Posts

Showing posts from April, 2014

c# - Autoscroll ListView in WPF using MVVM -

i try have list automatically scrolls end when adding new line. here simple mvvm example in want integrate : there button adds lines list when clicked. model code : public class student { public string lastname {get; set;} public string firstname {get; set;} public student(string lastname, string firstname) { this.lastname = lastname; this.firstname = firstname; } } public class studentsmodel: observablecollection<student> { private static object _threadlock = new object(); private static studentsmodel current = null; public static studentsmodel current { { lock (_threadlock) if (current == null) current = new studentsmodel(); return current; } } private studentsmodel() { (int = 1; <= 50; i++) { student astudent = new student("student " + i.tostring(), "student " + i.tostring()); a

windows - C++ Addon example unable to find the created module -

Image
hey trying addon example located here http://nodejs.org/api/addons.html (hello world). seems run fine until final step. recieve error in picuture attached. [for shot put hello.js , hello.node in same folder no sucess). point location of hello.node, keep getting error have success example or more own c++ add on?? thanks in advance.

vsts - No files checked in migration error -

trying migrate version control data visual studio online local tfs. got following error. have retried multiple times , still same error. oh-scm-009: error occurred while sync. no files checked in. not sure go one. there somewhere can more details?

java - How to create array of ArrayLists -

this question has answer here: create array of arraylists 15 answers how create integer arraylist? [duplicate] 5 answers for program need create array of arraylists. is possible? this code trying use: public static arraylist<chemical> [] [] chemicals; chemicals = new arraylist<chemical>[cols][rows]; it gives generic array creation error. thank you. this seems work in java 8 arraylist<chemical>[][] chemicals = new arraylist[cols][rows];

Xcode C++ "Use of undeclared identifier" error with another class -

i've done reading on site here undeclared identifier errors in xcode , c++. seems comes small typo somewhere in code, can't figure out life of me why i'm getting error (also please note beginner in c++, may making dumb mistake). i'm writing own library artificial neural nets, , when try compile 'connection' class bunch of "use of undeclared identifier 'node'" error on every line in connection.h file has node class somewhere in it. classes node , connection in same namespace, , both cpp files implemented functions declared in header files. here header files both classes: connection.h (where i'm having problems): #include <iostream> #include <tuple> #include <boost/shared_ptr.hpp> #include "node.h" namespace ann{ class connection{ public: connection(); connection(boost::shared_ptr<node> innode, boost::shared_ptr<node> outnode, float weight, int connid); ~c

php - Data Insert tool keep saying "mkdir(): File exists in" -

i have created admin user page data can inserted. everytime try execute says: mkdir(): file exists in rental/search/add_property_2.php on line 98 here code: $p_img9 = $_post['p_img9']; $p_img10 = $_post['p_img10'];*/ if (!file_exists('tmp_imgs/'.$property_id)) { // creating temprory directroy images mkdir('tmp_imgs/tmp_'.$property_id, 0777, true); ...line 98 } foreach ($_files['p_img']['name'] $f => $name) { $allowedexts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $name); $extension = end($temp); seeking on this property id auto generated , on previous page defined as $property_id = get_new_property_id();... and second page getting error $property_id = $_post['property_id'];.. your check condition doesn't match directory creating. can fix so $directory = 'tmp_imgs/tmp_'.$property_id; if (!file_exists($director

plotting residuals in R error -

i'm trying plot fit in r , i following error: error in xy.coords(x, y, xlabel, ylabel, log) : 'x' , 'y' lengths differ here code: exercise <- as.factor(c(10, 10, 20, 20, 10, 10, 20, 20)) time <- c("pm", "am", "am", "pm", "am", "pm", "pm", "am") glucose <- c(71.5, 103, 83.5, 126, 125.5, 129.5, 95, 93) fit1 <- aov(glucose ~ exercise + time) summary(fit1) par(mfrow = c(2, 2)) plot(fit1) you need make sure time factor. time <- as.factor(c("pm", "am", "am", "pm", "am", "pm", "pm", "am")) then plot work. looks aov gets bit confused when pass character vector.

ios - Calling UITapGestureRecognizer on specific views in a viewcontroller -

i have 4 views in view controller. want call specific function on touching specific view example if touch on view 1 in iphone screen, want call corresponding function. i have view controller , 4 views in storyboard. how can load specific views in code , on view touch implement function. individual touch gesture 4 views corresponding selector methods work.

java - Objectify Appengine should query a few rows -

is there way load fix number of saved rows/data using objectify v5? for example, wanted load 10. query humanentity human = ofy().load().type( humanentity.class ); what add here? found it! query<humanentity> human = ofy().load().type( humanentity.class ).limit( 10 );

How do I print the values of hashsets that are saved in a file in ruby -

i have file (named ter.txt ) contains hashsets content below: {"qty"=>"gfg", "unit"=>"gfg", "item"=>"xcv", "cost"=>"0.0", "salestax"=>"0.0"} {"qty"=>"gdf", "unit"=>"g", "item"=>"gg", "cost"=>"0.0", "salestax"=>"0.0"} i want print values of hashsets. i've tried following got error of undefined local variable or method 'item' file = file.open('ter.txt', 'r').map { |line| line.split("\n")[0] } file.each |hash| p hash p " #{hash[item]}" end you shouldn't save data way. perfect case use yaml. write file like: --- - qty: gfg unit: gfg item: xcv cost: 0.0 salestax: 0.0 - qty: gdf unit: g item: gg cost: 0.0 salestax: 0.0 then can load with: require 'yaml' data

How can I convert the input __NSArrayM into an AppleScript list in an Automator Action project? -

Image
automator action i making custom automator action manipulating text input. tested input see class , result __nsarraym . means need somehow convert input list applescript can understand—and string. need isolate string , convert same object output. summary: convert __nsarraym input applescript list object convert applescript list object __nsarraym output i automator this: coding attempt in xcode my attempt @ coding looks like: script change_case property parent : class "ambundleaction" property menuchoices : {"title case","upper case","lower case","toggle case"} property menuselection : 0 on runwithinput_fromaction_error_(input, anaction, errorref) set inputclass class of input -- debugging set menusel menuselection if menusel 0 -- title case display dialog menusel string end if tell class "nsarray" of current application set inputvalues

Xcode 5.1.1 and SVN problems -

i send code svn server using xcode. found xcode 4 has in provisioning profile tool manage svn (creating folders & pulling code). in xcode 5 change , added source control. i added svn server address (inlucding name , password) in preferences -> accounts each time try commit , pull files svn server there information "no remotes found". how can solve ? how can manage structure of folders in svn using xcode ? i tried resume this post intervention has been deleted, not answer. can't add bounty (not enough reputation) , can't add comment (same issue) supposed if not adding answer or adding new question same problem?

Opinion about Android layout design to support multiple screens -

i'm developing android app needs support phones , tablets (minsdk:14). support mean layout , images (heights, widths, padding, margin, etc) should scale different screen sizes. don't need "different" layouts tablets such navigation drawer or rearranged layouts. at first tried creating layout-sw600dp, layout-sw720dp... realized duplicating layouts , changing measures (heights, widths, etc). don't because difficult mantain in future. instead left layouts in default /layout folder. created several dimens.xml , place them in folders /values, /values-sw600dp etc. for /values/dimens.xml defined: <dimen name="dp1">1dp</dimen> <dimen name="dp2">2dp</dimen> ... <dimen name="dp100">100dp</dimen> for /values-sw600dp/dimens.xml defined: <dimen name="dp1">2dp</dimen> <dimen name="dp2">4dp</dimen> ... <dimen name="dp100">200dp</dimen&g

javascript - AngularJS: $digest required before $httpBackend.flush() -

i trying wrap head around why need call $rootscope.$digest() before $httpbackend.flush() test pass. if don't getting error: no pending request flush! here test: it('should post new task server', function() { $httpbackend.when('post', $rootscope.serverroot + '/task/create').respond({}); var created = false; mockboardservice.addtask({name: 'add dynamic categories'}) .then(function(response) { created = true; } ); $rootscope.$digest(); $httpbackend.flush(); expect(created).tobe(true); }) and service function it's calling: this.addtask = function(data) { return $http.post($rootscope.serverroot + '/task/create', data); } why need run $rootscope.$digest ? it looks mockboardservice.addtask doing async work. without $digest, it's trying flush() $httpbackend requests before async code has chance make request. $digetst() call giving time asy

optimization - ScaLapack operation, word and message counts -

i wondering if knows papers or working notes count how many operations scalapack routines perform , how many messages send , how many words. in terms of operation counts can browse golub , van loan's excellent matrix computations or check lapack's lawn 41 , assume don't change scalapack, cannot find on message , word counts , last resort before go through code.

c# - Sort a Dictionary<Point, int> based on its key -

i have dictionary<point, int> mydic , point class defined below: public class point { public double x { get; set; } public double y { get; set; } } how can sort mydic based on key using linq ? want order x y . for example if dictionary below: key (point (x,y)) value (int) -------------------------------------- (8,9) 6 (5,4) 3 (1,4) 2 (11,14) 1 it after sorting: key (point (x,y)) value (int) -------------------------------------- (1,4) 2 (5,4) 3 (8,9) 6 (11,14) 1 orderby , thenby should trick you: mydic.orderby(x => x.key.x) .thenby(x => x.key.y) .todictionary(x => x.key, x => x.value)

c++ - The key exist in the map variable but find cannot find it -

i have created class named myclass , define map as: map<string,myclass> myclasssample; i inserted variable , key: myclasssample["id"].setstring1_1("hi"); note: setstring1_1 setter of class then use code see if key available: if (myclasssample.find("id") != myclasssample.end()) { printf("problem"); } problem shown out put. condition true! function can return string! return myclasssample["id"].getstring1(); note: getstring1 getter of class you seem have misunderstanding of how map::find works. returns end() iterator when key you're searching cannot found . condition check if key present needs be if (myclasssample.find("id") == myclasssample.end()) // ^^ ==, not != { printf("problem"); }

c# - What does Set<TEntity> do in IDbSet interface? -

i read article uow in entity framework , has code this: public interface iunitofwork { idbset<tentity> set<tentity>() tentity : class; int savechanges(); } i dont understand set<tentity>() do ? all entities stored in context different flags (for example deleted, changed) in front of database. if savechanges called synchronization database triggered. set contains deleted , modified marked entities/database records inside transaction. if transaction commit successful changes in entities contained in set visible; if not rollback started. acts cache tracking changes inside target transaction. in article description of uow design pattern can found ( http://www.codeproject.com/articles/581487/unit-of-work-design-pattern ).

increment - Incrementing values larger than 2147483647 in PHP -

basically i'm working on card management system in particular module has job of creating bulk cards sequential. these cards 19 digits long , because these cards have monetary value need store entire card value. odd thing system has no trouble managing visa card number incrementing , 16 digits long. i'm assuming last 3 digits breaking function have no idea how on earth handle i've never had deal such large values before. $seqarray = array(); for($i = $_post['startcardnumber']; $i <= $_post['endcardnumber']; $i++) { $i = sprintf('%0.0f',$i); if(strlen($i) < $count) { $i = str_pad($i, $count, '0', str_pad_left); } array_push($seqarray, $i); } any appreciated. thanks fluffeh found out bc math functions needed. below new loop i'm using calculate , increment card numbers. $seqarray = array(); for($s = $_post['startcardnumber'], $e = $_post['endcardnumber'];bccomp($s,$e) != 1; $s = bcadd($s, 1)) {

java - Hibernate join without foreign key and map only a table -

i'm studying orm pattern , hibernate framework. i have 2 tables: table library , table book |library | book +------------------- +-------------- |libraryid :int (pk) |bookid:int (pk) |name:varchar |libraryid:int the column libraryid in book isn't foreign key for join tables, use code written below session.createquery("from book b, library l b.libraryid=l.libraryid , l.name=:name") .setstring("name", "test" ) .list(); from code list of object[] of book , library class. how can book class? session.createquery("select b book b ...) should gives vales of class book.

c# - Timer for a dictionary -

i have created dynamic timer. time has take time intervals dictionary. when run program says index not exist. , says when y=0; var timer = new system.windows.forms.timer(); int track = 0; int y = 0; timer.tick += (object sender, eventargs e) => { timer.interval = pqueuvalues[y]; if (track < nodenum) { txtoutput.text += "\r\r\n" + "the node name is: " + normalqueuname[track] + " priority: " + pqueuvalues[track]; ++track; } else { timer.stop(); } }; timer.start(); when use int key type, dictionary indexes key not numerical position of element. if don't have element key value of 0, fail. can use elementat method use position index: timer.interval = pqueuvalues.elementat(y).value;

How do I get change migration files of existing tabels in rails -

how can generate change file existing table? can command line or possible hand? i read text , me it's unclear how change file created? and if generate change file hand should name this? don't change migration files, you'll best creating new ones: $ rails generate migration change_table this create new migration, should this: #db/migrate/[timestamp]_change_table.rb class createtable < activerecord::migration def change add_column :table, :column_name, :type, after: :column end end you'll best reading on rails migrations documentation

c# - Open multiple website in a single window in different tabs -

i want open no. of urls , want open 1st url in new window , after others in same window in new tabs. using c# , window application use code provided firefox not opening new tab. opens new window. here code: private void btnsearch_click(object sender, eventargs e) { process.start("http://google.co.in","2048"); process.start("http://google.co.in","2048"); } thanks in advance. the problem starts when don't have you're browser open. else work perfect without thread.sleep. maybe can try this the "_blank" opens new blank page in same window "so new tab" using system.threading; private void button1_click(object sender, eventargs e) { process.start("http://www.google.com", "_blank"); thread.sleep(2000); process.start("http://www.google.com", "_blank"); }

rabbitmq - Is it possible to get a "push" when number of messages reaches threshold? -

i want check what best practice number of messages in queue. know can via queue.getmessagecount() know can monitor plugin gets it. http request? or rabbitmqctl application.(jni?) ? best way if want react when x messages arrive? and more important - can number of messages in queue via push? can declare threshold receive push notification? (e.g. signal every time have 5000 messages) you use queue x-max-length http://www.rabbitmq.com/maxlength.html queue length measure takes account ready messages, ignoring unacknowledged messages , message size. messages dropped or dead-lettered front of queue make room new messages once limit reached. so can configure dead letter exchanges , manage messages rejected limit exceeded. the reason name describing why message dead-lettered , 1 of following: rejected - message rejected requeue=false, expired - ttl of message expired; or maxlen - maximum allowed queue length exceeded. i hope helps edit** the ide

arrays - positioning blocks in breakout clone -

i trying make breakout clone without totally stuck. have created xml file , referenced etc. can see when debug pulls data through intending make first level have 4 blocks , dsplaying one. (curiously displays 3rd of 4 in xml list ?!?!) using system; using system.collections.generic; using system.linq; using microsoft.xna.framework; using microsoft.xna.framework.audio; using microsoft.xna.framework.content; using microsoft.xna.framework.gamerservices; using microsoft.xna.framework.graphics; using microsoft.xna.framework.input; using microsoft.xna.framework.media; using blocklocations; namespace smashblocks { public class level { block block; int totalblocks; public block[] blocks; coords2[] blocklocations; contentmanager content; public level(int totalblocks, contentmanager content) { content = content; totalblocks = totalblocks -1; blocks = new block[totalblocks];

c++ - can't find openCV head file -

recently i'm learning opencv. followed tutorial on opencv website. http://docs.opencv.org/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html#howtoscanimagesopencv however, when compile code using following command g++ loadimage.cpp -o loadimage the command line shows: fatal error: 'opencv2/core/core.hpp' file not found #include <opencv2/core/core.hpp> ^ i installed opencv brew, think ok. use emacs edit , g++ compile code directly, problem? searched similar problems refer xcode environment. help! you need tell g++ can find header files. recommend setup either eclipse or other ide can handle stuff (like qt creator or many others). can follow setup guides opencv instructions, if needed. [edit: note know emacs can setup handle things include , library paths, have no idea how, hence recommendation full scale ide] you can specify path includes on command line -i , should work. example: g++ -i/path/to/opencv-2.4.9/build/include l

java - Duplication of data when receiving a file through a socket -

sorry bad english, used google translate. working on application needs transfer file on network ability resume, program works, why when open text file transmitted through nano seen data duplicated. server outputstream outtoclient = socket.getoutputstream(); file myfile = new file(filepath); system.out.println("файл " + myfile.tostring()); byte[] mybytearray = new byte[(int) myfile.length()]; bufferedinputstream bis = new bufferedinputstream(new fileinputstream(myfile)); bufferedoutputstream bost = new bufferedoutputstream(new fileoutputstream(new file(filepath+"111"))); bost.write(mybytearray, 0, mybytearray.length); bis.skip(fileposition); bis.read(mybytearray, 0, mybytearray.length); bost.write(mybytearray, 0, mybytearray.length); outtoclient.write(mybytearray, 0, mybytearray.length); outtoclient.flush(); bis.close(); client byte[] mybytearray = new b

mysql - Stored Procedure - Need to use the result of a SELECT statement -

the following stored procedure return result column noofarticles correct total amount. delimiter // create definer=`root`@`localhost` procedure `sp_membersarea`(in reqdtable varchar(30), in scannerid int, in memberid int) begin declare noofarticles int(11); set @sql_text = concat("select count(*) noofarticles t_annualdetails scannerid = ", scannerid); prepare stmt @sql_text; execute stmt; deallocate prepare stmt; end // delimiter ; so-far-so-good. here problem. able use 'result' in query within same stored procedure, don't know how achieve it. work this: set @noofarticles = noofarticles; set @sql_text = concat("update ", reqdtable, " set scan = ", @noofarticles, " memberid = ", memberid); prepare stmt @sql_text; execute stmt; obviously, doesn't work, 'result' ( noofarticles ) placed in variable (i.e. @noofarticles ), , use variable ( @noofarticles ) inside update statement. i've been on day no

linux - Working with pipes in Unix C -

i having serious trouble working pipes in c. i'm supposed take in arguments command line (example: ./myprogram 123 45 67), read arguments 1 character @ time buffer, send character child process counted, , return total number of characters read parent process. code follows(note: comments i'm supposed doing): // characters command line arguments sent child process // parent process 1 @ time through pipe. // child process counts number of characters sent through pipe. // child process returns number of characters counted parent process. // parent process prints number of characters counted child process. #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <signal.h> static int tochild[2]; static int fromchild[2]; static char buffer; int main(int argc, char **argv) { int status; int nchars = 0; pid_t pid; pipe(tochild); pipe(fromchild); if ((pid = fork()) == -1) { pri

javascript - Setting global variable across fancebox iframe -

this question has answer here: pass value/variable fancybox iframe parent 2 answers i have webpage , calling fancybox plugin iframe show page. have used page upload image. now, want pass image path parent page after fancybox closes. i thought of setting global variable on parent page, , set value of variable inside fancybox iframe (to uploaded image path). on parent page placed afterclose() fancybox read variable's value. work? if not, else can try? parent file code: var globalimageurl = ""; $('.fancybox').fancybox({ maxwidth : 800, maxheight : 600, fittoview : false, width : '70%', height : '70%', autosize : false, closeclick : false, openeffect : 'none', closeeffect : 'none', afterclose: function(){

racket - list even values ​​of a tree in scheme -

write program returns list of numbers of tree i this: (define (list_pares arbol) (cond [(empty? arbol) 0] [(and (es-hoja? arbol) (even? (dato-tree arbol))) (list (dato-tree arbol))] [else (cond [(even? (dato-tree arbol)) (append (list (dato-tree arbol)) (list_pares (left-tree arbol)) (list_pares (right-tree arbol)))] [else (append (list_pares (left-tree arbol)) (list_pares (right-tree arbol)))])])) but when run: (list_pares (list 2 empty (list 5 (list 4 empty empty) (list 9 (list 6 empty empty) empty)))) returns me error: append: last argument must list, received 0 how it? your error message comes this: [(empty? arbol) 0] so when resursion append result end 0 instead of empty list problem because (append '(something) 0 '(something else)) not allowed. what should return if given empty tree , should return list of values it?

jquery-ui-multiselect-widget flickering while loading the data? -

jquery multiselect ui widget 1.14pre this issue me long list. see below image onload , after load effect(click on link). i tested list of 1600 items on mozilla machine , browser locked ~5 minutes. https://camo.githubusercontent.com/3dc1a939065e6364e699eef8f08b9cd653741cf0/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f333439313130312f3335313235362f61636133333962652d613034322d313165322d393462382d3239396561333065663532632e706e67 example: suppose need show 1000 names in drop down on web page using multiselect.js. when web page loading names coming in <select><option</option></select> tags. after completing loading becoming multiselect drop down. $(function(){ $("#"+ prefix + "schedule_id").multiselect({ header: 'travels', noneselectedtext: 'travels', selectedtext: 'travels', prefix: prefix + 'travels', }).select2; }); ** while loading data in drop

javascript - how to start drawing a line with a space between y-axis and it using d3js -

Image
i'm drawing simple line chart axes. // set scales var x = d3.scale.ordinal() .domain(data.map(function(d) { return d.labels;})) .rangeroundbands([0, width], 0); var y = d3.scale.linear() .domain([0, d3.max(data, function(d) { return d.values; })]) .range([height, 0]); var xaxis = d3.svg.axis().scale(x).orient("bottom"); var yaxis = d3.svg.axis().scale(y).orient("left"); // draw line graph var line = d3.svg.line() .x(function(d) { return x(d.labels); }) .y(function(d) { return y(d.values); }) .interpolate("linear"); // create svg 'canvas' var svg = d3.select("body").append("svg") .attr("class", "chart") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom).append("g") .attr("transform", "translate(" + margin.left + "," +

javascript - A HTML to PDF converter button using jspdf -

the pdf generator button in html webpage not working. can please explain going wrong? i using jquery version 1.7.2. <!doctype html> <html> <head> <title>print fax view</title> <meta content="text/html; charset=utf-8" http-equiv=content-type> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script type="text/javascript" src="js/jquery"></script> <script type="text/javascript" src="jspdf/jspdf.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.standard_fonts_metrics.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.split_text_to_size.js"></script> <script type="text/javascript" src="jspdf/jspdf.plugin.from_html.js"></script> <script type="text/javascript" src="jspdf/libs/de

How to save doctrine database schema in a Symfony controller? -

i'm using symfony 2.3 , doctrine 2 , need user save schema of doctrine database file (*.sql). need action method , send file user just started, should work in concept. didn't run it, assume might need little tweaks side. <?php use symfony\component\console\input\arrayinput; use symfony\component\console\output\nulloutput; use doctrine\bundle\doctrinebundle\command\proxy\createschemadoctrinecommand; // controller public function myaction() { $command = new createschemadoctrinecommand(); $command->setcontainer($this->container); $input = new arrayinput(array('--dump-sql' => true)); $output = new nulloutput(); $schema = $command->run($input, $output); //this schema // write file if want file_put_contents('path/to/schema.sql', $schema); } references: similar question php file_put_contents() symfony2 filesystem

ios - how to change simulator type? -

whenever i'm opening application using start_test_server_in_background, i'm seeing app in iphone simulator. want run in on iphone retina. can suggest me how change settings. thanks in advance. i assume running on xcode 5.1.1 for more details see: https://github.com/calabash/calabash-ios/wiki/a0-xcode-51-support $ device_target="ipad retina (64-bit) - simulator - ios 7.1" calabash-ios console` > start_test_server_in_background`

jquery plugins - I get this error "Cannot read property 'type' of undefined" when I use highchart -

Image
i using timeseries chart highchart plugin follow: var series1={ type: 'area', color:linecolors[numoflines], name: legends[numoflines], pointinterval: 24 * 3600 * 1000, pointstart:date.utc(datestart[0], datestart[1], datestart[2]) , data: democrat}; var series2={ type: 'area', color:linecolors[numoflines+1], name: legends[numoflines+1], pointinterval: 24 * 3600 * 1000, pointstart:date.utc(datestart[0], datestart[1], datestart[2]) , data: repub}; youdynamicseries.push(series1); youdynamicseries.push(series2);} and after creating series create chart this: highcharttimeseries

java - Setting LiveCard layout views and strings using the R class -

i'm trying register ids specific view attributes in r class, when update r class, android sdk rejecting values , resetting them automatically. mlivecardview.settextviewtext(r.id.hometeamnametextview, getstring(r.id.home_team)); mlivecardview.settextviewtext(r.id.awayteamnametextview, getstring(r.id.home_team)); mlivecardview.settextviewtext(r.id.footer_text, getstring(r.id.game_quarter)); what correct way create , set id's in r class? r class livecard suppose use? lastly, there way set start_sticky integer or value? @override public int onstartcommand(intent intent, int flags, int startid) { //timelinemanager tm = new timelinemanager(); if(mlivecard == null){ remoteviews views = new remoteviews(context.getpackagename(), r.layout.livecard_view); mlivecard.setviews(views); // // set initial remoteviews values homescore

java - How to develop a content assist like the one of Eclipse IDE? -

i want develop content assist own ide 1 eclipse offers java. problem is: how display information of completion proposal has html text(javadoc in case of eclipse)? i know how use string show information of method in content assist: new completionproposal("catch(a)", index + 1, offset - (index + 1), "catch(a)", img, keyword + " ", null, "catches exception a"); tks time, regards ramos

dart - On Page Loaded Event -

is there way run code when view has been loaded interact element when page loaded. have tried putting code in constructor of component view has not been loaded @ point in routing configuration can specify enter handler called when view loaded: 'some_view': ngroute( enter: (routeenterevent e) => print('entering view')) you can find more information on routing events in angular tutorial .

database - PHP SQLITE3 Create Table -

for reason table i'm trying create isn't being created when run following code: $database = new pdo('sqlite:maindb.db'); $database->query("create table friends(id integer primary key, int, int);"); has else faced similar issue? i've tried exec well, no luck.

<input type="button" /> does not call Spring controller in Internet Explorer 8 -

i call spring controller method on button click in jsp. works fine in firefox. not in internet explorer 8. following jsp code <a href="maintenance.html" > <input type="button" value="search" name="action"/> </a> following spring controller code @requestmapping(value={"/","/maintenance"}) public string navigatetomaintenance() { return "maintenance"; } there nothing wrong controller. microsoft standard doesn't allow button inside anchor. remove a tag , change code this <input type="button" value="search" name="action" onclick="location.href='maintenance.html'"/> or you can remove button , style anchor button

r - Extract every n-th + x subsequent elements from a vector -

i create vector in each element n-th element plus x following elements of vector. for example, if have vector a: a <- c(1,2,3,4,5,6,7,8,9,10) my new vector b should have elements b <- c(1,2,5,6,9,10) meaning first 2 elements, third 2 elements etc. any appreciated! logical indexing recycling this: a <- c(1,2,3,4,5,6,7,8,9,10) a[c(t,t,f,f)] ## [1] 1 2 5 6 9 10 from comment question: n <- 4 x <- 2 a[c(rep(t, n-x), rep(f,x))] ## [1] 1 2 5 6 9 10

.net - Powershell io.streamreader "-context" equivalent command -

i using below code in powershell collect relevant data large txt file. $sr = new-object system.io.streamreader(get-item c:\test.txt) while (($line = $sr.readline()) -ne $null) { if ($line -match "data") { $line } } $sr.dispose() this works useful if there equivalent powershell's select-string -context 1,0 able line above matched line. can assist? if need 1 previous line, following suffice: $sr = new-object system.io.streamreader(get-item c:\test.txt) while (($line = $sr.readline()) -ne $null) { if ($line -match "data") { $prev_line, $line } $prev_line = $line } $sr.dispose()

Google API PHP Client - retrieve calendar list and events -

the documentation google calendar api out of date, unable simple calendar list. here code far. <?php require_once "includes/partials/_header.php"; set_include_path(get_include_path() . '/google-api-php-client/src'); $client_id = 'xxxx.apps.googleusercontent.com'; $service_account = 'xxxx@developer.gserviceaccount.com'; $p12 = 'xxxx-privatekey.p12'; session_start(); require_once 'google/client.php'; require_once 'google/service/calendar.php'; $client = new google_client(); $client->setapplicationname("calendrier"); if (isset($_session['token'])) { $client->setaccesstoken($_session['token']); } $key = file_get_contents($p12); $client->setclientid($client_id); $cred = new google_auth_assertioncredentials( $service_account, array('https://www.googleapis.com/auth/calendar'), $key); $client->setassertioncredentials($cred); if($client->getauth()->isaccessto

Grails StaleObjectException with Dynamic Finder (Hibernate) -

i have batch job consistently throws stale object exceptions on dynamic finder. ideally not running orm solution job, have no choice. exception occurs in formulatagservice, being called formulabatchpopulatorservice. application being run on 2 servers using 1 database. 1 server performs batch processing. my questions are: a) why simple select statement, resulting in domain object instance no changes being made object during given transaction persisted in session, resulting in stale object exception? b) possible sorting being done on formula.tags being persisted @ end of transaction, causing staleobjectexception if else modifying formula on different server? note, did change service read-only, , still stale object exception. appreciated. formula tag service @cacheable("formulajob") def getformulabyteachertagsordefaultbatchjob(long evaluationtemplateid, list teachertags) { long formulabytagsid = existsformulawithsametagsbatchjob(evaluationtempl

sql - sp_MSforeachtable Abuse (Modification needed) -

recently hacked our database using sp_msforeachtable , multiline query if im right. now question how can modify sys.sp_msforeachtable , using @command1 , other commands execute query in order drop our tables. xxxx=censored db name (somehow spaces in front of use) use xxxx; exec sp_msforeachtable "alter table ? nocheck constraint all"; exec sp_msforeachtable @command1 = "drop table ?" then sql profiler shows: select @mscat = ltrim(str(convert(int, 0x0002))) exec(n'declare hcforeachtable cursor global select ''['' + replace(schema_name(syso.schema_id), n'']'', n'']]'') + '']'' + ''.'' + ''['' + replace(object_name(o.id), n'']'', n'']]'') + '']'' dbo.sysobjects o join sys.all_objects syso on o.id = syso.object_id ' + n' objectproperty(o.id, n''isusertable'') = 1 ' + n

html - Hide all other div's using jQuery -

when click button, show div id. want hide other div id's. can point me tutorial on how using jquery ? current code given below: $('#show_link_group').click(function() { $('#link_group').show(); }); after shows #link_group , want hide other div's. i suggest giving off div's class name , use hide them. <div class="alert" id="item-one"></div> <div class="alert" id="item-two"></div> <div class="alert" id="item-three"></div> then using jquery // hide divs class of alert show div id of item-one $('.alert').hide().filter('#item-one').show();

Installing cURL modules for Perl on Windows -

i have activeperl 5.14.2 on windows machine. have been trying install lwp curl module. have installed libcurl-dev library , gcc on machine. i understand lwp curl has dependency on www-curl-easy module. installed too. installed these through command lines using steps given in readme files. ran perl makefile.pl command followed make , make install . no errors given out during installation. i trying execute sample code test lwp curl installation: use lwp::curl; use strict; use warnings; $lwpcurl = lwp::curl->new(); $content = $lwpcurl->get('http://search.cpan.org','http://www.cpan.org'); i receiving below error: can't locate loadable object module www::curl in @inc (@inc contains: c:/perl64/site/lib c:/perl64/lib .) @ c:/perl64/site/lib/www/curl.pm line 11. begin failed--compilation aborted @ c:/perl64/site/lib/www/curl.pm line 11. compilation failed in require @ c:/perl64/site/lib/www/curl/easy.pm line 9. compila

How to add image and text in UITextView in IOS? -

Image
i want add both text , image in uitextview. textview should expanded according length of text , image. in short want when capture image camera or pick gallery should display in uitextview , should able add text image similar facebook.i attaching image how uitextview like. this absolutely possible now, using + (nsattributedstring *)attributedstringwithattachment:(nstextattachment *)attachment see apple docs here and example taken other answer : uitextview *textview = [[uitextview alloc] initwithframe:cgrectmake(0,0,140,140)]; nsmutableattributedstring *attributedstring = [[nsmutableattributedstring alloc] initwithstring:@"before after"]; nstextattachment *textattachment = [[nstextattachment alloc] init]; textattachment.image = [uiimage imagenamed:@"sample_image.jpg"]; cgfloat oldwidth = textattachment.image.size.width; //i'm subtracting 10px make image display nicely, accounting //for padding inside textview cgfloat scalefactor = oldwidt

objective c - setting BOOL variable inside block -

i'm trying set bool value defined in class inside block, can't see able set it. code. __weak __block sptween *tween2weak = tween; __block bool buttonscroll2 = buttonscroll; tween.oncomplete = ^{ [sparrow.juggler removeobject:tween2weak]; buttonscroll2 = no; }; i presume when buttonscroll2 = no , im doing setting separate variable , not original, how original inside block then? you correct, once value of buttonscroll gets copied buttonscroll2 , changes buttonscroll2 have no effect on original buttonscroll . if buttonscroll instance variable of object, should able access using __weak self pattern: __weak __block sptween *tween2weak = tween; __weak typeof(self) weakself = self; tween.oncomplete = ^{ [sparrow.juggler removeobject:tween2weak]; myclass *strongself = weakself; strongself->buttonscroll = no; };

Plain text values in encrypted cookie Slim framework -

documentation slim framework says uses encrypted cookies login. http://docs.slimframework.com/#cookie-session-store however, when built login system , inspected cookie values chrome extension this, found there plain text values in cookie. thought have done wrong, downloaded example app slimframework staff member https://github.com/briannesbitt/slim-contextsensitiveloginlogout ..and checked value. still looks this: a%3a2%3a%7bs%3a10%3a%22slim.flash%22%3ba%3a0%3a%7b%7ds%3a4%3a%22user%22%3bs%3a16%3a%22brian%40nesbot.com%22%3b%7d we can see "slim.flash", "user" session variable names, email.. how can normal if cookie "encrypted" ? you can check configuration in github link's index.php the default slim configuration has cookies.encrypt set false. in example, you've: $app = new \slim\slim(); configure to: $app = new \slim\slim(array( 'cookies.encrypt' => true, 'cookies.secret_key' => 'your_s

PDO execute() then fetchall() with bound paramaters. I can't get it to work -

i new pdo, , trying function executesqlquery($connection, $sqlquery, $paramsarray) { try { $sql = $connection->prepare($sqlquery); $sql->setfetchmode(pdo::fetch_assoc); $sql->execute($paramsarray); $result = $sql->fetchall(pdo::fetch_assoc); } ... etc $result empty array. can tell me doing wrong? $connection valid (i check (not shown), throw exception if not) paramsarray = array('modem_id' => '1'); $sqlquery = "select vehicle_id vehicles modem_id=":modem_id" [update] requested, here code in more detail. function executesqlquery($connection, $sqlquery, $paramsarray) { try { $sql = $connection->prepare($sqlquery); $sql->setfetchmode(pdo::fetch_assoc); $sql->execute($paramsarray); $result = $sql->fetchall(pdo::fetch_assoc); } ... etc nothing matters after point in function, things have gone wrong - $result nu

html - floating part of a ul -

i have basic question. i have page ul 7 lis, spanning 100% of page. want make last 3 lis float right, , want last 1 different color. trying not recode more necessary. here code, how shall apply css? make ul, (but stay in line other) or apply li directly? can make special class of li let last 3 positioned in different place? <html> <head> <style> ul { width:100%; padding:0; margin:0; list-style-type:none; } { width:6em; text-decoration:none; color:white; } </style> </head> <body> <ul> <li><a href="#">link one</a></li> <li><a href="#">link two</a></li> <li><a href="#">link three</a></li> <li><a href="#">link four</a></li> <li><a href="#">link five</a&

When and how do bash determine whether the input line is an assignment? -

if type in following 2 commands: i=1 var$i=2014 i error message var1=2014: command not found . i have found how make dynamic variable names possible declare in this post, still wondering why error message generated. implies bash consider var1=2014 command/executable name instead of assignment, , if line assignment test happened before $i expansion. qustion: what order bash follow parsing input line w.r.t. assignments? any recommended reading appreciated. first checks whether command looks assignment or ordinary command invocation. then performs variable substitutions, command substitution, etc. has after determining type of command line, because variable substitution different when goes assignment. instance, there's no word splitting when write: var=$variable but there word splitting when write: command $variable finally, after substitutions, word splitting, globbing, executes command. if determined assignment, assigns variable; otherwise, ex