Posts

Showing posts from August, 2010

sql - How to split table data into separately named Excel files with 'datepart' using an SSIS package? -

i followed great link below accomplish 90% of work. when created excel files using 'dateparts' created excel files, did not load data files. how split table data separate named excel files using ssis package? example: link above showed how create north , south , template excel files table values. in case want create north_20130613 , south_20130613 , template_20130613 . created these files also, unable load data them(extended 'datepart'). i know how append everyday data files. usually load data file general name , rename file datapart afterwards.

domain driven design - Value Object as a Service Call Argument -

in book implementing ddd, there's mention of creating tenantid value object. makes sense me, guid empty isn't valid tenantid , making tenantid value object can protect against (i have other value objects name , phonenumber , emailaddress , etc): public class tenantid { public tenantid(guid id) { this.setid(id); } public guid id { get; private set; } private void setid(guid id) { if (id == guid.empty) { throw new invalidoperationexception("id must not empty guid."); } this.id = id; } } what i'm interested in, should i, or should not, use tenantid on service method, like: tenantid tenantid = new tenantid(model.tenantid); // model.tenantid being guid. this.tenantservice.gettenant(tenantid); or should use more raw form in service method arguments: this.tenantservice.gettenant(model.tenantid); // again model.tenantid guid. the book seems 1 way , sometime another. t

android - ListView Item ID homescreen widget -

i have homescreen widget listview how can obtain number of current item clicked: i've tried following way: insite custom class extends appwidgetprovider public void onupdate(context ctxt, appwidgetmanager mgr, int[] appwidgetids) { (int i=0; i<appwidgetids.length; i++) { intent svcintent=new intent(ctxt, widgetservice.class); svcintent.putextra(appwidgetmanager.extra_appwidget_id, appwidgetids[i]); svcintent.setdata(uri.parse(svcintent.touri(intent.uri_intent_scheme))); remoteviews widget=new remoteviews(ctxt.getpackagename(), r.layout.widget); widget.setremoteadapter(appwidgetids[i], r.id.contacts, svcintent); intent clickintent=new intent(ctxt, appwidget.class); clickintent.setaction(action_widget_refresh); clickintent.putextra(appwidgetmanager.extra_appwidget_ids, appwidgetids[i]);

how to capture backspace key code in android browser - javascript? -

