Posts

Showing posts from January, 2015

r - Dynamic counting of occurrences -

r newb. small rep of data. teamhome <- c("lal", "hou", "sas", "lal") teamaway <- c("ind", "sas", "lal", "hou") df <- data.frame(cbind(teamhome, teamaway)) df teamhome teamaway lal ind hou sas sas lal lal hou imagine these first 4 games of season thousands of games. home team , visitor team want compute cumulative number of games played @ home, on road , total. 3 new columns both home team , visiting team. (in case calculating new variables home team): teamhome teamaway hometeamgamesplayedathome hometeamgamesplayedroad hometeamtotalgames 1 lal ind 1 0 1 2 hou sas 1 0 1 3 sas lal 1 1 2 4 lal hou ...

vbscript - VB Script to change the from field of emails in Outbox -

i have emails in outbox in outlook , i'd run vb script change field of these emails other email i managed following doesn't work i'd , therefore missing main piece. i'd appreciate if help. intfolderoutbox = 4 msofiledialogopen = 1 ' load requied objects set wshshell = wscript.createobject("wscript.shell") ' windows shell set objolapp = createobject("outlook.application") ' outlook set ns = objolapp.getnamespace("mapi") ' outlook set box = ns.getdefaultfolder(intfolderoutbox) ' outlook each item in box.items *** here need replace field **** item.sender = "email2@gmail.com" item.update item.save next something following works adding recipient couldn't find equivalent field. item.recipients.add "email2@gmail.com" here doesn't work in case set oaddrentry = createobject("mapi.addressentry") oaddrentry.name...

html - Grid Issue By Using <div> and <a> -

i have 1 silly question bootstrap grid system. is okay use <a href="#" class="col-lg-4"> instead of <div class="col-lg-4"> ? is because want create column-4 grid menu hyperlink. basically, should hyperlink cover text not whole column if had styled width: 100%; height: 100%; inside <a> tag. <div class="row"> <div class="col-lg-4"> <a href="#">menu 1</a> </div> </div> after change code, should like <div class="row"> <a href="#" class="col-lg-4"> menu 1 </a> </div> is best practice of using bootstrap? or have follow standard define bootstrap? do , looking great: add class or style element. or add class "btn btn-default btn-block" use bootstrap button styles <div class="row"> <div class="col-lg-4 text-center"> <a...

javascript - How would I get an ID from a response like this? -

