Posts

Showing posts from February, 2013

Removing HTML tags from Magento posts to Facebook -

Image
when post links magento product pages on facebook, html tags in facebook snippets. i've added meta descriptions both products see here. edit: reread question! it looks of products have html tags in meta_description, worth having @ that, that's not main issue. now i've understood issue, take @ great tutorial solve problem setting correct meta data facebook http://www.gofishclientcatchers.com/internet-marketing-blog/development-blog/facebook-meta-tags-for-magento/ the important part relates issue strip_tags php function; <meta property="og:description" content="<?php echo strip_tags(mage::registry('current_product')->getshortdescription()); ?>" /> you use; <meta property="og:description" content="<?php echo strip_tags(mage::registry('current_product')->getdescription()); ?>" /> if not creating short description. t

Java HashSet contains Object -

i made own class overridden equals method checks, if names (attributes in class) equal. store instances of class in hashset there no instances same names in hashset. my question: how possible check if hashset contains such object. .contains() wont work in case, because works .equals() method. want check if same object. edit: package testprogram; import java.util.hashset; import java.util.set; public class example { private static final set<example> set = new hashset<example>(); private final string name; private int example; public example(string name, int example) { this.name = name; this.example = example; set.add(this); } public boolean isthisinlist() { return set.contains(this); //will return true if equal instance in list //but should not //it should return true if object in list } public boolean remove() { return set.remove(this); } //override equals

I know that generic arrays are not supported by Java, but I don't know how to fix this so it will work -

i'm try create hashtable , part of code requires array, when it's not delcared generic unchecked warnings, know generic arrays aren't supported, i'm not sure how fix this. array = new hashentry<anytype>[ nextprime( arraysize ) ]; i suggest checking out jdk's own code hashmap , resize method , these lines: @suppresswarnings({"rawtypes","unchecked"}) node<k,v>[] newtab = (node<k,v>[])new node[newcap]; newtab assigned main instance variable, table . so, if jdk can't avoid @suppresswarnings , neither you.

excel vba - How to insert into a TEMP Table in VBA -

when run following code receive error, "run-time error '1004': application-defined or object-defined error" when select debug, following line highlighted: .refresh backgroundquery:=false querystr = "set nocount on" & chr(13) & _ "select csd.storeno 'storeno',sum(csd.amount) totalsales " & chr(13) & _ "into #salesofthestores " & chr(13) & _ "from purchase.dbo.cashsheetdetail csd " & chr(13) & _ "inner join purchase.dbo.cashsheetheader csh on csh.transferid = csd.transferid , csh.storeno = csd.storeno " & chr(13) & _ "where csd.comments = 'total gross sales' , csh.dayenddate between '" & startdate & "' , '" & enddate & "' " & chr(13) & _ "group csd.storeno; " activesheet.querytables.add(connection:= _ "odbc;driver=sq

mysql - Count and group by -

i have 2 tables : exp_channel_titles t (parent table) exp_category_posts p (many many table links t via column entry_id) i need know how many entries per category each author_id has in p using author_id , entry_id fields t t.channel_id = 7 . e.g. select cat_id, author_id exp_channel_titles t, exp_category_posts p t.channel_id = 7 , t.entry_id = p.entry_id group p.cat_id group t.author_id try this: select p.cat_id, t.author_id, count(*) cat_entries exp_channel_titles t join exp_category_posts p on t.entry_id = p.entry_id t.channel_id = 7 group p.cat_id, t.author_id

mysql - Is it possible to use a nested select statement as a column that has multiple rows? -

mysql 5.5.36 apache 2.2.15 centos 6.6 php 5.4.31 sorry terrible title, here looking with; have 2 tables, each order has single row , order_items has multiple rows. order id | date | customer | status order_items id | order_id | item_id | item_name my current code cycling through open orders doing secondary db call grab items , place them single row of html table this: order_id | date | customer | status | item_name 1 | 2014-11-20 | 100233 | open | widget (item id 0004) | widget (item id 0004) 2 | 2014-11-21 | 103327 | open | widget c (item id 0005) | widget d (item id 0006) the desired end result shown in above table, entire thing within singular query if possible, instead of having multiple queries per order displayed. now, after googling while, haven't been able find trying do. looked @ group_concat, concatenates columns within single table looks like

swift - Getting PFUser's username (Parse.com) -

i trying username of pfuser. code below works without line: var username = nameid.username string when added collection view not show results. ideas? var query = pfquery(classname:"chat") // query.wherekey("user", equalto:currentuser) query.wherekey("rideid", equalto:currentobjectid) query.orderbyascending("createdat") query.findobjectsinbackgroundwithblock { (objects: [anyobject]!, error: nserror!) -> void in if error == nil { // find succeeded. nslog("successfully retrieved \(objects.count) scores.") // found objects object in objects { nslog("%@", object.objectid) var testid = object.objectid println(testid) self.orderedidarray.append(testid) var message = object.objectforkey("message") string self.messagestring = messa

java - Swing gui disappeared -

i working on simple gui options add,remove,write disk etc.. while coding program came problem gui start disappear , opening blank frame in design tab/editor(also in run time), tried undo multiple times , coming time point cannot undo anymore. posted code have. solution problem ? package nikola.lozanovski.bitola; import java.awt.eventqueue; import java.awt.font; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.util.hashtable; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.joptionpane; import javax.swing.jpanel; import javax.swing.jtextfield; import javax.swing.border.emptyborder; public class vozenred extends jframe { public vozenred() { } /** * */ private static final long serialversionuid = 1l; private jpanel contentpane; private jbutton delete; private jbutton t

google apps script - My conditional rows are coming over as a string of all data in one cell? -

here have: var values = spreadsheetapp.getactivespreadsheet() .getsheetbyname('base').getrange('a:m').getvalues(); var row, len, data = []; (row = 0, len = values.length; row < len; row++) if (values[row][12] == 'red') data.push([values[row]]); var dest = spreadsheetapp.getactivespreadsheet() .getsheetbyname('basics'); dest.clearcontents(); var lastrow = dest.getlastrow(); dest.getrange('a1:m1').offset(lastrow, 0, data.length, data[0].length).setvalues(data); it working, in getting data source sheet correctly, in dest, putting data cells cell a1, rather corresponding cells. doing wrong? try code. copies without empty rows in destination sheet. function copyvalues(){ var sheet = spreadsheetapp.getactivespreadsheet().getsheetbyname('base'); var values = sheet.getrange('a:m').getvalues(); var row, data = []; (row = 0, len = sheet.getlastrow(); row < sheet.getlastrow(); row++){ if (values[row][12]

stored procedures - SQL: Writing a bulk insert script that ignores existing entries -

i'm starting existing program uses sql database , trying modify uses bulk insert (rather one-by-one) , prevents repeat entries. here's i've got function add 1 user (as long user doesn't exist), should working: use [debugdatabase] go set ansi_nulls on go set quoted_identifier on go create procedure [dbo].[adduser] @id bigint, @login nvarchar(100), @consolename nvarchar(100), @ip nvarchar(50) begin set nocount on; declare @foundid bigint = (select id [user] id = @id) if @foundid null begin insert [user] (id, login, consolename, ip) values (@id, @login, @consolename, @ip) end else begin update [user] set [id] = @id, [login] = @login, [consolename] = @consolename, [ip] = @ip id = @id end select top 1 * [user] id = @id; end go now i'd write function bulk-insertion, calls above function check each entry. wa

php - Sync multiple iCalendars (Airbnb, Flipkey, Google Calendar, etc) -

i'm developing website apartments rental. i'm using wordpress hotel theme tweaked instead of "rooms" uses "flats" , booking plug-in. each of flats advertised in airbnb , flipkey. what need able sync calendars if, instance, books flat in airbnb, flat automatically marked "non available" in both website , flipkey. done using feeds .ics provided both companies. there output feed , input feed both, if paste output in input of other , vice versa, thing works perfectly. now, need way of centralizing both calendar in 1 system , using system feed inputs of airbnb, flipkey , own booking plugin of wordpress. i've tried with: php icalendar (it can, google calendar, feeds, doesn't -as far know- provide unified output). services http://www.accommodationcalendar.com input, no output either. maybe http://www.davical.org/ option, i'm using shared hosting, can't install (as far know) -the reason being shared hosting has mysql , not pos

What does set_if_nil.call do in ruby? -

i'm relatively new ruby , have legacy code support. in following line don't understand: set_if_nil.call(:type, @config['type_1']) i assume it setting type variable to value of @config['type_1'] , why call method well? also, there no type variable in class. method in passed object. parameter of object? presumably set_if_nil defined proc. if is, call method executes proc, passing in :type , @config... parameters. afaik, set_if_nil not defined part of ruby standard library, understand more details what's happening you'll have track down it's defined.

javascript - How to find number of data points in a given range in d3 -

i trying find number of data points in series lie in given range (xmin,ymin) (xmax, ymax) . give example, if series line plot looks (1,1) (2,2) (4,4) (6,7) (9,10) , range (3,3) (8,8) , 2 points satisfy criteria looking , => (4,4) (6,7) (the actual problem trying solve if have rectangle zoom on series plot, allow zooming if rectangle of zoom @ least captures n data points original series) is there easy way in d3? thank you this straight-forward javascript only: var data = [[1,1],[2,2],[4,4],[6,7],[9,10]]; function filterdata(minarr, maxarr) { return data.filter(function(d) { return d[0] >= minarr[0] && d[0] <= maxarr[0] && d[1] >= minarr[1] && d[1] <= maxarr[1]; }); } console.log(filterdata([3,3], [8,8])) //[[4,4],[6,7]]

jquery - defining local variables using an object in javascript -

may silly question, wanted know if there's difference (performance wise) between following. someobject.prototype.myfunc = function() { var = 123; var b = "something"; ... } someobject.prototype.myfunc = function() { var loc = {}; loc.a = 123; loc.b = "something"; ... } i've been doing second way, been easier debug doing console.log(loc) , it's habit doing server side code i've been defining local structures. as per tests done phil ( http://jsperf.com/direct-variable-vs-object-property-assignment ) there's noticeable difference between using direct variable assignment , object property assignment. definitely using direct variable assignment

angularjs - Unit testing angular intercept -

is possible? i can mock $httpbackend, , intercept called during $httpbackend.flush(); cannot hold of it. intercept function changes state of $rootscope, not help, because both on request , on response -- , state after response. is there way check state of $rootscope after request? there way check state of config, input parameter? here code: // application // angular.module('myapp',[]); // // controller // var myapp = angular.module('myapp'); myapp.controller('fooctrl', ['$scope', '$http', function ($scope, _$http_) { var $http = _$http_; $scope.onsubmit = function() { var config = {method: 'post', url: '/foo.py', data: 'bar', myprop: 'request'}; $http(config).success(function(result) { }).error(function(data) { $scope.error = data; }); }; }]); // // service // var fooservice = angular.module('fooservice', ['ngresource']); fooservic

java - Restful Web Service Error -

Image
i use javax restfull web service. can return string mobile app. cant return model class. want return employee model. give error; full error: severe: servlet.service() servlet [jersey rest service] in context path [/cafesiparis] threw exception [servlet execution threw exception] root cause java.lang.abstractmethoderror @ org.codehaus.jackson.map.annotationintrospector$pair.findserializer(annotationintrospector.java:1148) @ org.codehaus.jackson.map.ser.basicserializerfactory.findserializerfromannotation(basicserializerfactory.java:362) @ org.codehaus.jackson.map.ser.beanserializerfactory.createserializer(beanserializerfactory.java:252) @ org.codehaus.jackson.map.ser.stdserializerprovider._createuntypedserializer(stdserializerprovider.java:782) @ org.codehaus.jackson.map.ser.stdserializerprovider._createandcacheuntypedserializer(stdserializerprovider.java:735) @ org.codehaus.jackson.map.ser.stdserializerprovider.findvalueserializer(stdserializerprovider.j

xml - xslt writing to uncles of a context in a for-each -

i have following input: <element1> <elelment2/> </element1> and i'm grabbing node set bunch of files , inserting many elements find in node set using: <xsl:variable name="root" select="/" /> <xsl:variable name="id" saxon:assignable="yes" select="0"/> <xsl:variable name="views" select="collection('file:/c:/temp/?select=*.xml;recurse=yes')"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="/element1/element2"> <xsl:copy> <xsl:apply-templates select="@* | *"/> <xsl:for-each select="$views/element3[somefilter]"> <element3 name="{@name}" xmi.id="{$id}"/> <saxon:assi

ember.js - Ember data: side-loading hasMany relationship using a non-id field -

i wondering if can side-load hasmany relationship in ember-data - hooked on non-id column. here code snippets- app.profile = ds.model.extend({ firstname: ds.attr(), lastname: ds.attr(), photo: ds.hasmany('photo', {async:true}) }); app.photo = ds.model.extend({ path: ds.attr('string'), title: ds.attr('string'), owner: ds.belongsto('user', {async:true}), }); app.profileserializer = ds.restserializer.extend({ attrs:{ photo: {embedded: 'load'} }, }); the json returned localhost:/api/profiles/ is: [ { "photos": [ "media/pic3.jpeg", "media/pic4.jpeg" ], "id": "5441b6b2bc8ae304d4e6c10e", "first_name": "dave", "last_name": "gordon", "profile_pic": "media/profilepic.jpg", "member_since": "201

vb.net - Convert Array to DayOfWeek -

any idea how make function convertarraytodayofweek . using dll https://taskscheduler.codeplex.com/documentation import system.win32.taskscheduler ... function convertarraytodayofweek() dayofweek dim a() integer = {1,2,3,4,5,6} dim d dayofweek 'todo : how change a() d = 1 or 2 or 3 or 4 or 5 or 6 return d end function i try create task trigger every monday , saturday (or other day depending on user wishes) imports microsoft.win32.taskscheduler module module1 sub main() using ts new taskservice() ' create new task definition , assign properties dim td taskdefinition = ts.newtask td.registrationinfo.description = "does something" ' add trigger will, starting tomorrow, fire every other week on monday ' , saturday , repeat every 10 minutes following 11 hours dim wt new weeklytrigger() wt.startboundary = datetime.today.adddays(1)

hadoop - Map function fails in mapreduce run in EMR -

i running own map reduce tasks on amazon emr. see map tasks failing, not able find out reason failed map tasks. import fileinput import csv mydict = {} csvreader = csv.reader(fileinput.input(mode='rb'), delimiter=',') newline in csvreader: #newline = line.split(',') if newline[6] not in mydict.keys(): #print 'zipcode: ' + row[6] + ' hospital code: ' + row[1] mydict[newline[6]] = 1 elif newline[6] in mydict.keys(): #print 'value in row '+ str(mydict[row[6]]) mydict[newline[6]] += 1 key in mydict.keys(): print '%s\t%s' % (str(key), str(mydict[key])) the map task read csv file given input, create key,value pairs using data in 2 columns. reduce task aggregate them , print them. the following stderr obtained maptask when #!/usr/bin/env python not added @ top of script. if adde,d stderr blank , yet maptask fails.: /mnt/var/lib/hadoop/tmp/nm-local-dir/usercache/hadoop/appca

Visual Studio "Clean & Rebuild" in one button? -

my solution i'm working on it's has specialy. , sometime need clean solution , after rebuild solution , if not web application can not access. why made bat file work , bind bat file button in visual studio toolbar. but way, visual studio run bat file, clean , rebuild 1 solution i'm defined before in bat file. want button can clean , rebuild on solution opening, made combo of clean , rebuild commands of visual studio 1 button. is there way me? i'm using visual studio 2013. as @blorgbeard said, what rebuild solution? rebuild solution clean , build solution scratch, ignoring it’s done before. deletes assemblies, exe’s , referred files compile again. what clean solution? clean solution delete compiled files (i.e., exe’s , dll’s) bin/obj directory. rebuild means compile , link source files regardless of whether changed or not. build normal thing , faster. versions of project target components can out of sync , rebuild necessary make build suc

storing contents of file into variables in c++ -

i'm working on program requires me create hash table contents of file. file contains records (1 per line) include key (int), name (string), code (int), , cost (double). have code written of program create hash table, however, i'm having trouble figuring out how should load table file. more specifically, how store each piece of record corresponding variable? the code kind of long, if think posting answer question, let me know , i'll glad include it. i feel should include though, have struct set hold information contained in each record have set follows: struct record { int key; string name; int code; double cost; } if need see other portions of code, or code whole, let me know. if data file has white-space separated items in lines, can use example following code: #include <iostream> #include <fstream> using namespace std; typedef struct record { int key; string name; int code; double cost; }

image processing - How do I group the pairs of pixels on MATLAB -

i have image read in using imread function. goal collect pairs of pixels in image in matlab. specifically, have read paper, , trying recreate following scenario: first, original image grouped pairs of pixel values. pair consists of 2 neighboring pixel values or 2 small difference value. pairing done horizontally pairing pixels on same row , consecutive columns, or vertically, or key-based specific pattern. pairing through pixels of image or portion of it. i looking recreate horizontal pairing scenario. i'm not quite sure how in matlab. assuming image grayscale, can generate 2d grid of co-ordinates using ndgrid . can use these create 1 grid, shift horizontal co-ordinates right make grid , use sub2ind convert 2d grid linear indices. can use these linear indices create our pixel pairings have described in comments (you should add post btw). what's important need skip on every other column in row ensure unique pixel pairings. i'm going assume imag

Running a Ruby class from a Shoes Edit Line -

hello all, i have finished writing ruby class complete supposed to, since ruby, have been running through terminal , need more user-friendly (i.e. have gui). googled , came across shoes, seems nice ruby gui toolkit, , looking for. however, despite googling can't seem figure out how use shoes gui edit line send argument class made. here edit line shoes.app background white para "application name" stack(margin: 12) para "message" flow edit_line button "enter" end end end in short, there way gets.chomp (or literally else similar) , set equal instance variable? yes! assign elements want keep track of instance variables, , pass block button (the block gets executed when button clicked). try this: shoes.app background white para "application name" stack(margin: 12) @message = para "message" flow @edit_line = edit_line button "enter"

Makefile: extract pattern from a full path string -

in makefile, can full path string $(curdir) . result /home/jones/prj/platform/application_ubuntu/build_os . how extract ubuntu string? i use subst replace '/' space. dir = $(subst /, " ", $(curdir)) i result home jones prj platform application_ubuntu build_os . then try use filter command cannot use % or wildcard match application_ubuntu out. in advance. use penultimateword macro answer here . penultimateword = $(wordlist $(words $1),$(words $1), x $1) build_os=$(call penultimateword,$(subst /, ,$(curdir))) build_os=$(subst _, ,$(build_os)) build_os=$(word 2,$(build_os)) this sensitive underscores in path/etc.

Matlab - Continue to next elseif in nested if statements -

i have bunch of nested 'if' statements in 1 another, , can't them flow way want them. have if statement, , if met, run uniqueness test (myuniquetest), , if shows condition gives unique result, want log , go on. i've got part figured out however, if first condition not give unique result, want continue rest of elseif statements see if subsequent ones give unique result. (i have total of 8 elseif statements within code, imagine methodology iwll same.) code looks this: if edgedouble(y0-1, x0) == 1 && (y0-1)>=y1 && (y0-1)<=y2; testpt = [y0-1, x0]; uni = myuniquetest(testpt, mypoints); if uni ==1; k = k+1; mypoints{1,k} = testpt; mypoints = testmypoints(mypoints, edgedouble, x1, x2, y1, y2); end elseif edgedouble(y0-1, x0+1) ==1 && (y0-1)>=y1 && (y0-1)<=y2 && ... (x0+1)>=x1 && (x0+1)<=x2; testpt = [y0-1, x0+1]; uni = myuniquetest(testpt, mypoints); if uni ==1; k = k+1;

ios - Usage of CGrect for positioning button in objective c frame view bounds -

Image
i trying position button on uiimageview in uicollectionview . _prevbutton.frame = cgrectmake(self.view.bounds.origin.x, self.view.bounds.size.height, 50, 30); how can use (self.view.bounds.origin.x, self.view.bounds.size.height) set button width , height ?i pretty new in objective c .how can comprehend use button sizing? take @ clear understanding.

c# - Modifying the string list using reflection -

say, have class user has (string firstname, list siblings) want modify properties of user. let's assume want replace strings b instead of a. user : { firstname: "rager", siblings : { "stalin", "marx" } } using reflection need read individual strings , following output object. user : { firstname: "rbger", siblings : { "stblin", "mbrx" } } let's consider below function private object modifyobject(object t){ foreach(var propertyinfo in t.gettype.getproperties(){ var stringtobemodified = propertyinfo.getvalue(t,null); propertyinfo.setvalue(t, stringtobemodified.replace("a","b"),null) } } the above code works fine when modifying firstname. dont know how modify strings in siblings. i thought make use of 3rd property (optional index value indexed properties). looks whole property not indexed. siblings, propertyinfo.getvalue(t,null) gives 2 strings. [0] -- stalin [1]

javascript - What are the pros and cons of using Meteor-Roles? -

i'm looking make app there admin account can manage other user's profiles. question is, pros of using meteor-roles? watched video on youtube , looked through documentation, seems use pub/sub , on create add field named "role:". need package? seems meteor's built-in pub/sub , oncreate function simple , enough accomplish feature? you roll own (bad pun intended, sorry), why? source code available: meteor-roles . when decide need it, add it. if don't think need yet, don't add yet. i use apply "admin" role users, , "blocked" role others prevents them logging in. package gives handy functions add roles users, or check see if user has role. can handy finer-level control on publications (e.g. users might have read-only access, whereas users role might have read-write access).

makefile - Breaking up large C program in Header files and C files -

i have break following code following files: main.c, student.c, students.h, mergesort.c, mergesort.h, aux.c , aux.h. have make makefile compile all. program mergesort implemented on linked list. i've separated code, have no clue in terms of headers files , include directives, , less of clue how create makefile. need include headers files, , need include in c files? example, if mergesort.c using functions students.c, have include students.h in mergesort.c? here's code original program: #include <stdio.h> #include <stdlib.h> #define name_len 25 struct node { int number; char name[name_len+1]; struct node* next; }; /* functions manage linked list. functions prompt user , read standard input if needed. */ struct node* insert (struct node* student_list); void print_student (struct node* student); void print_list (struct node* student_list); void search (struct node* student_list); struct node* delete (str

Is there a way to get facebook public info from name? -

is there way if provide name and/or company name user's facebook details eg : if enter name "john dropes" related public info(eg : birthday,location etc) of users name. i not going use facebook username or id should able info name. you can use search list of users: /search?q=john%20doe&type=user this return list of users match name more or less closely: { "data": [ { "name": "john doe", "id": "7688817164415" }, { "name": "rubén doe", "id": "3650636703421" }, ... ] } you can issue request id of individual users: /7688817164415 this give info. aware standard info set narrow.

java - Censored Words Condition -

i need program print "censored" if userinput contains word "darn", else print userinput, ending newline. i have: import java.util.scanner; public class censoredwords { public static void main (string [] args) { string userinput = ""; scanner scan = new scanner(system.in); userinput = scan.nextline; if(){ system.out.print("censored"); } else{ system.out.print(userinput); } return; } } not sure condition if can be, don't think there "contains" method in string class. the best solution use regex word boundary. if(mystring.matches(".*?\\bdarn\\b.*?")) this prevents matching sdarns as rude word. :) demo here

perl - Using shared memory in mod_perl environment -

i have requirement wherein i have place data structure (perl hash) in memory, each http process (running perl script) use hash. the hash structure around 300 mb. the environment mod_perl i thought of creating module load @ apache start creates hash in shared region , returns reference it. can please comment on behaviour, or suggest alternative solutions. please point resources check examples. if place huge hash data on mod_perl memory, mod_perl parent process reads @ server startup phase. in first, create your/hugedata.pm on @inc directory. package your::hugedata; our %dictionary = ( .... ); next, apache process reads on startup. # in apache.conf (or anywhere apache config file) perlmodule your::hugedata then script can use %your::hugedata::dictionary package variable. # in mod_perl handler script or modperl::registry (cgi emulate) script. use your::hugedata; ... $tokyo = $your::hugedata::dictionary{tokyo}; when use prefork mpm on linux apac

c# - Catch "FileNotFoundException" -

i have method folder path of particular file: string filepath = path.combine(environment.getfolderpath( environment.specialfolder.mydocuments), "file.txt"); and later, use read text in file: streamreader rdr = new streamreader(filepath); // "c:\users\<user>\documents\file.txt" string mystring = rdr.readtoend(); trouble is, if file doesn't exist, throws filenotfoundexception (obviously). want use if/else catch error, in user can browse find file directly, i'm not sure use verify if filepath valid or not. for example, can't use: if (filepath == null) because top method retrieve string return value, whether or not valid. how can solve this? you can use file.exists :- if(file.exists(filepath)) { //do } else { }

ArrayList in Scala with Gistlabs Mechanize. Unable to use foreach -

i'm trying use gistlabs mechanize web page processing using scala. i've been able figure out quite stuff despite fact there little documentation. thankfully, there source. snippets work: val agent= new mechanizeagent() agent.setuseragent(useragent) val response:abstractdocument= form.submit() so, want read through of cookies, this. but, first let's cookies , class: val cookiestore = response.getagent().cookies().getall() println(cookiestore.getclass()) and response: class java.util.arraylist so, cookiestore arraylist , should able use foreach() it, right? when try that: cookiestore.foreach { println } i error: value foreach not member of java.util.list[com.gistlabs.mechanize.cookie.cookie] clearly, i'm doing wrong scala, what? java.util.list has not method foreach . can convert scala list using implicit conversion. add import scala.collection.convert.wrapasscala._ source file.

docker - What's the difference between Kubernetes and Flynn/Deis -

i have read introduction of these projects, still cannot clear idea of difference between kubernetes , flynn/deis. can help? kubernetes 3 things: a way dynamically schedule containers (actually, sets of containers called pods) cluster of machines. manage , horizontally scale lot of pods using labels , helpers (replicationcontroller) communicate between sets of pods via services, expose set of pods externally on public ip , consume external services. necessary deal horizontal scaling , dynamic nature of how pods placed/scheduled. this tool set managing compute across set of machines. isn't full application paas. kubernetes doesn't have idea "application" is. paas systems provide easy way take code , deployed , managed application. in fact, expect see specialized paas systems built on top of kubernetes -- redhat openshift doing. one way think kubernetes system "logical" infrastructure (vs. traditional vm cloud systems

Go app hangs when testing a function that contains a lock -

this function wrote adds request request queue: func (self *requestqueue) addrequest(request *request) { self.requestlock.lock() self.queue[request.normalizedurl()] = request.responsechannel self.requestlock.unlock() } and 1 of tests: func testaddrequest(t *testing.t) { before := len(rq.queue) r := samplerequests(1)[0] rq.addrequest(&r) if (len(rq.queue) - 1) != before { t.errorf("failed add request queue") } } when run test, application hangs. if comment out test, works fine. think problem locking inside function. there i'm doing wrong? help! the problem infinite loop in samplerequests() function: func samplerequests(num int) []request { requests := make([]request, num, num+10) := 0; < len(requests); i++ { r := newrequest("get", "http://api.openweathermap.org/data/2.5/weather", nil) r.params.set("lat", "35") r.params.add("

java - How to use android-async-http library -

i trying use android-async-http library asynchronous file upload server. callback inside method call upload. however, error when trying call method asynctask class. can spot getting error? here upload method: public void upload(string title, string genre, string description, string songuri, int accountid) { file song = new file(songuri); try { string url = uri.parse(getresources().getstring(r.string.audio_upload_url)) .buildupon() .appendqueryparameter("title", title) .appendqueryparameter("tags", genre) .appendqueryparameter("description", description) .appendqueryparameter("accountid", string.valueof(accountid)) .build().tostring(); asynchttpresponsehandler httpresponsehandler = createhttpresponsehandler(); requestparams params = new requestparams(); // path retrieved library or camera //strin

cordova - File Upload Not working in Android 4.4.2 -

i have created app using phonegap. app works fine on android versions. file upload feature on app not work on android 4.4.2. have googled lot on issue, , have found google has disabled feature android 4.4.2. is there no work around @ all? in need of solution problem. great if can suggest solution issue. there's no chance file uploads working in webview on android 4.4.2. nevertheless, onclick or onchange events still fired on <input type="html"> element. this means can either file there via javascript or call java method event handlers , file upload manually. for cordova, there's issue here: https://issues.apache.org/jira/browse/cb-5294 ... , workaround here: https://github.com/cdibened/filechooser

After cloning repository from bitbucket shows dll missing error -

i'm working on visual studio 2014 , have pushed project in bitbucket repository. i've cloned same repository in machine. problem other machine shows lot of .dll files missing. how solve it? please @ this screen capture . the problem because *.dll appears in gitignore_global.txt file. though local repository did not have gitignore file, found global file within c-drive's mydocument folder. what worked me, in order dlls bitbucket, navigate through git bash folder containing dlls, , use command: git add <assemblyname>.dll -f

ios - Objective-C Animating a character -

for starters trying animate main character of game can later replace images in array sprites - ive done in header file main character : - (void)animate; and in implementation file ive written : -(void) animate{ uiimage* img1 = [uiimage imagenamed:@"obstacle.png"]; uiimage* img2 = [uiimage imagenamed:@"obstacle02.png"]; uiimage* img3 = [uiimage imagenamed:@"obstacle03.png"]; uiimage* img4 = [uiimage imagenamed:@"obstacle04.png"]; nsarray *images = [nsarray arraywithobjects:img1,img2,img3,img4, nil]; uiimageview* imageview = [[uiimageview alloc] initwithframe:cgrectmake(0.0, 0.0, 160.0, 160.0)]; //images.name = @"animation"; [imageview setanimationimages:images]; [imageview setanimationrepeatcount:0]; [imageview setanimationduration:0.5]; //imageview.center = character.center ; [imageview startanimating]; // character used myview // images inside array ! } take note

c# - How to use ElementName binding from resource? -

i've added menuflyout button in itemscontrol.itemtemplate. able bind current item commandparameter. want bind command menuflyoutitem. in codebehind : layoutroot.datacontext = this; so if bind layoutroot bind current usercontrol. following binding not working: command="{binding activateprofilecommand, elementname=layoutroot}" it gives me not errors in output it's not working. here's full example: <controls:headerdecorator x:uid="accountsheader" text="accounts" x:name="layoutroot" name="layoutroot"> <controls:headerdecorator.resources> <menuflyout x:key="accountmenuflyout"> <menuflyoutitem text="activate" name="activate" command="{binding activateprofilecommand, elementname=layoutroot}" commandparameter="{binding}" /> </menuflyout> </controls:he

java - Writing a ZIP on the fly? -

at moment tracing load of files come system directory. issue running out of inodes (the number of files can store). "replay" reasons (there other reasons too), files separate files, can't write 1 file. i wondering whether can replace code write files zip on fly. however, concern - happens if jvm crashes during procesing whatever reason, end corrupt zip file? or there way can ensure zip valid after every "write"?

regression - R Shiny: Rendering summary.ivreg output -

Image
i'm trying render instrumental variable regression summary in r shiny here code: iv=ivreg(lwage~educ+exper|nearc4+exper) summary(iv) when use rendertable following error: no applicable method 'xtable' applied object of class "summary.ivreg" any suggestions how go around issue? this website, if want see i'm doing exactly: https://ieconometrics.shinyapps.io/test/ rendertable expect object xtable methods exist, can see methods avaible : methods(xtable) , , doen't work summary.ivreg , can build method or obtain result these code below : library(shiny) library(aer) library(reporters) # define server server <- function(input, output) { output$raw_summary <- renderprint({ fm <- ivreg(log(packs) ~ log(rprice) + log(rincome) | log(rincome) + tdiff + i(tax/cpi), data = cigarettessw, subset = year == "1995") print(summary(fm)) }) output$summary_table <- renderui({ fm <- ivreg(lo