i have page made in pure html javascript... handle keyup code , need key code, when key code == 8 (backspace) special task must run... if open page in android browser, chrome, or whatever... backspace doesn't return key code... i've made: $( '.input-cell' ).bind( 'keyup', function( e ){ var keycode = e.keycode ? e.keycode : e.which; alert( keycode ); if( keycode == 8 ) { ..... } }); the alert returns me keycodes backspace... there way capture backspace press event? input change event $('#myinput').bind('input', function(){ // code }); backspace $('#myinput').on('keypress', function() { //code }).on('keydown', function(e) { if (e.keycode==8) { //code } });

Prevent automated robots submitting forms to ruby on rails application? -

what decent way fix form submitted everyday numerous times robots posting kind of rubbish through it? i have beta signup form hidden field , username , password field. get's submitted numerous times day , results in error reports in rails application. is there decent ruby on rails way prevent robots submitting forms? know can kind of stuff in frontend tricks seem fail ( im using hidden field trick check robots, still pass there mess true ) edit #1: adding form data posted automated robot. seems posting form fields when not present in form. url : http://mysite.com/beta * ip address: 91.121.170.197 * parameters: {"utf8"=>"✓", "authenticity_token"=>"8mvhnqgx0krwnymdoeqgd8ap52h/zrjkjnkcubgrcmm=", "betum"=>{"code"=>""}, "name"=>"bryan", "email"=>"quaker@yahoo.com", "commit"=>"joignez-vous »", "com

php - Fopen a .txt file using a regex -

i need open .txt file know directory path not entire name. know unique numbers part of name. i've checked php.net , google little bit didn't find useful. in opinion possible achieve this? for example: have these unique numbers part of filename ("9129129"), , know path directory , other files stored ("/home/library/applicationsupport/project"). file .txt, , can "xyz124124 fbqwf9129129 fwehbj$124.txt". you use glob function match .txt file sub-string: $substring = "9129129"; $path = '/home/library/applicationsupport/project/'; list($name) = glob(sprintf("$path*%d*.txt", $substring), glob_nosort) + array(null); if ($name) { $file = fopen($path . $name, "r"); // `$file` }

javascript - Bootstrap Carousel bug -

so have simple carousel made on bootstrap , want when enter carousel slide stop. works when mouse enters problem happens. div has disappear doesn't slide disappears <script> $(document).ready(function() { $('#mycarousel').carousel({interval: 1000}) .on('slid', function (e) { $(this).carousel({interval:false}); }); }); </script> example: http://jsfiddle.net/ferkp/ after bit of research, seems a known bug in bootstrap 2.x . by upgrading bootstrap 3.0, appearance of carousel gets changed, bug fixed. can grab css , js cdn: <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> oh, , might still want include result other answer (that's deleted, seems) , change $(this).carousel({ interval: false }); $(this).carousel('pause'); , otherwise piece of

javascript - MVC 4 using jquery how to check if the model property has elements in it -

i'm passing in view model works checkboxlistfor property , hide checkbox section if when repost page there no check marks ticked. can show , hide check box section no problem using: $('div.ksearch').hide(); or $('div.ksearch').show(); what i've been trying check view model has list hold information keyword model. there anyway check if list has element being passed in within jquery can show or hide section like: if (('@model.selectedkeywords').length) { $('div.ksearch').show(); } else { $('div.ksearch').hide(); } but shows section. ideas? something this? var len = @model.selectedkeywords.count; if (len > 0) { $('div.ksearch').show(); } else { $('div.ksearch').hide(); } ('@model.selectedkeywords').length treated string length in javascript, , it's positive (and true) ;)

Restore git submit history from github -

a disgruntled developer left project sabotaged git repository , have been brought on. unsure did here facts: there full commit history in github before , know sha of commit want make current head i can view commit buy using sha in github url: https://github.com/[user]/[project]/tree/d5f7068fcef33791418e3e1d2b954162403e7c8b when check out project locally not pull in history other last commit made blank readme file: $ git log commit 4cbfb43f76a41df6de6f66354566377c2ef2ab0d author: author date: sun sep 1 20:39:47 2013 +0300 initial i cannot rebase because local repo doesn't know commit sha because 1 commit comes down github. history want seems orphaned. is there way check out other commit via sha directly github (origin) , make head point that? any other ideas? you should able git merge <sha> , which, because bad dev did rebase, complain, given rebased initial commit, sounds solving conflict relatively easy. if local repository doesn't kno

c++ - OpenMP doesn't run this for loop in different threads, how can I fix it -

i have code: #pragma omp parallel for( i=0;i<(int)table.size();i++) { vec3b bgrpixel; tableelement element=table[i]; bgrpixel = inputimage.at<vec3b>(element.inputpixel.y,element.inputpixel.x); outputimage.at<vec4b>(element.outputpixel.y,element.outputpixel.x)[0] = bgrpixel[0]; outputimage.at<vec4b>(element.outputpixel.y,element.outputpixel.x)[1] = bgrpixel[1]; outputimage.at<vec4b>(element.outputpixel.y,element.outputpixel.x)[2] = bgrpixel[2]; outputimage.at<vec4b>(element.outputpixel.y,element.outputpixel.x)[3] = 255; } when run it, can see 25% of processors power used. believe not run in parallel. why not run in parallel , how can improve performance? images opencv mat objects. it suggested in comments, mat::at might kind of locking. checked opencv source, , does'nt seem case. 1 version of mat::at reproduced below: template<typename _tp> inline _tp& mat::at(int i0, int i1) { cv_dbgasse

ruby on rails - Model blank due to carrierwave gem - nested_attributes -

i've started learn ruby , ruby on rails, , first time have ask question on so, making me mad. i'm programming rest api need receive image url , store in db. for this, i've done model called imageset uses carrierwave store uploaded images this: class imageset < activerecord::base has_one :template mount_uploader :icon1, icon1uploader mount_uploader :icon2, icon2uploader def icon1=(url) super(url) self.remote_icon1_url = url end def icon2=(url) super(url) self.remote_icon2_url = url end end this icon1 , icon2 both received urls, hence setter override, , can't null. uploader classes creating versions whitelist of extensions , override of full_name. then, have template class receives nested attributes imageset. class template < activerecord::base belongs_to :image_set accepts_nested_attributes_for :image_set (other stuff) def image_set super || build_image_set end end this model has image_set_id can

javascript - ajax pagination issue with history.back() -

==> load page n ==> click list ==> list detail page. when "previous button" browser, landed in page 1, not page n. i realized ajax pagination has issue. as of now, can think of workaround solution, : - after clicking list, open new tab instead using original tab.   at least user don't struggle find previous page n. is there other solution ? specific, how land in page n after clicking previous button browser (with ajax pagination)? you can modify browser's history using history.pushstate() or history.replacestate() so, when load page n, run (as per mozilla developer's page) var stateobj = { foo: "bar" }; //save data here if url not descriptive enough history.pushstate(stateobj, "pagetitle", "pathname"); if using stateobj need listen 'popstate' event retrieve data , restore appropriate state. this part of html5 spec, might not work in older browsers.

c# - Parse HTML in Windows Phone 8 without HtmlAgilityPack -

i'm trying build app windows phone 8 i'm trying parse data website.htmlagilitypack right tool when load website htmldocument doc = web.load(url); i have error: 'htmlagilitypack.htmlweb' not contain definition 'load' , no extension method 'load' accepting first argument of type 'htmlagilitypack.htmlweb' found my question is: there other way htmlagilitypack parse html in windows phone 8 ? thanks. that method not available wp8, since doesn't allow async downloads. should somehow download page , load htmldocument, example httpclient client = new httpclient(); var html = await client.getstringasync("http://stackoverflow.com"); var doc = new htmlagilitypack.htmldocument(); doc.loadhtml(html);

java - Trying to throw own exception -

i created own throwable exception when want throw it, editor says, reference enclosing class required. don't know, need write. here's code: public class main { int = 0; public main() { if (i == 0) throw new myexception("i must not 0"); //here says enclosing class } public static void main(string[] args) throws exception { new main(); } public class myexception extends exception { public myexception(string e) { super(e); } } } someone can tell me, , must write? you've defined myexception inner class of main, created instance of no corresponding instance of main available (since main method static method). you need declare exception class separately, outside of main. changing access public package-private let keep declaration in same file. otherwise, since can have 1 public class per file, need go in own file. alternatively can define static inner class, so: public class

php - Users having multiple accounts -

this question isn't how question or technical question more of should way kind of question? so scenario -> administrator part of committee (so have 2 user groups admin , committee). admin wants in committee user group because admins (as per upper management) not allowed grade application unless in committee. program separates roles admins, committee, upper management, , scholarship administration. idea 1 so first thought had of having admin committee role member have 2 accounts, if admin wants use work email both accounts. in end means both committee account , admin account on same email same user. idea 2 the next thought had if can use first name, , last name, both accounts user use first , last name. again stumped on proper way of going issue. issues : don't want make custom user roles person , make view again 1 person. so, in end came : user uses same email both accounts user enters email clicks button called "next step" thi

php - Zip and Download -

i use code zip , download files php browser start zip download, corrupt. when try open browser say's format file unknown or damaged. any tip solve? $files = array('1.png', '2.png'); $zipname = 'file.zip'; $zip = new ziparchive; $zip->open($zipname, ziparchive::create); foreach ($files $file) { $zip->addfile($file); } $zip->close(); header('content-type: application/zip'); header('content-disposition: attachment; filename=file.zip'); header('content-length: ' . filesize($zipfilename)); obclean(); flush(); readfile($zipname); the problem in line: header('content-length: ' . filesize($zipfilename)); obclean(); change to: header('content-length: ' . filesize($zipname)); ob_clean();

loops - How to pass a List of Maps to a GSP page view and iterate over it -

let's want show information files of folder. have save information of each file in map. then, add these maps list. controller action: def show() { list results = new arraylist(); file dir = getdir(params.id); if (dir.exists()) { dir.eachfile { map fileinformation= new java.util.linkedhashmap() fileinformation.put("name", it.getname()); fileinformation.put("size", it.length()); fileinformation.put("path", it.getabsolutepath() ); results.add(fileinformation); } } [filesoffolderdata: result] } maybe, best attempt data in view (i followed approach of here no luck): <g:each in="${filesoffolderdata}"> <p> it: ${it}</p> <p> it.properties: ${it.properties} </p> <g:each var="propertyentry" in="${it.properties}"> <p> propertyentry.key: ${propertyentry.key} </p>

Map a war to root - JAVA Azure web role -

Image
i created simple servlet in eclipse (as dynamic web project) installed azure sdk, packaged project windows azure using gui, i want app deployed root folder, so can access : mysite.com/servlet?.... and not like: mysite.com/war_name/servlet?.... reffering answer : deploying application @ root in tomcat i added server.xml <context docbase="war_name" path="" reloadable="true" /> also tried: <context docbase="war_name" path="" reloadable="true" debug="0"><context/> i used remote control verify server.xml has line included (just before 'host' end tag) and does, yet still cannot access app want to. i new java, using tomcat 7, , here screenshot have done : the simplest way map java webapp (eg: war) root context path deleting original tomcat_home/webapps/root , renaming war file root.war (if you're deploying in archive style), or rename folder root (

vb.net - VB NET Application Starts with Wrong Icon First Time -

i have created vb net application installed installer project (msi). installer works perfectly, app functions designed. on windows 2008 server r2 (standard), first time log in application starts wrong icon/task bar group. starts ibm tivoli command line icon or gui icon options in group. after close application , open second time, have correct icon , taskbar group. if log box , start different application, application, correct icon/group. things have tried... uninstalling/reinstalling multiple times confirmed application advertised deleted icon cache profile more information (from continued trouble-shooting)... if set taskbar buttons "never combine" correct icon app, not correct group options (right click). if pin ibm tivoli command line taskbar, problem goes away. app starts correct icon/group every time. if pin app taskbar, problem resolved every time. so problem occuring when neither app pinned taskbar. another update... this issue occurs

html - How to vertically align the text into a coloured div using CSS? -

i need vertically align text div have height. if go here can see problem: http://onofri.org/example/example3/ as can see have #titlebox div contain text: promoting investment in agriculture the #titlebox have specific height 40px. want vertically align text in green div in such way @ center. this html , css code don't work well: <div id="container"> <div id="titlebox"> <p id="mytitle">promoting investment in agriculture</p> </div> </div> #titlebox{ margin: 0 auto; width: 350px; background-color: #6da662; height: 40px; vertical-align: middle; } #mytitle{ /* consente di posizionare un elemento al centro del suo contenitore */ margin: 0 auto; overflow: hidden; color: #fff; font-size: 16.5px; font-weight: bold; text-align: center; } what have solve? tnx andrea try add these styles #mytitle : vertical-align: middle; li

php - How to use CKEditor as form input? -

i trying make simple web editor using ckeditor cant find out how make work. first checked samples site. thing make ckeditor work include .js file , add ckeditor class form textarea element. <script src="../ckeditor.js"></script> . . . <textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10"> so copy .js file , try in own folder , when run php script whole textarea element hidden , doesnt create ckeditor panel should in this sample page. there might javascript configuration havent found in source code of sample page. copy of ckeditor folder server. add html page ;like this: <script src="../script/ckeditor/ckeditor.js" type="text/javascript"></script> assign css class of textarea ckeditor ; class="ckeditor" .

html - Aligning 270 degree oriented div (transform: rotate) -

Image
i have div (tab) rotate 270 degrees so: -webkit-transform-origin: 100% 0%; -webkit-transform: rotate(270deg); (example here: http://users.telenet.be/prullen/align.html ) when want align tab top edge of content box, it's pretty easy. set "top" "3px" (the border size). however, bottom it's story. it appears need calculate jquery so: $tab.css('bottom', (math.abs($tab.outerwidth()-$tab.outerheight()) (though example i'm using static value. may not want in browser, here's image: ) i wondering if there better way since not seem work in firefox example (1 pixel shift). there easier way adjusting transform-origin perhaps? (note need keep same div structure have now) ideally it'd easy setting bottom to: 3px (the border thickness) thanks. when want put tab @ top of sticky, apply class .tab-top .sticky-tab element. .tab-top { transform-origin: 100% 0%; transform: rotate(270deg); top: 5px; /*bo

Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column -

Image
i'm trying insert large csv file (several gigs) sql server, once go through import wizard , try import file following error report: executing (error) messages error 0xc02020a1: data flow task 1: data conversion failed. data conversion column ""title"" returned status value 4 , status text "text truncated or 1 or more characters had no match in target code page.". (sql server import , export wizard) error 0xc020902a: data flow task 1: "source - train_csv.outputs[flat file source output].columns["title"]" failed because truncation occurred, , truncation row disposition on "source - train_csv.outputs[flat file source output].columns["title"]" specifies failure on truncation. truncation error occurred on specified object of specified component. (sql server import , export wizard) error 0xc0202092: data flow task 1: error occurred while processing file "c:\train.csv" on data row 2. (sql server impor

SQLAlchemy db.session.query() vs model.query -

for simple return results query should 1 method preferred on other? can find uses of both online can't find describing differences. db.session.query([my model name]).all() [my model name].query.all() i feel [my model name].query.all() more descriptive. it hard give clear answer, there high degree of preference subjectivity in answering question. from 1 perspective, db.session desired, because second approach requires incorporated in model added step - not there default part of base class. instance: base = declarative_base() dbsession = scoped_session(sessionmaker()) class user(base): __tablename__ = 'users' id = column(integer, primary_key=true) name = column(string) fullname = column(string) password = column(string) session = session() print(user.query) that code fails following error: attributeerror: type object 'user' has no attribute 'query' you need this: class user(base): __tablename__ = 'users&

c# - How to avoid convoluted logic for custom log messages in code? -

i know title little broad, i'd know how avoid (if possible) piece of code i've coded on solution of ours. the problem started when code resulted in not enough log information: ... var users = [someremotingproxy].getusers([somecriteria]); try { var user = users.single(); } catch (invalidoperationexception) { logger.warnformat("either there no users corresponding search or there multiple users matching same criteria."); return; } ... we have business logic in module of ours needs there single 'user' matches criteria. turned out that, when problems started showing up, little 'inconclusive' information not enough know happened, coded method: private user getmappeduser([searchcriteria]) { var users = [remotingproxy] .getusers([searchcriteria]) .tolist(); switch (users.count()) { case 0: log.warn("no user exists [searchcriteria]"); return null; case

c# - Event before pressing a key or barcode scanner -

Image
how this? example: i have textbox1 , input "someinput" leave textbox1 . (input using keyboard or barcode scanner) when return textbox1 "someinput" highlighted textbox1.selectall() . when press key "someinput" changed key press. (or use barcode scanner) now, how would insert "someinput"(the input before key press) in textbox3 ? i tried textchanged event insert new key pressed. private void textbox1_textchanged(object sender, eventargs e) { textbox3.text = textbox1.text; } focus event not allowed. another question: textchanged occur when barcode scanned? assuming select text in textbox1 focus gets over,writing code in textbox1.enter might achieve need; private void textbox1_enter(object sender, eventargs e) { if (textbox1.selectedtext.length == textbox1.textlength) { textbox3.text = textbox1.text; textbox1.text = ""; } }

ios - 1000 * 256 *4 for loop takes a minute to complete -

i'm trying check winning numbers of simple gambling game. user selects 4 cards of each symbol (diamond, heart etc') , creates 256 combinations specific selection. 4*4*4*4 = 256 combinations. have array of 1000 raffle results. each result contains 4 winning cards , numeric value. i need check how many winning cards each result contains. my code looks this: for(int=0;i<results;i++) // [results count] = 1000 { ... ... //take 1 results , check against combinations for(int j=0;j<usercombinations;j++) // [usercombinations count] = 256 { [self checkwins:[usercombinations objectatindex:j]] } } -(void)checkwins:(nsmutablearray *)myarray { for(int j=0;j<4;j++) { //j=0 -> if heart numeric value equals heart numeric result //j=1 -> if diamond numeric value equals diamond numeric results } } there may typos in code (wrote memory) basic idea same. question

java - How to get a response message from opening an App Engine Channel? -

i'm trying create typical chat room app in google app engine. far, when user logs in, i'm able create token them, being displayed in chat area. my problem after getting token i'm not able open or use channel. this javascript code below, i'm able create token sending user-entered clientid , sending servlet (chatroom.java): <script type="text/javascript"> $(document).ready(function(){ alert("doc"); $("#field1").hide(); $(".button").click(function(){ $("#field2").hide(); $("#field1").fadein(2500); var clientid = $("#textbox2").val(); var form=$('#form1'); $.get(form.attr('action'),$(form1).serialize(),function(data,status){ alert(status); $('#display').val(" client id "+clientid); $('#display').val(" tok id "+data.token);

javascript - Customize typing cursor in string -

i wish change writing cursor (while typing there show/hide cursor) position in replace string. here string: if(str.indexof('<html>') != -1){ str = str.replace(/\<html\>([a-z|a-z|0-9| ])/g, "<html>\n \n</html>"); } that means when typing <html> result is: <html> </html>| ^ typing cursor now wanted result: <html> | </html> how can customize/place typing cursor in replacement string? try in js console on stackoverflow, after clicking [ask question]: document.queryselector('textarea#wmd-input').value = "here >< caret" document.queryselector('textarea#wmd-input').selectionstart = 6 document.queryselector('textarea#wmd-input').selectionend = 6 for element types other textarea element.setselection(startposition, startposition) might work.

apt get - "reading files list for package 'inkscape': Input/output error" while trying to install packages -

it doesn't matter try install using package manager(sudo apt-get install whatever), error. dpkg: unrecoverable fatal error, aborting: reading files list package 'inkscape': input/output error e: sub-process /usr/bin/dpkg returned error code (2) i have researched , have tried rebuild dpkg status file, , have tried revert older version, either hasn't worked or doing wrong. also, when try run command "sudo apt-get update", error. the problem started when lost internet connection while downloading monodevelop. appreciated. i figured out answer, post here in case else has same problem in future. note: after fix, apt-get no longer installs dependencies me automatically without using -f flag. go /var/lib/dpkg directory make backup of "status" file open status file root , find package causes error. in case, "package: inkscape". delete text until next package: declaration in file.

java - Parsing XML with XmlPullParserFactory is crashing in while statement -

i using xmlpullparserfactory object parse xml receive server. reason crashes @ while statement , can't figure out why happen. xml: <?xml version="1.0" encoding="utf-8"?> <body> <item> <id>115240</id> <title> <![cdata[student evangelism team leaves fiji]]> </title> <created>20130821-15:50</created> <author> <![cdata[staff writer]]> </author> <summary> <![cdata[on august 21, service, justice, , missions coordinator fabio maia , ten pacific union college students left eighteen-day evangelism mission in fiji sharehim , quiet hour ministries.]]> </summary> <body_text> <![cdata[<p>on august 21, service, justice, , missions coordinator fabio maia , ten pacific union college students left eighteen-day evangelism mission in fiji sharehim , quiet hour ministries. each student placed in spe

java - Array exception error, Point3f array -

i'm having null pointer exception error on point3f array , can't see why. happens on first pass position [0] selected. can explain this? thanks. import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import javax.vecmath.point3f; public class starter { static int noofsides = 4; public static void main(string[] args) { point3f[] pointarray = new point3f[noofsides]; for(int i=0; i<noofsides; i++) { system.out.println(i+1+". input x value: "); pointarray[i].x=readconsole(); // pointer exception here system.out.println(i+1+". input y value: "); pointarray[i].y=readconsole(); pointarray[i].z=(float)0.0; } // static call work out area of polygon system.out.println("area: "+polyareatry.calarea(pointarray)); } public static float readconsole() { string s = null; try { bufferedreader bufferread = new bufferedreader(

Progress indicator during pandas operations (python) -

i regularly perform pandas operations on data frames in excess of 15 million or rows , i'd love have access progress indicator particular operations. does text based progress indicator pandas split-apply-combine operations exist? for example, in like: df_users.groupby(['userid', 'requestdate']).apply(feature_rollup) where feature_rollup involved function take many df columns , creates new user columns through various methods. these operations can take while large data frames i'd know if possible have text based output in ipython notebook updates me on progress. so far, i've tried canonical loop progress indicators python don't interact pandas in meaningful way. i'm hoping there's i've overlooked in pandas library/documentation allows 1 know progress of split-apply-combine. simple implementation maybe @ total number of data frame subsets upon apply function working , report progress completed fraction of subsets. is perha

text - Assembly, how to read something from a txt? -

i need read phrase , how many times appears each letter, example: "hello sir" h=1, e=1 , l=2, o=0, s=, i=1, r=1 but dont know how take text txt , use on assembly code. using (var sr = new streamreader(@"c:\test.txt")) { var str = sr.readtoend(); var charlist = str.distinct().tolist(); foreach (var chr in charlist) { var count = str.count(x => x == chr); console.writeline(string.format("{0} : {1}", chr, count)); } }

html - PHP Pagination Bug with Twitter Bootstrap -

i have bug in program pagination links not show @ when $page_rows greater 1. <?php require('/inc.all.php'); $_session['lasturl'] = $_server['request_uri']; // total count of rows $sql = "select count(username) user_profile hidefromusercount='0'"; $query = $db->query($sql); $row = $query->fetch_row(); // total row count $rows = $row[0]; //number of results per page $page_rows = 3; //tells number of last page $last = ceil($rows/$page_rows); if($last < 1) $last = 1; //establish $pagenum variable $pagenum = 1; if(isset($_get['pg'])) $pagenum = preg_replace('#[^0-9]#', '', $_get['pg']); else $pagenum = 1; //makes sure pagenumber isnt below 1 or more $last if($pagenum < 1) $pagenum = 1; else if($pagenum > $last) $pagenum = $last; //sets range of rows chosen $pagenum

javascript - How to clone element when i use $.append -

i have data json when page load pull combo box. function dataprovide(){ //load data json selectvalues = { "pilih" : "-pilih-", "id" : "id", "emp_name" : "employee name", "photo_path" : "photo path", "emp_id" : "employee id", "birth_place" : "birth place", "birth_date" : "birth date" }; $.each(selectvalues, function(key, value) { $('#data1_1') .append($("<option></option>") .attr("value",key) .text(value)); }); } $(document).ready(function() { dataprovide(); }); when page load, generated data input combo box, problem when want perform additional row in table using $.append.... $(".addcf").click(function(){ count

javascript - Trying to add a bit logic to game -

i have fight game , want add bit more interaction, kinds of abilities. way this? constructor , list of abilities or i've missed more simple method this? var abilityconstructor = function(name, desc, icon, target, param, rate, duration) { this.name = name; // name of ability this.desc = desc; // ability's description this.icon = icon; // ability's icon this.target = target; // if self usage - 0, if enemy - 1 this.param = param; // parameter influenced (health - 0, damage - 1, speed - 2, missing rate - 3) this.rate = rate; // factor dealing (ability's strength) this.duration = duration; // spells' duration (current round - 1, 2 rounds - 2, 3 rounds - 3) } // list of available rates abilities var lowrate = 0.1; var midrate = 0.25; var highrate = 0.5; var testability = new abilityconstructor('health reduction', 'reduces health of opponent 2 rounds', 'icon_path_here', 1

javascript - using 2 classes from css and jquery together -

i'm trying apply css class , jquery class checkbox <input type='checkbox' name='something' class='group_ctrl' data-group='group_a' id='checker'> css code class = 'styled' (jquery code combined css code style checkbox) .checkbox, .radio { width: 19px; height: 25px; padding: 0 5px 0 0; background: url(images/checkbox.png) no-repeat; display: block; clear: left; /* float: left; */ } jquery code class = "group_ctrl" $(document).ready(function() { $('.group_ctrl').change(function () { // gets data-group value , uses in outer selector // select inputs controls , sets disabled // property negated value of it's checked property $("." + $(this).data("group")).prop('disabled', !this.checked); }).change(); }); the current html allows checkmark enable or disable other fields in can see in jquery, css code

html - What is wrong with my CGI script to print MySQL data? -

i want display data mysql database in browser, using ruby cgi script. the problem have displaying data; displays title column, , 1 cell , nothing price , isbn columns. i used "title varchar, price decimal(10,2), isbn integer" create table. i tried displaying price , isbn first 2 columns don't print, data in database. #!/usr/bin/env ruby require 'mysql2' require 'cgi' client = mysql2::client.new( :host => "localhost", :database => "tempdb", :username => "user", :password => "pass" ) results = client.query("select * mytable") cgi = cgi.new puts cgi.header puts "<table border='1'> <tr> <th>title</th> <th>price</th> <th>isbn</th> </tr>" results.each |row| puts "<tr>" puts "<td>" + row["title"] + "</td>" puts "<t

ruby - Backing up open source gems in case they go away -

we wondering how developers deal possibility gem author deletes git repository , gem goes away. forking/cloning every gem use , updating them every new version of our app starts ridiculous if have hundreds of gem dependencies. how have other developers tackled potential issue? you don't have fork repo. have clone it. can push clone newly-created project later on, if needed. but yes, sort of thing has happened before, of why lucky stiff 's projects.

c++ - getch() to capture Ctrl-*letter* on linux -

i have decided use getch conio.h on linux. have heard not recommended need solution , work improve programming skills later. i read number of tutorials of how enter one key , program something. such as: printf("press key\n"); c = getch(); if (c) printf(" key pressed keyboard "); else printf("an error occurred "); however if want use enter ctrl + e print 'a ctrl held key'. how go around doing this? getch() function found on windows in #include <conio.h> or on unix in #include <curses.h> . did mean call 1 of those? not function defined in c standard (the standard functions getc() , getchar() , of course). if use function <curses.h> , need initialization first , finalization afterwards. assuming resolve issue of function planning call, find control characters number 1..26: control-a = 1 control-z = 26 you might need translation work on getch() <curses.h> — it returns interesting v

javascript - Drag and drop picture to text and with double click to remove the text inside the box -

<!doctype html> <html lang="en"> <head> <meta charset=utf-8 /> <title>basic drag , drop</title> <style> #drop { min-height: 200px; width: 200px; border: 3px dashed #ccc; margin: 10px; padding: 10px; clear: left; } p { margin: 10px 0; } #triangle { background: url(images/triangle.jpg) no-repeat; } #square { background: url(images/square.gif) no-repeat; } #circle { background: url(images/circle.jpg) no-repeat; } #red { background: url(images/red.jpg) no-repeat; } #yellow { background: url(images/yellow.jpg) no-repeat; } #green { background: url(images/green.jpg) no-repeat; } .drag { height: 48px; width: 48px; float: left; -khtml-user-drag: element; margin: 10px; } </style> <script> var addevent = (function () { if (document.addeventlistener) { return function (el, type, fn) { if (el && el.nodename || el === window) { el.addeventlistener(type, fn, false

Can I do research in Visual Basic 2010? -

i want know, how can search in "visual basic 2010"? i not have code project, need help, want do: i want show word searched in text-box in "rich text box" you can iterate through string in text box , search key word. if looking ready made solution here link shows how highlight search text in rich text box. http://www.dotnetcurry.com/showarticle.aspx?id=146

laravel - Executing a Route (Controller/Action) using PHP CLI and Detecting a CLI Request -

is there way in laravel 4 run controller/action using php-cli? have controller/action extend perform alternative action if request comes cli, there way identify request cli request? the laravel documentation on this site seems suggest there method request::cli() determining if current request via artisan cli when used method in laravel 4, throws error: call undefined method illuminate\http\request::cli() basically, have moved cakephp laravel , accomplish similar what's described in article (for cakephp) : calling controller actions cron , command line i understand can work laravel 4 artisan commands, approach use possible? , if so, how? as rob said, determine if current script being run in console use app::runninginconsole() or simple plain php php_sapi_name() == 'cli' . as running controller@action console, use curl or wget request 1 of routes think proper way of doing use custom artisan command . controllers classes can instantiate them , u

text - Replacing words within a matrix in R -

i have matrix. single data entry in matrix character string. example, "crocin tablet". matrix contains many entries "tablet" @ end. want replace word "tablet" "tab" every entry within matrix. how can in r? just making ananda mahto's solution more explicit. > newmatrix <- matrix(data=c("abbott laboratories tablet", + "abbvie tablet", + "acadia pharmaceuticals tablet", + "acorda therapeutics tablet", + "actavis tablet", + "actelion tablet", + "advanced chemical industries tablet", + "advaxis tablet", + "ajanta pharma tablet", + "alcon tablet"), nrow=5, ncol = 2) > gsub("tablet

Html table overlapping in mobile browser when sending email with same subject from c# code -

i sending emails our users updated score after each interval of game. sending email same subject same message body updated interval score. when open email in mobile browser creates group of emails , overlaps mail format when send single mail display correctly. not display correctly in grouping. think group because same email id. display correctly on desktop browser. how solve it, please me. private static stringbuilder createstringformat_forsendingmail(datatable dtteamscoredb, int qtrno, string quater) { stringbuilder strtable = new stringbuilder(); string strnotes = "",str; int flag = 0; bool otadded = false; try { string strteam1 = "", strteam2 = "", strotteam1score = "", strotteam2score = "", strfinalscore1 = "", strfinalscore2=""; strteam1 = dtteamscoredb.rows[0]["team1name"].tostring(); strteam2 = dtteamscoredb.rows[0]["team2name"].tost