Posts

Showing posts from July, 2014

r - Is it possible to report NAs in stargazer table? -

Image
stargazer package gives me nice descriptive table include in latex document. library(stargazer) stargazer(attitude) is possible add column reporting number of nas each of variables? this snippet give number of nas per row , column in data frame # make data count <- 10 data <- data.frame( a=runif(count), b=runif(count)) # add nas data[data$a>0.5,]$a <- na data[data$b>0.5,]$b <- na # nas per row data$nacount <- apply(data, 1, function(x) {length(x[is.na(x)])}) # nas per column nacountsbycolumn <- lapply(data, function(x) {length(x[is.na(x)])} )

java - Android: Is it possible to call a method directly from setOnClickListener()? -

i dynamically creating buttons , ideally able have method run if button pressed. is following possible? private void somemethod(int id){ //on button pressed id } private void othermethod(){ for( program element : somelist) { addbutton.setonclicklistener(somemethod(element.getid)); } } obviously thats mock of code illustrate question. know can instantiate new class seems should able call method although far keep getting errors attempts. i have had around web can't find answer this, thought ask here. setonclicklistener defines happen when button clicked. setting multiple times same button meaningless; last 1 set active one. to call method within listener, declare anonymous class override: addbutton.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { somemethod(...); } }); if you're trying set multiple buttons similar functionality, need loop through buttons (in list, say), , set

sas - Using an ARRAY Statement with an Iterative DO Statement -

i'm working on data set (data) has 3 variables (var1, var2, var3) in format need change. variables in special date format (for example purposes, oldfmt1) , need change them regular sas date format using datepart function. the issue need accomplish in single data step using both loop , array calls datepart function. dim function must used used right in array , must drop index varaible (i) before end datasetp. then, have apply date9. function these changed variables. i'm new loops , 1 causing me massive headaches. appreciated. by saying want use datepart function, implying 3 existing variables stored sas "date-time" values. try this: data have; var1 = datetime(); var2 = datetime(); var3 = datetime(); format var1-var3 datetime19.; run; data want; set have; array allvars(*) var1-var3; i=1 dim(allvars); allvars(i) = datepart(allvars(i)); end; format var1-var2 date9.; drop i; run; please remember sas has 2 data ty

php - Eager Loading from the model in Laravel 4 -

in laravel 3, 1 following in model ( http://laravel.com/docs/database/eloquent#eager ): class book extends eloquent { public $includes = array('author'); // line public function author() { return $this->belongs_to('author'); } } which useful if loading same models often. in laravel 4, adding "this line" doesn't seem cause eager loading though. doesn't seem mentioned in docs ( http://four.laravel.com/docs/eloquent#eager-loading ). has been replaced else or functionality gone? update: i've looked @ source model (so nice read). it's now: /** * relations eager load on every query. * * @var array */ protected $with = array(); is there way can suggest added (back) documentation (it seems 1 of little things can overlooked)? the docs on github ( https://github.com/laravel/docs ) can requests...

html5 / jQuery, Clock that does milliseconds animating every 100ms, <div> or <canvas>? -

i've coded small stopwatch / clock in jquery, run on android , ios using phonegap build, stopwatch shows time since stopwatch started in format of "00:00:00.0", includes milliseconds last block of numbers , gets updated every 100ms. have been looking on google canvas vs div performance articles nothing seems mention how perform updating text @ 100ms intervals. im wondering if best update text showing time in <div> or should in <canvas> ? @ moment using div , every , there tiny bit of lag looks browser cant keep up, advice / insight situation appreciated, guys! i'll transcribe comments here; you should know canvas re-draws each cycle, whereas dom elements moved/animated when requested. tho think, such simple animation, neither matter, dom movement () faster. the downside dom-element animation might browser performance visually tho. browsers tend make rotating , transforming dom-elements differently, said; ugly (sharp ed

sql server 2008 - Merge into and scope_identity issue -

i using sql server 2008 , merge into data table-valued parameter. create procedure [dbo].[sp1] ( @p ttvp readonly ) declare @thisid int begin merge [dbo].[firsttable] tp using @p ps on tp.id = ps.id when matched update set tp.name = ps.name, tp.mydate = getdate() when not matched insert (name, mydate) values (ps.name, getdate()); seclect @thisid = identity_scope() insert secondtable (id, mydate) select (@thisid, getdate()) end i think scope_identity never gets id insert statement. so first update , insert works, how inserted id second insert? this shows how record output data merge statement. note output clause runs across branches in merge, including both update , insert portions. uses mismatch between inserted.id , deleted.id work out inserted. output clause shows how can carry forward name column inserted virtual table. use tempdb; -- create test tables , ta

I have a segmentation error in C -

i have segmentation error, maybe lot more after run it, can't check else because of that. the program should work this: when user types in 5 numbers, should print out in ascending order if user enter number exit, remove original value if user enter native value, print list backwards this code far: #include <stdio.h> #include <stdlib.h> struct element { int i; struct element *next; }; void insert (struct element **head, struct element *new) { struct element *temp; temp = *head; while(temp->next != null) { if((*head==null)) { head = malloc(sizeof(struct element)); //temp->i = i; temp->next = new; new = temp; } else if(temp->i == new->i) { new = malloc(sizeof(struct element)); free(new); //purge(&head,&new); } else if(temp->i < new->i) { temp->i = new->i; } else if(temp->i > new->i) { new = new->next;

html - Safari browser not processing JQuery Right but works in IE|Chrome|FireFox Just fine -

i working on page brother. using jquery , html build it. the problem running page loads fine in ie chrome , firefox when load in safari blows up. cant go reels link without coming apart. when click on reals should expand 4 videos. when click on button should close , move on. leaves them open. in safari mind you. here link http://anthonyrussell.info/test/jbp/index.html and here source <!--this site rt applications inc. production (http://www.anthonyrussell.info) --> <!--none of content on site in public domain. taken site must first approaved sites owner--> <!--http://www.jaysonbernard.com owned jaysonbernard , maintained rt applications inc.--> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><!-- running live--> <!-- <script src="jquery-1.9.1.min.js"></script> <!--for running local--> <script> $(doc

php - Delete row from Table with ajax -

i found code on internet , need ajax code post $row[id] delete.php file: echo "<td><a id=$row[id] onclick=\"if(confirm('are sure want delete this?')) deleterow(this.parentnode.parentnode.rowindex); return false; \" href=\"\" >del</a> </td>" i have tried: function deleterow(i){ var makarios = document.getelementbyid('m').deleterow(i) var mak; if (window.xmlhttprequest) { // mozilla, safari, ... mak = new xmlhttprequest(); } else if (window.activexobject) { // ie 8 , older mak = new activexobject("microsoft.xmlhttp"); } var data = "id=" + makarios; mak.open("post", "delete_basket.php", true); mak.setrequestheader("content-type", "application/x-www-form-urlencoded"); mak.send(data); } in case want jquery example looks lot easier jazz in comment: function deleterow(id

sql server - Sa password automatically keeps changing automatically -

i using sql server 2008 r2. since 2-3 weeks ago, sa password has been continuously changing automatically. know why case? make sure have not set sa account change password after set amount of time. in pci compliance mode may have roll security passwords. however, should account sa accounts.

bioinformatics - Splicing through a line of a textfile using python -

i trying create genetic signatures. have textfile full of dna sequences. want read in each line text file. add 4mers 4 bases dictionary. example: sample sequence atgatatatctatcat what want add atga, tgat, gata, etc.. dictionary id's increment 1 while adding 4mers. so dictionary hold... genetic signatures, id atga,1 tgat, 2 gata,3 here have far... import sys def main (): readingfile = open("signatures.txt", "r") my_dna="" dnaseq = {} #creates dictionary char in readingfile: my_dna = my_dna+char char in my_dna: index = 0 dnaid=1 seq = my_dna[index:index+4] if (dnaseq.has_key(seq)): #checks if key in dictionary index= index +1 else : dnaseq[seq] = dnaid index = index+1 dnaid= dnaid+1 readingfile.close() if __name__ == '__main__': main() here output: actc actc actc actc

zoom - Jquery size text -

i've created script supposed increase or decrease size of text (shown below) problem text remaining same size when click on 1 of images , pass parameter menos <script> function increase_text(size,mode) { var size_ini=16; var size_max=20; var size_min=16; if (mode=="mas") { var size_increase = size_ini++; alert("ok"+size_increase); if (size_increase<20) { $(".content").css("font-size",""+size_increase+"px"); } else { $(".content").css("font-size",""+size_max+"px"); } } if (mode=="menos") { var size_increase = size_ini--; if (size_increase>=20 || size_increase>=size_min) { $(".content").css("font-size",""+size_increase+"px"); } else

How to reduce javascript / jquery / ajax load time for my website? -

how reduce javascript / jquery / ajax load time website ? website : http://maavankal.com/ a general rule minify javascript. jquery distributes minified version. article help: is there javascript minifier? if can use json it's more succinct xml (and has native jquery support). in general try reduce bandwidth requirements of components.

in javascript dom, how do you get the target of the current window? -

assuming link <a href='www.domain.com/mypage' target='target1' >open in new tab</a> opens mypage how, mypage , know if current window 'target1' have looked under window , window.location , nothing there seems fit the window.name property you're looking for.

terminal - Badly placed ()'s when creating Xquery command -

so have created same books.xml file w3schools. i'm trying use xquery. i started command: doc("books.xml") but shows following error: badly placed ()'s. i have use query: doc("books.xml")/bookstore/book/title same error any suggestions? i found error, saxon file i've upload gl not uploaded properly. mean 3.9 mb on gl 0 size !! works fine now

Build Android app based on Android Source instead of official sdk -

i modify existing source of android sdk, instance, in linearlayout , put print message or adding paddings constant so there way can create new android app, , have depends on sdk source instead of choosing sdk in projection creation. thanks you can extend linearlayout, or extend viewgroup class (which standard layouts extend). in layout xml can declare custom view: <com.example.mylayout adnroid:layout_width="..." ... > </com.example.mylayout> my problem inflater ignored children under custom layout. maybe did wrong, , luckier :) in worst scenario may have separate layout xml children , add programmatically after inflating. embedding own layout android system not practice mere reason in case have supply modified android system users of app :)

java - setReadable(true) doesn't work after setReadable(false) -

i testing method have written throwing file exception. triggering exception setting read permissions on file false file f = new file(unreadablefile); f.setreadable(false); // run test f.setreadable(true); the problem f.setreadable(true) not setting permissions should be. have test tests normal mode of operations, , fails because f.setreadable(true) didn't restore file before exception test run. have checked permissions on disk, , wrong. quoting docs returns true if , if operation succeeded . operation fail if user not have permission change access permissions of abstract pathname. if readable false , underlying file system not implement read permission, operation fail. check return value , check if have permissions operation. operation delete() , can fail if not have permissions.

proc - Jiffy duration in Android -

i figure out way jiffy duration (used /proc) on android device, similar sysconf(_sc_clk_tck). my device (as of others) uses 1 centisecond (1/100s), though /proc/timer_list reports "resolution 1 nsecs". there reliable (and preferably straightforward) way go? thanks.

android - spinner dropdown show up on click of menu button -

i want spinner dropdown show on click of menu button in android.like press menu button , on click of menu button spinner dropdown shows up.can please suggest way ahead. call on menuitem click spinner.performclick();

c# - Building tree hierarchy using Linq -

i working on creating tree hierarchy using linq , since new facing trouble. have 2 tables have create hierarchy , table follows table a id name description table b id of (as foreign key) name and need structure this: name(from table a) |_name(from table b) |_name (from table b) name(from table a) i have class defined as public class c { public class c(c item,ienumerable<c> id,ienumerable<c> data) { aid=item.ai; bid=item.bid; aname=item.name; childeren=id; } public ienumerable<c> children{get;set} } all name of tables must displayed not have nodes i used group join data both tables , having problem code select node , sub node. linq code follows: private list<model> buildhierarchy(ienumerable<model> hirs) { var families=hirs.tolookup(x => x.aid); var topmost = families.first().select(s => s)

java - The RepositoryFactory has already been initialized Exception in tiles and Velocity Integration -

i trying integrate tiles+ velocity in spring mvc. i found link in github serving same purpose. using classes in project in eclispe. when run project getting following exception: http status 500 - servlet.init() servlet appservlet threw exception type exception report message servlet.init() servlet appservlet threw exception description server encountered internal error prevented fulfilling request. exception javax.servlet.servletexception: servlet.init() servlet appservlet threw exception org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:936) org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1004) org.apache.coyote.abstractprotocol$abstractconnectionhandler.p

c# - unable to send data in windows phone 7 to php server through httpwebrequest -

application collects location coordinates , sends php server. coordinates getting displayed on emulator not getting saved on server. here code: private void post(string lat, string lng) { string latlng=lat; httpwebrequest request = (httpwebrequest)webrequest.create("http://60.243.245.179/windowsapp/windows.php"); request.contenttype = "application/x-www-form-urlencoded"; // set method property 'post' post data uri. request.method = "post"; // start asynchronous operation request.begingetrequeststream(new asynccallback(getrequeststreamcallback), request); // keep main thread continuing while asynchronous // operation completes. real world application // useful such updating user interface. alldone.waitone(); } private static void getrequeststreamcallback(iasyncresult asynchronous

entity framework - System.AccessViolationException due a System.Data.Objects.ObjectQuery -

from time time i'm getting exception of type system.accessviolationexception in w3wp.exe crash app. the stack of exception (got event viewer): log name: application source: .net runtime date: 05-04-2013 00:00:27 event id: 1026 task category: none level: error keywords: classic user: n/a computer: myserver description: application: w3wp.exe framework version: v4.0.30319 description: process terminated due unhandled exception. exception info: system.accessviolationexception stack: @ system.collections.generic.list`1[[system.__canon, mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089]]..ctor() @ system.data.common.internal.materialization.coordinatorscratchpad..ctor(system.type) @ system.data.common.internal.materialization.translator.processcollectioncolumnmap(system.data.query.internaltrees.collectioncolumnmap, system.data.common.internal.materialization.translatorarg, system.data.query.in

.net - Changing the Shared Secret in AES Encryption -

i have used advanced encryption standard (aes) encrypt data before storing them database. understanding, if change "shared secret" part of algorithm, have update of stored data accordingly. there other way me give admin user opportunity update key without needing update huge volume of stored data while doing so? following code i'm using encryption: public static string encryptstringaes(string plaintext, string sharedsecret) { if (string.isnullorempty(plaintext)) throw new argumentnullexception("plaintext"); if (string.isnullorempty(sharedsecret)) throw new argumentnullexception("sharedsecret"); string outstr = null; // encrypted string return rijndaelmanaged aesalg = null; // rijndaelmanaged object used encrypt data. try { // generate key shared secret , salt rfc2898derivebytes key = new rfc2898derivebytes(

asp.net - Display GridView while others still load -

i new asp.net/c#. came across asp:updatepanel control in asp.net. have multiple gridviews in page. trying achieve display gridviews , when loaded. say instance, first gridview data loaded data source , databound grid. how can use updatepanel show results user while other gridviews still being loaded? note: achieve this, using flag , timer. timer set trigger in updatepanel on every tick of timer, check if data loaded using flag. if so, call databind() method displays data on page while others still being processed. i know above not efficient way this. please help. if set update mode of updatepanel conditional , after databind() should call .update() such gridview1.databind(); updatepanel1.update();

python - How to prevent docopt from swallowing an option? -

i'm trying create command-line interface using docopt. here simplified version of file: #!/usr/bin/env python """ test program. usage: test.py [options] options: -a <input> -b -c -d """ import docopt print docopt.docopt(__doc__) i want able specify of options, in order. however, if forget specify argument -a flag, output this: $ python test.py -a -b -c {"-a": "-b", "-b": false, "-c": true, "-d": false} docopt treating -b flag argument -a flag, instead of rejecting input invalid. there easy way detect this, or make docopt refuse accept sort of malformed input? there ambiguities concerning short option : better use --option=arg long option : -o --option words starting 1 or 2 dashes (with exception of "-", "--" themselves) interpreted short (one-letter) or long options, respectively. - short options can "stacked&quo

c# - How To Select The First line or (first 20 Characters) of a pragraph using Microsoft Office Interop word.? -

i have been trying following code first line or first 20 characters of paragraph using microsoft office interop word 12 microsoft.office.interop.word.application w = new microsoft.office.interop.word.application(); microsoft.office.interop.word.document doc; int iparastart = para.range.start; para.range.text = "a big paragraph comes here ……."; para = doc.paragraphs.add(); int iparaend = para.range.end; // select first sentance code tried doc.range(irangestart,irangeend).sentences.first.select(); doc.range(irangestart,irangeend).sentences.first.shading.backgroundpatterncolor=wdcolor.wdcolororange; // characters code tried doc.range(irangestart,irangestart+20).select(); it seems not working how can . need select either first sentence or first 20 characters try using (i assumed have open application , word document): // paragraph range paragraphs = doc.paragraphs; word.paragraph paragraph = paragraphs.first; word.range para

jquery - swipe right on touch to toggle class? -

is possible, jquery mobile or jquery have swipe event changes class something? $(document).ready(function() { $("body").swiperight(function(event){ $('.main-content').toggleclass('.swiped'); }); }); would use jquery or jquery mobile sort of thing? $('.main-content').toggleclass('.swiped'); // ^ not dot please! should be: $('.main-content').toggleclass('swiped'); btw, think without plugin jquery mobile gives api: $("body").on('swiperight', function(){});

jQuery preload URL -

i'm looking solution preload content of page if clicks on link because i'm generating page content dynamicly. for example: <a href="pagexy.php">click me</a> $('a').click(function{ $('#preloader').show(); $preloadurl($(this).attr('href')){ done: // open url / show content } }); is there plugin wich makes possible? nice if work form submit, too. for gallery site, use queryloader2 plugin gaya design. it looks nice , easy-to use. hope search that. here's demo: http://gayadesign.com/scripts/queryloader2/

Matlab - how to remove a line break when printing to screen? -

there example big big score for 2 hours and there need see how many more before end of do output on screen of outer loop but values ​​and there many, such 70 000 question - how remove line break when printing screen not receive 70 000 lines and see current display in 1 line? try function, can use in place of disp string argument. displays command window, , remembers message has displayed. when call next time, first deletes previous output command window (using ascii backspace characters), prints new message. in way see last message, , command window doesn't fill old messages. function teleprompt(s) %teleprompt prints command window, over-writing last message % % teleprompt(s) % teleprompt() % terminate % % input s string. persistent lastmsg if isempty(lastmsg) lastmsg = ''; end if nargin == 0 lastmsg = []; fprintf('\n'); return end fprintf(repmat('\b', 1, numel(sprintf(lastmsg)))); fp

c# - How to mirror a Matrix3D? -

Image
i want mirror drawing. i need mirror matrix3d think... don't have clue this. i tried this: var transformation = scenecamera.transformationmatrix; var invertedtransformation = transformation; invertedtransformation.invert(); var trans = transform3d.identity.value * transformation * invertedtransformation; but doesn't work. as see in image drawing in report has mirrored. thanks in advance! to "mirror" model can either mirror camera transformation, or mirror objects transformation. mirroring in camera give effect of mirroring picture. mirroring model mirror object in world, regardless of @ from. to mirror camera in x-direction, multiply camera transform matrix has -1 x component , 1 other scalings. may have offset camera since mirroring may have moved object out of view, depending on how camera transform set begin with. var cameratrans = scenecamera.transformationmatrix; cameratrans.scale(new vector3d(-1, 1, 1));

css - Highslide In Page Z-Index -

i have problem z index position of inpage galery on page. i have tried hs.zindexcounter attribut, not work out. navi has z-index 10000. here live example: live example thank help, michael hs.zindexcounter isn’t overrideable inline, mean can’t put in var . (see “details” in reference page: http://highslide.com/ref/hs.zindexcounter ) need set global variable (outside var ): hs.zindexcounter = 1;

angularjs - Angular JS: Handling different UI components from each views repeated using ng-repeat when the view look-feel are same -

Image
apologies big title, couldn't come thing better. let me explain issue having. i have render 3 cards each of them share same look-feel, means each of them have header section , body section. using ng-repeat data model , render these cards. code: <div class="card"> <a href="#/cards/{{card.id}}"><h1>{{card.title}}</h1></a> <div ng-repeat="widget in card.widgets" class="widget"> <h2>{{widget.title}}</h2> {{widget.type}} </div> </div> now, each of these card's body should have different ui in it. example, 1 card's body might have chart using hight charts, 1 might want use ui jquery ui library, etc.. how achieve when looping using ng-repeat? let me know if starting direction correct? the model data this: [ { "id": "c001", "title": "card 1", "widgets": [ { "title": &

c# - How to apply a filter expression to a gridview? -

i have grid view , filter expression database. want apply filter expression grid data grid sort. column criteria match column of grid. isn't problem. i can set grid.filterexpression = filter , how can sort values grid filter criteria? code: html markup populate dropdowns <asp:sqldatasource id="sqldatasourcecity" runat="server" connectionstring="<%$ connectionstrings:northwindconnectionstring %>" selectcommand="select distinct city customers"> </asp:sqldatasource> <asp:dropdownlist id="ddlcountry" runat="server" appenddatabounditems="true" autopostback="true" datasourceid="sqldatasourcecountry" datatextfield="country" datavaluefield="country" width="100px"> <asp:listitem value="%">all</asp:lis

spring - CGLIB proxy not getting created for Transactional Proxies -

here doing: @component("jdbcbookdao") public class jdbcbookdao extends jdbcdaosupport implements bookdao{ @autowired public void injectdatasource(datasource datasource){ setdatasource(datasource); } @transactional public int getstock(int isbn){ string sql = "select bs.stock book b, book_stock bs b.id=bs.book_id , b.isbn=?"; return getjdbctemplate().queryforint(sql, isbn); } } and in application context, have declared: <tx:annotation-driven proxy-target-class="true"/> with config, expected when fetch jdbcbookdao context, cglib proxy(as have set proxy-target-class true). when debug, comes instance of jdkdynamicaopproxy. can 1 please explain why jdk proxy getting created when requested cglib proxy? thanks. spring source code object according if use interface jdk proxy, if use normal class cglib. e public aopproxy createaopproxy(advisedsupport config) throws aopconfigexception { if (config.isoptimize() || con

itunesconnect - Autoingestion.class has stopped creating report files -

a few month ago wrote scripts fetch itunes connect sales reports automatically. today noticed scripts has stopped working correctly, searched problem. obviously autoingestion tool apple (autoingestion.class) has stopped create expected output files... usage example: java autoingestion user *pw* vendor sales daily summary 20130401 syntax still correct regarding http://www.apple.com/itunesnews/docs/appstorereportinginstructions.pdf the tool runs fine without errors. expected output file missing :(. to except problems java - tested tool on different platforms different jvm versions. is else experiencing problem? i had same issue, per own comment, tried on box date jre, believe, , worked. (i'd tried on dev box, running on live box worked. makes sense.) just adding, output want see: $ java autoingestion autoingestion.properties <vendor> sales daily summary 20130801 s_d_<vendor>_20130801.txt.gz file downloaded i'm inclined think there shou