here response in question: object { 0: <li#gen_kw_select_77080.actions-list__option.j-selected.j-focused>, context: <li#gen_kw_select_77080.actions-list__option.j-selected.j-focused>, length: 1 } and here code generates it: function doaction (items) { items.each(function(index, el) { var $el = $(el); console.log($el); $el.addclass('animate'); settimeout(function() { $el.removeclass('animate'); }, 300); }); } i highly appreciate responses here. should mention i'm using selectonic plugin.

javascript - angular morphing current view -

say have 2 custom elements <card1> , <card2> independent of each other meaning can create arbitrary amount of each , each of them have different models. what want when action happens in <card1> creates <card2> within <card1> (preferably animation) or morphs <card1> <card2> . dont want have predefine <card2> within <card1> , hide until interaction happens. because want scalable if decide create card3 or card4 , have them appear based on interaction what best way structure view, controller, template, ...?

memory leaks - In what android activity state should one be opening and closing database connections? -

i have commercial application finished. has 8 list activities , 4 detail activities , bunch of other stuff going on. when started out (and new android development), in each method needed database connection, created new sqliteopenhelper subclass instance , database connection , closed connection @ end of method. seemed bad things. complicating need install data upon first launch. have rest app access , have cached data it. seem run out of memory when try load 1 of tables when use jsonreader class in gson , not regular inputstreamreader functionality. so, supposed read in objects 1 @ time. still runs out of memory on emulators <= 1 gb memory. so, started using singleton, synchronized getter, sqliteopenhelper subclass instance. doing this, should still able db connection objects , close them within methods? did not seem work. now using simplecursoradapter subclass list activities. seems move problem bit not fix or make worse. see diagram of activities , when run: http:...

sql server - Upgrading SQL Management from Express 2012 to Enterprise 2016 -

Image
i migrating webappserver sql2012express sql2016enterprise. have installed windows server 2016 iis10 current iis db connection string "data source=.\sqlexpress;integrated security=sspi;attachdbfilename=|datadirectory|aspnetdb.mdf;user instance=true" this on windows 2008 , iis 7 sql 2012 express. now on new webappserver source no longer sqlexpress since sql enterprise not express. instance name sql2012 changed sql2016 in software's web.config , iis not able connect software database. here current db string on current webappserver. my sql management studio on new server iss db connection string same express? and sql studio properties my connection string in mvc app web.config file i hope giving enough information me on challenge facing. this first time migrating sql server , sure have create instance correctly. connection string site on iis data source=.\sql2016;integrated security=true;app=worldwide;initial catalog=worldwide a...

Does webdriver.io waitForVisible method timeout if a new page is loaded? -

using latest version of webdriver.io (3.1) i'm running weird issue waitforvisible method timing out instantly instead of after 5000ms timeout i've set. doesn't happen , if add 500ms pause before method seems resolve issue. have feeling waitforvisible method being called before new page begins load after click , i'm betting if page changed causes method fail , reason failure being reported timeout? if happening there way around other adding pause? don't pauses because seem make tests fragile. test('clicking logout link logs user out , routes login view', function(){ return client.click('#header [data-action="app:logout"]') .pause(1000) //this pause fixes issue //this method instantly times out .waitforvisible('#login', 10000).then(function(result){ expect(result, 'did not log out'); }); });

javascript - How to get html element id using jquery -

i need id before , after html element of dropdown list on change. please see blow source code. when fund name selected need previous selected checkbox id or name ( cash / epf ) & after selected checkbox id or name ( no.of units reedem / amount reedem / units) . in advance. $(document).ready(function () { $('.units').change(function () { alert($(this).attr('id')); alert($(this).before().parent().parent().html()); }); }); <html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-mfvzlkhceqatnogioxvee8fiwmzzg4w85qfrfifbfyc= sha512-dtfge/zgomypp7qbhy4gwmegsbsdzecxz7iritjcc3spuftf0kufbdz/ixg7artxmdjlxdmezhubenikykgvyq==" crossorigin="anonymous"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"...

php - the data validation is always return true in cakephp -

the data validation in user model return true. can tell me why? model: user.php class user extends appmodel { var $name = "user"; public $validate = array( "username" => array( "rule" => "notblank", "message" => "please enter title !", ), "password" => array( "rule" => "notblank", // tập luật là không rỗng "message" => "please enter info !", // thông báo khi có lỗi )); } userscontroller: if(($this->request->is('post'))) { $this->loadmodel('user'); $this->user->set($this->data); echo "</br> vao ".$this->user->validates(); if($this->user->validates()){ echo "</br>".$this->user->validates(); $this->session->setflash("data avaliable !"); }...

hashmap - Java visibility: final static non-threadsafe collection changes after construction -

i found following code snippet in luaj , started doubt if there possibility changes made map after has been constructed might not visible other threads since there no synchronization in place. i know since map declared final, initialized values after construction visible other threads, changes happen after that. some might realize class not thread-safe calling coerce in multi-threaded environment might cause infinite loop in hashmap , question not that. public class coercejavatolua { static final map coercions = new hashmap(); // map visible threads after construction, since final public static luavalue coerce(object paramobject) { ...; if (localcoercion == null) { localcoercion = ...; coercions.put(localclass, localcoercion); // visible? } return ...; } ... } you're correct changes map may not visible other threads. every method accesses coercions (both reading , writing) should sync...

javascript - onlick event not working within a window.open -

i'm trying achieve onclick event once window.open has opened. when user clicks button in new window works. the onclick event works if it's not within newly opened window. <div class="show-dialog" id="content"> <script type="text/javascript"> var c = document.getelementbyid("content"); function resizetext(multiplier) { if (c.style.fontsize == "") {c.style.fontsize = "1.0em"; } c.style.fontsize = parsefloat(c.style.fontsize) + (multiplier * 0.2) + "em"; } </script> <a href="javascript:void(0);" onclick="resizetext(1)" id="plustext">make text bigger</a> <a href="javascript:void(0);" onclick="resizetext(-1)" id="minustext">make text smaller</a> </div> the javascript function enables clicking links , increasing or decreasing text. op...

Divide a main table into multiple tables using SQL server -

hi trying create multiple tables out of main table in sql server. e.g the main table looks like a 1 2 3 b 4 b 5 b 6 the output should : table a: a 1 2 3 table b: b 4 b 5 b 6 the main table updated every week can have different alphabets. want create dynamic query automatically divide main table 'n' different tables depending on how many different n's there , name table based on nth value. yes achievable, curse , blessing dynamic sql erland sommarskog create table @tbl the desire here create table of name determined @ run-time. if @ arguments against using dynamic sql in stored procedures, few of them applicable here. if stored procedure has static create table in it, user runs procedure must have permissions create tables, dynamic sql not change anything. plan caching has nothing it. etc. nevertheless: why? why want this? if creating tables on fly in application, have missed fundamentals database design. in relational da...

Java - JSCH Library - Run command which expects password -

i writing java program runs rsync on local linux host copy data remote host. using jsch library. looked @ jsch examples, didn't find relevant. i can't setup key authentication, expecting automated password entry of remote host when rsync command run prompts password. i searched online ways of doing it, don't find easy way of doing it. following function executes command fed it, function part of class has server, username, password public int executecommand(string command) throws exception { jsch jsch = new jsch(); session session = null; channel channel = null; int exitcode; try { //initialize session session = jsch.getsession(this.username, this.server, 22); session.setpassword(this.password); session.setconfig("stricthostkeychecking", "no"); session.setconfig("preferredauthentications", "publickey,password"); //connect session.connect(); ...

Loading jQuery with AJAX -

like of know, jquery gets loaded/"activated" on page load if bring content via ajax code requires few modifications or restart in cases. i make fitvids inside magnific popup work in ajax loaded content. attemps has been failed while repaired bootstrap tooltips , few other minor things. fitvids inside main.js (function( $ ) { "use strict"; $.fn.fitvids = function( options ) { var settings = { customselector: null, ignore: null, }; if(!document.getelementbyid('fit-vids-style')) { // appendstyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js var head = document.head || document.getelementsbytagname('head')[0]; var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}'; var div = d...

actionscript 3 - How To Link To A Frame Adobe Flash CS6 Action Script 3 -

i need adobe flash assignment , m still new adobe flash :( how tell user if input wrong keyword how link them frame . var i:int = 0; var names:array = new array("html","head","body"); var frames:array = new array("6","7","8"); searchhtmlll.text =""; searchhtml.addeventlistener(mouseevent.click, fl_mouseclickhandler_2); function fl_mouseclickhandler_2(event:mouseevent):void { findinarray(searchhtmlll.text); gotoandstop(frames[i]); } function findinarray(str:string):int { for(i = 0; < names.length; i++) { if(names[i] == str) { return i; } } return 0; } i answering based on whatever limited information have provided in question, , understand. your method findinarray has return type of int , calling without assigning variable. so code should be: var result:int = findinarray(searchhtmlll.text); gotoandstop(frames[result]); hope helps.

python - Passing a Facebook Oauth2 object while using Tornado -

i trying implement oauth manually on website being implemented using tornado. url (localhost/form) contains button when clicked brings facebook login , if login successful redirects same site token (localhost/form?code=xxx) collect token/code , begins taking requests facebook. my issue upon redirecting localhost/form given code, appears reinitialize brand new oauth2session object not match token , receive request error. how should correctly pass oauth2session object or correctly reinitialize it? reinitialization causing error or else? current code not work is: class formhandler (basehandler): def get(self): client_id =xxx client_secret =xxx authorization_base_url = 'https://www.facebook.com/dialog/oauth' token_url = 'https://graph.facebook.com/oauth/access_token' facebook = oauth2session(client_id, redirect_uri='http://localhost/form') facebook = facebook_compliance_fix(facebook) authorization_url...

c# - Avoiding Deadlock with HttpClient -

what best way use httpclient , avoid deadlock? using code below, called entirely synchronous methods, concerned maybe causing deadlock. i've done reading on functions .configureawait(false) , .getawaiter() , .getresult() looking input on best practice approach. not quite exact code, close enough. public static bool tryrequest(string url, out response) { httpcontent content = new stringcontent(json, encoding.utf8, "application/json"); using (httpclient client = new httpclient()) { httpresponsemessage responsemessage = null; switch (verb) { case httpverb.put: responsemessage = client.putasync(url, content).result; break; case httpverb.post: responsemessage = client.postasync(url, content).result; break; case httpverb.delete: responsemessage = client.deleteasync(url).result; break; case httpverb.get: ...

android - ViewPagerIndicator not changing colours -

i have integrated circlepageindicator viewpager.i trying change fill colour , page colour shows default colour only.below code trying. layout <android.support.v4.view.viewpager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" /> <com.viewpagerindicator.circlepageindicator android:id="@+id/circles" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_below="@+id/header" android:layout_above="@+id/popup_achievement" /> class mviewpager.setadapter(madapter); circlepageindicator.setviewpager(mviewpager); circlepageindicator.setbackgroundcolor(0xffcccccc); circlepageindicator.setradius(15); circlepageindicator.setpagecolor(r.color.gray); circlepageindicator.setfillcolor(r.color.das_color); circlepageindicator.setstrokecolor(r.color.dffe_color); circlepageindicator....

haskell - Joining Nested Monads -

i using frp.sodium , have object of type io (behavior (io (behavior))) . need convert object type io (behavior) , using akin nested join . possible using sodium functions? there more general solution a (b (a (b c))) -> (b c)) ? there isn't obvious way so. cobble right type using functions sample , sync or updates , executesyncio/executeasyncio , wouldn't obey monad laws. there isn't more general solution a (b (a (b c))) -> (b c)) , there if b traversable , lets rearrange things a (a (b (b c))) traversing outer b .

c++ - Debugging PIN tool add-symbol-file doesn't work -

to debug simulator uses pin tool, using 2 different terminal windows, following: /home/agy/mcsim/pin/intel64/bin/pinbin -pause_tool 5 -t /home/agy/mcsim/pthread/mypthreadtool -port 47145 -skip_first 10000 -- mcsim/jacnoboost/jaccard pausing attach pid 5465 load tool's debug info gdb use: add-symbol-file /home/agy/mcsim/pthread/mypthreadtool 0x7f86e6c06ee0 -s .data 0x7f86e709f620 -s .bss 0x7f86e70aaac0 on other window following: gdb /home/agy/mcsim/pthread/mypthreadtool gnu gdb (ubuntu 7.7-0ubuntu3.1) 7.7 copyright (c) 2014 free software foundation, inc. license gplv3+: gnu gpl version 3 or later <http://gnu.org/licenses/gpl.html> free software: free change , redistribute it. there no warranty, extent permitted law. type "show copying" , "show warranty" details. gdb configured "x86_64-linux-gnu". type "show configuration" configuration details. bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs...

Eclipse Plugin to Invoke a GUI -

i understand process of creating eclipse plugins , adding buttons or menu items eclipse. know how create eclipse plugin should add button eclipse menu , button must invoke gui. how proceed that? the gui form user needs select bunch of options. how create gui form within custom eclipse plugin?? there's plenty of information out there long search using correct names . start simple plug-in work way creating wizards .

How to create an Email queue mechanism in ASP.NET In case of network goes down? -

i developing website using asp.net. in there sending emails users. currently using code send email asynchronously user. emails sending in background. public static void sendemail(string path, string emailto) { thread emailthread = new thread(delegate() { try { string body = string.empty; using (streamreader reader = new streamreader(path)) { body = reader.readtoend(); } mailmessage mail = new mailmessage(); mail.from = new mailaddress("test@test.com"); mail.to.add(emailto); mail.subject = "test email"; mail.body += body; mail.isbodyhtml = true; smtpclient smtpclient = new smtpclient("smtp.test.com"); smtpclient.port = 587; smtpclient.deliverymethod = smtpdeliverymethod.network; smtpclient.usedefaultcredentials = false; ...

jquery - How to post a variable to a php file using ajax -

i want pass variable college.php variable can used fetch data. i tried get , post methods using form, using get variable values visible in address bar , using form resubmission alert appears used. <form class="morestories"method="get" enctype="multipart/form-data" action="college.php"> <input type="hidden" name="collegename" value="<?php $collegename=$row['name']; echo $collegename; ?>"> <input class="morestoriesbutton" type="submit" name="collegeselectlink" value="more stories" /> </form> also variables passing college.php file, on refresh should used again access data possible help this example passing name , password php function , can refer , apply accordingly condition. $(document).ready(function(){ //this button $("#click").click(functi...

c++ - Is it possible to find the number/type of the captured variables in a lambda? -

is possible automatically realize number of variables captured lambda when accessed value or reference? possible decipher types? example, assume piece of code: int = 47; int b = 48; long long c = 49; auto f1 = [=](){ return + b; }; auto f2 = [=](){ return + b + c; }; is possible have function named count_args returns 2 in line , 3 in next line if called below? std::cout << count_args( f1 ) << "\n" << count_args( f2 ); no, because question implicitly assumes captured variables in fact member variables. compiler granted far more latitude. ajay notes in comments, decent optimizer can replace members hoisted expressions, , may alter types, use non-c++ types, etcetera. may capture struct color { char r,g,b } while lambda stores .r , .g only. count_args 2/3rd ?

php - My plugin not updating properly (issue with upgrader_process_complete) -

i have users have installed plugin (we'll call v6). v6 version of plugin not register handler upgrader_process_complete . in new version, have upgrader_process_complete registered upgrades database table. however, seems when user upgrades plugins page using update now link, handler of new version not invoked. could shed light on issue?

java - How to get the part of the text from JLabel according mouse pointer -

does knows how part of text beginning of jlabel pointer of mouse? example, let's have jlabel text 'c:\aaa\bbb\ccc'. user points mouse pointer on characters 'bbb', text 'c:\aaa\bbb'. now, when have part of text, can change color. think use html that. the java accessibility api conveniently includes getindexatpoint method part of accessibletext interface converts location (such of mouse pointer) index of character @ location: given point in local coordinates, return zero-based index of character under point. if point invalid, method returns -1. here test program uses method part of string asked for: import java.awt.borderlayout; import java.awt.point; import java.awt.event.mouseevent; import java.awt.event.mousemotionadapter; import javax.accessibility.accessibletext; import javax.swing.jframe; import javax.swing.jlabel; public class jlabelmousedemo { private static string labeltext = "<html>c:\\aaa\\bbb\\ccc</htm...

Javascript method declaration -

Image
is right declare method this? window['test']['myfunction?'] = function(param) { for(var in([ param.getelementsbytagname('ol'), param.getelementsbytagname('ul') ]){ found += a.length(); } return != 0 ? true : false; } i use declare method this var test = function(param){ ... } but saw first declaration in code. not able that. what's difference in these 2 type of declaration. 1 more efficient? in javascript, virtually object meaning has set of properties. can access or set these properties in few ways, 2 of relevant here. the first option window.foo = 'bar'; . way write window['foo'] = 'bar'; first 1 called dot notation , second 1 called bracket notation . bracket notation has 1 advantage on dot notation, type of characters can use. example window.invalid-foo = 'bar' not work. window['invalid-foo'] on other hand does. now question; there poss...

bash - My shell script for checking leap year is showing error -

#!/bin/bash echo "enter year (yyyy)" read year if[ $((year % 4)) -eq 0] if[ $((year % 100)) -eq 0] if[ $((year % 400)) -eq 0] echo "its leap year" else echo "its not leap year" fi else echo "its not leap year" fi else echo "its not leap year" fi its showing error on 7th line , on [ $((year % 4)) -eq 0] you miss blanks nesessary in bash: echo "enter year (yyyy)" read year if [ $((year % 4)) -eq 0 ] if [ $((year % 100)) -eq 0 ] if [ $((year % 400)) -eq 0 ] echo "its leap year" else echo "its not leap year" fi else echo "its not leap year" fi else echo "its not leap year" fi

javascript - angular (jquery timepicker) is unable to detect changes -

im new angular , while doing small exercise, struck , wanted enable ng-show depending upon previous row timings , time input through jquery timepicker, angular unable read value of timepicker show next row my code shown below <table class="table table-bordered"> <thead> <tr> <th>time from</th> <th>time to</th> </tr> </thead> <tbody> <tr> <td> <input type="text" ng-model="row1" size=6/ disabled> </td> <td> <input type="text" id="timepicker1" ng-model="dup_row1 " size=6/> </td> </tr> <tr ng-show="show_row2()"> <td> <input type="text" ng-model="dup_row1" size=6/> </td> <td> <input type="text" ng-model="dup_row2" size=6/> ...

ios - How to rotate UILabel in xocde -

Image
i want know how rotate uilabel in xcode per attachment watermark ("expired"). use yourlabel.transform = cgaffinetransformmakerotation(m_pi /2); // set dividend additional reference see --> how angle uilabel in ios

sql server 2008 - Dynamic Pivot and Join -

i have table representing employees , various details. have table representing training courses employees have attended. employees have attended more courses others. need represent each employee single row in returned query associated details , column each course have been on. employee table: +--------+---------+---------+----------+ | empnum | empname | emptype | empphone | +--------+---------+---------+----------+ | 1234 | smith | ft | 09876543 | | 2345 | jones | pt | 08765432 | | 3456 | brown | ft | 07654321 | +--------+---------+---------+----------+ skill table: +--------+------------+ | empnum | skillname | +--------+------------+ | 1234 | first aid | | 2345 | first aid | | 3456 | first aid | | 1234 | safety | | 3456 | safety | | 1234 | leadership | | 2345 | leadership | +--------+------------+ after joining these 2 tables, i'm looking have following returned: +--------+---------+---------+----------+----...

sql - dynamic page break in SSRS -

i have report displays summary data 3 years. each page displays data 1 year. the report set have thee pages. however, year summary data negative , there no need show. there way skip page in report? there way hide controls based on rules, couldn't find way hide entire page output. in order this, can choose filter dataset rows/records negative values not appear.

Java Virtual Machine Missing Aptana Studio -

i on windows 8.1 , trying run aptana studio 3 a java runtime environment (jre) or java development kit (jdk) must available in order run aptanastudio3. no java virtual machine found after searching following locations: /c:/users/myname/appdata/roaming/appcelerator/aptanastudio/jre/bin/javaw.exe i'm on windows 10 x64 , facing same problem. have jdk 7 (64-bit) installed on machine , still getting error. solution installing jre x86 version though os 64 bit jdk installed.

mapping - Grails GORM default sort field which is also a field of a composite key -

my grails version 2.5.0 i have 2 domain classes: import org.apache.commons.lang.builder.hashcodebuilder class templateheader implements serializable { int headerid int ver string templatename string extradescription string servicetype string createdby boolean isactive string updatedby date datecreated date lastupdated static hasmany = [templateitems: templateitem] static mapping = { id composite: ['headerid', 'ver'] ver comment:'' templatename length: 40 servicetype length: 20 extradescription length: 60 isactive defaultvalue:false templateitems sort:'itemno', order:'asc' } static constraints = { headerid unique: 'ver' templatename nullable: false servicetype nullable: false } boolean equals(other) { if (!(other instanceof templateitem)) { return false } other.id == id && other.ver == ver } int ...

How can I use stanford-openIE for Chinese text -

i working on on stanford-openie not know whether supports chinese text or not. if supports chinese language, how can use stanford-openie chinese text? any guidance appreciated. stanford's openie system developed english. it's based off of universal dependencies, meaning in theory shouldn't hard adapt other languages; but, nonetheless, it's highly unlikely work out of box. at minimum, relation triple segmenter have adapted chinese. of more subtle functionality, code mark natural logic polarity , code score prepositional phrase deletions have rewritten.