Posts

Showing posts from July, 2015

c++ - Boost::ASIO cannot write back to client from server -

i have couple questions regarding boost asio. i'm running problem clients can connect server, , asynchronously send data, cannot receive back. the async_write callback gets error: "the file handle supplied not valid". find strange couple reasons: when client connects initially, check socket.isopen() on server, , returns true. the fact client can still send data makes me think it's server side problem, or firewall problem (which find odd because server , client both on same computer (i'm using "localhost" connect now). some more info... tcp sockets. i'm using boost , allegro side-by-side, , both boost , allegro threads being used. have io_service running in boost thread (server , client): boost::asio::io_service::work work( io_service ); boost::thread io_thread( boost::bind( &boost::asio::io_service::run, &io_service ) ); and that's being called before create sockets. the allegro threads hold allegro event loops, no

ruby on rails - Remove buttons on active_admin_editor gem -

i'm trying customize buttons on ribbon of active_admin_editor gem. according documentation, i've set on initializers/active_admin_editor.rb test it: activeadmin::editor.configure |config| config.parser_rules['tags']['h1'] = { 'remove' => 1 } config.parser_rules['tags']['h2'] = { 'remove' => 1 } config.parser_rules['tags']['h3'] = { 'remove' => 1 } end but no avail. did rm -rf tmp/cache as suggested on docs , restarted server several times, still change makes no effect, , h1, h2, h3 buttons still showing up. problem? hello! the parser bit reads input , defines if styling has been attached it, if copy , paste content html page.. , if styling applicable or not in block, right. an other idea had first deactivate of selectors , reactivate them 1 one. think quite thing users tend copy formatted text it. here solution: activeadmin::editor.configur

Sorting files in C -

i trying write program opens text file, reads file, changes upper case lower case, , counts how many times word has occurred in file , prints results new text file. my code far follows: #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <ctype.h> #include <string.h> int main() { file *filein; file *fileout; char str[255]; char c; int = 0; filein = fopen ("input.txt", "r"); fileout = fopen ("output.txt", "w"); if (filein == null || fileout == null) { printf("error opening files\n"); } else { while(! feof(filein)) //reading , writing loop { fscanf(filein, "%s", str); //reading file = 0; c = str[i]; if (isupper(c)) //changing upper case lower case { c =(tolower(c)); str[i] = putchar(c); }

jQuery smooth toggle css width between value and auto -

i looking smoothly toggle css width of div between value , auto. have this, second-best option know achieve want. by doing hoping create click menu wide image , name. $('#loginbutton').click(function(){ $(this).css('width', 'auto'), $("#profile").delay(100).toggle(300); }); other toggle functions found wouldn't work "auto" value, find strange. next toggle option div , it's contents "smoothly" widen, rather pop once clicked. jsfiddle: http://jsfiddle.net/everybdylies/jaxpd/1/ thank you. the crux of problem no 1 talks $.stop(true,false).animate({width: 'toggle'}); anymore (deprecated?). also, display:inline-block useful when don't want take available space don't want element quite such pushover display:inline . i changed little show how can done, there's still work needs done make text display properly. http://jsfiddle.net/ctms3/2/ jquery (and other js lib animate

How can I get this hittest to work -

i'm creating game player holding baseball bat , when click button swing bat. when swing bat hit enemy enemy goes flying off in opposite direction of hit them golf ball. have done moving , attacking function working how can register hittest hits enemy when facing towards , enemy going back. done far: package { import flash.display.movieclip; import flash.events.event; import flash.events.keyboardevent; import flash.events.mouseevent; import flash.ui.keyboard; public class player extends movieclip { var walkspeed:number = 4; var walkright:boolean = false; var walkleft:boolean = false; var walkup:boolean = false; var walkdown:boolean = false; var attacking:boolean = false; public function player() { stage.addeventlistener(keyboardevent.key_down , walk); addeventlistener(event.enter_frame, update); stage.addeventlistener(keyboardevent.key_up, stopwalk

C++, Constructor with istream on a derivate class -

i have problem derived class have constructor istream in parameter. reference.cpp _ .... reference::reference(istream& p_is) {...} .... livre.h _ class livre : public reference { private: void verifieinvariant() const; std::string m_editeur; std::string m_isbn; public: livre( const std::string& p_cote, const std::string& p_theme, const std::string& p_titre, const std::string& p_auteurs, int p_anneeedition, const util::date& p_dateacquisition, const std::string& p_editeur, const std::string& p_isbn); livre(std::istream& p_is); ... livre.cpp .... livre::livre(std::istream& p_is) { reference(std::istream& p_is); string editeur =""; string isbn = ""; string buffer = ""; getline(p_is, buffer); getline(p_is, editeur); getline(p_is, isbn); m_editeur = editeur; m_isbn

javascript - Trying to loop through images with a delay in canvas -

i have 25 images want show quickly, kinda slideshow without effects. images named 0 26. i've tried setting loop , settimeout delay settimeout runs @ end of loop showing = 25 @ checkpoint. js: function startanimation(){ for(var i=0; i<25; i++){ settimeout(function(){ img = new image(); img.src = 'images/canvas/'+[i]+'.jpg'; img.onload = function(){ctx.drawimage(img,0,0, 850,194)} alert('cp. in settimeout. i= '+i); },1000); ctx.clearrect(0,0,canvas.width, canvas.height); //clear image after 1 sec, loop show next. alert('cp outside. = '+i); } } i followed solution how add delay in javascript loop? : function startanimation(){ settimeout(function(){ img = new image(); img.src = 'images/canvas/'+[counter]+'.jpg'; img.onload = function(){ctx.drawimage(img,0,0, canvas.width,canvas.height)}; counter++; if(counter<26){

asp.net mvc - MVC Wizard Issues -

i attempting create wizard in mvc. because need submit stuff db after each step, pass data controller instead of handling client side. cannot life of me figure out doing wrong though. have containing viewmodel viewmodels each of steps , stepindex keep track of at. each of step pages typed containing viewmodel. reason when increment stepindex shows incremented in controller, never kept. have hidden value it, , step1 value passed. have tried model.stepindex++ , model.stepindex + 1, both show in controller incremented when view loaded incorrect value used. turned off caching see if cause. please let me know if see doing wrong. thank you, tj containing view model public class wizardvm { public wizardvm() { step1 = new step1vm(); step2 = new step2vm(); step3 = new step3vm(); } public step1vm step1 { get; set; } public step2vm step2 { get; set; } public step3vm step3 { get; set; } public int stepindex { get; set; } } st

eclipse - Android Widget - Click for action, update under 30 minutes, separate instances -

i've tried create widget that, on click calls routine on configuration activity, on update calls routine on configuration activity, update must under 30 minutes , instance created must work separately (in onupdate , in onclick). the code below: click doesn't work (can't see toast message , other function) update works fine first instance multiple widget instance works bad: if create 2 instances between 10 seconds (and refresh set 20 seconds) update every 10 seconds. that's manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.fraschi.controllogiardinowg" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <application android:allowbackup="true" android:icon

c# - How to use SqlCacheDependency with SqlCommand and MVC -

i have sqlcachedependency working mvc project i'm still bit confused on how working sqlcommand. goal dependency on couple fields changing within table, not in entire table changing. so of right have set similar demo: http://sdeu.wordpress.com/2011/02/08/activate-asp-net-mvc3-caching-with-database-dependency/ my question is, can specify specific sqlcommand query depend on? , put code? i'd guess global.asax.cs. i'd imagine this: sqlcommand cmd = connection.createcommand(); cmd.commandtext = "select fieldname1, fieldname2 myschema.sometable"; sqlcachedependency mydependency = new sqlcachedependency(cmd); but how would use in controller? maybe: [outputcache(duration = int32.maxvalue, sqldependency = mydependency)] also, required create table triggers , cache table(aspnet_sqlcachetablesforchangenotification) on database if use sqlcommand dependency? thanks help.

python - How to plot image data versus time with matplotlib -

Image
i've captured set of images each column timestamped. i've concurrently sampled other signals (e.g. gyroscope data) timestamped. i'd plot these signals on 2 vertically aligned subplots share time axis. as far understand, cannot call imshow() twice in subplot , position each image @ different location along x (they both share starting position, overlapping, , there doesn't seem setting overcome this): import matplotlib.pyplot plt fig, ax = plt.subplots(nrows=2, ncols=1, sharex=true) ax[0].imshow(np.atleast_2d(i[0][0]).t, cmap=plt.cm.gray, \ interpolation='nearest', aspect='auto') ax[0].imshow(np.atleast_2d(i[0][1]).t, cmap=plt.cm.gray, \ interpolation='nearest', aspect='auto') after googling, i've found potential solution entails creating axes within top subplot, inside of can plot each column: import matplotlib.pyplot plt fig, ax = plt.subplots(nrows=2, ncols=1, sha

php - Sanitizing some SQL queries -

this question has answer here: how can prevent sql injection in php? 28 answers what easiest , effective way sanitize this: $q = "select * `admin` " ."where `username`=' ".$_post["username"]."' " ."and `passcode`=' ".$_post["password"]."' " also, learning php if please provide explanations, tips, suggestions, or more ways clean stuff prevent sql injections appreciated i use $mysqli prepared statements - here example php site: explanation (see bottom example using code): you replace variables in query ? marks, , bind variables in @ later time. $city = "amersfoort"; /* create prepared statement */ if ($stmt = $mysqli->prepare("select district city name=?")) { /* bind parameters markers */ $stmt->bind_param("s", $ci

java - JOptionPane.showInternalInputDialog not being editable -

i'm writing jdesktoppane application, , in jinternalframe , i've got jeditorpane webpage open (yes, i'm aware of crappy abilities of jeditorpane net, don't scold). i have way user input page visit, when call joptionpane.showinternalinputdialog(this, "what page visit?") text field not editable. problem has occurred me both in java 6 , java 7. edit: here's constructor of class public internet() { super("internet", true, true, true, true); setsize(500, 400); try { pane = new jeditorpane(new url("http://www.vetrustech.tk")); } catch (malformedurlexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } setcontentpane(pane); bar = new jmenubar(); page = new jmenu("page"); enterpage = new jmenuitem("enter page"); bar.add(page); page.add(enterpage); setjmenubar(bar); enterpage.addactionlistener(new act

GitLab: Is the backup rake task atomic? -

if make gitlab backup using gitlab:backup:create rake task pushing repositories, backup process affected? is necessary shutdown gitlab before doing backup? the task gitlab/backup.rake doesn't atomic. calls: rake::task["gitlab:backup:db:create"].invoke rake::task["gitlab:backup:repo:create"].invoke that uses gem activerecord : puts "dumping database tables ... ".blue activerecord::base.connection.tables.each |tbl| ... like other operations activerecord (see this question ), doesn't seem global atomic operation. hold on, few hours ago, randx (dmitriy zaporozhets) , main developer gitlab, refactored dumping database: commit 38d23c0e5f816937047c9326f9dd33fb10490032 shows use of system call mysqldump : system("mysqldump #{mysql_args} #{config['database']} > #{db_file_name}") commit c33d5e16fe5f5dde4f270adaf7fb6fe5b9552018 add grant select, lock tables, ... so part dumping data

Multiple loops in Wordpress -

i'm new wordpress , still getting head around loop , handling more advanced problems. basically i'm trying create listings page of posts in category, , want output posts based on tags posts in category have. the output 2 posts every tag. so i'm thinking, if can create array of various tags belong posts in category, loop through posts, grabbing latest 2 matching each tag in array , display pair of listings 1 after other..? is possible, or there better way of achieving want?

How do you use external Scala compiler with IDEA 12? -

how use external scala compiler idea ? seem have randomly appearing errors saying "scala: cannot connect compile server @ localhost/127.0.0.1:3200" sometimes works. doesn't. can't find pattern. here have in log 9:20:58 pm auto make completed errors 9:21:09 pm using new (sbt-based) scala compiler. in case of compilation problems may enable previous (internal) compiler clearing: project settings / compiler / use external build 9:21:10 pm scala compile server error: not create java virtual machine. error: fatal exception has occurred. program exit. 9:21:12 pm compilation completed 1 error , 0 warnings in 3 sec i'm using idea 12.1 (129.161) scala compiler 2.10.1 scala plugin 0.7.213 jdk 1.7 windows 7 in project settings / compiler / use external build checked. in ide settings / scala / run compile server checked. do need launch compiler server manually ? else ? upd: looks bug me. posted jira ticket

javascript - Extractzipfile plugin have error: plugin not found in ios -

i trying use extractzipfile plugin ios @ " https://github.com/phonegap/phonegap-plugins/tree/master/ios/extractzipfile ". but when use plugin in ios it's show error: 2013-04-05 11:20:17.968 fileandzip[751:c07] error: plugin 'extractzipfileplugin' not found, or not cdvplugin. check plugin mapping in config.xml. 2013-04-05 11:20:17.969 fileandzip[751:c07] -[cdvcommandqueue executepending] [line 103] failed pluginjson = [ "extractzipfileplugin733749280", "extractzipfileplugin", "extract", [ "test.zip", "\/users\/alienware\/library\/application support\/iphone simulator\/6.1\/applications\/4bca6b22-c582- 4529-92ff-4c7e54e82c18\/documents\/ex" ] ] i in guild file. me fix it! lot... edit: this code: <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0">

Netbeans 7.3: Error connecting to Git repository with SSH -

i trying connect git repository on remote server can edit source code in netbeans 7.3, when try connect repository ssh private key clone repository, error: java.lang.arrayindexoutofboundsexception: 779 log: info [org.netbeans.modules.git]: (address removed): java.lang.arrayindexoutofboundsexception: 779 java.lang.arrayindexoutofboundsexception: 779 @ com.jcraft.jsch.util.frombase64(util.java:50) @ com.jcraft.jsch.knownhosts.setknownhosts(knownhosts.java:157) caused: com.jcraft.jsch.jschexception @ com.jcraft.jsch.knownhosts.setknownhosts(knownhosts.java:171) @ com.jcraft.jsch.jsch.setknownhosts(jsch.java:184) @ org.eclipse.jgit.transport.jschconfigsessionfactory.knownhosts(jschconfigsessionfactory.java:261) @ org.eclipse.jgit.transport.jschconfigsessionfactory.createdefaultjsch(jschconfigsessionfactory.java:248) @ org.netbeans.libs.git.jgit.jgitsshsessionfactory.getjsch(jgitsshsessionfactory.java:122) @ org.netbeans.libs.git.jgit.jgitsshsessionf

javascript - Unable to fetch actual value from Web SQL database; it's returning undefined -

check code: var db = opendatabase("despesas", "1.0", "despesas db", 2000000); db.transaction(createtbl, errorcb, successcb); function errorcb(err){ alert('error : ' + err.code); } function successcb(){ console.log('db created!'); db.transaction(querydb, errorcb); } function createtbl(tx){ tx.executesql('drop table if exists entries'); tx.executesql('create table if not exists entries (id integer primary key autoincrement, entry text not null)'); } function callpopulate(){ db.transaction( function populatedb(tx){ var userinput = document.getelementbyid('user').value; tx.executesql('insert entries (entry) values (?)', [userinput]); //tx.executesql('insert entries (entry) values (&qu

Can I enforce SQL Server explicitly NOT to CACHE my query result set? -

is there explicit command or to enforce sql server not 'cache' query results ? i working on performance issue , when long query finished on 2nd call takes fast, in order compare query performances when make modifications, want behavior not take place. is possible? you doing wrong. use precise measurements instead: enable set statistics io on , set statistics time on , compare queries. @ number of logical reads queries have, driving factor improve performance. if force cold cache (which possible) optimizing wrong case, since times production server warmed , serving data form buffer pool. also fact seeing significant io driven query first time clear indication of table scans. query rewrite may help, real problem more missing indexes , that's should focus on.

java - How to extract XML nested tags from Soap object? -

here requirement, i getting response server soap object, converted string format, want extract xml data, how can extract nested tags? can extract data or need parse xml response? there way extract xml nested tags , parse arraylist<> post class? <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <maintag> <item> <name>androidpeople</name> <website category="android">www.androidpeople.com</website> </item> <item> <name>iphoneappdeveloper</name> <website category="iphone">www.iphone-app-developer.com</website> </item> </maintag> .. if possible how? thanks in advance. i saw possible use , how private static show getshowfromrss(context context, document feed, string feedurl) { try { // there should 1 channel in feed, it. // also,

python - parsing of xml to mysql database -

in app,i including function called xml parsing.i trying data data xml file , save mysql database. i coded google engine,but required data's not saving in database.i can run app without error. please see codes below views.py def goodsdetails(request): path = "{0}shop.xml".format(settings.project_root) xmldoc = open(path, 'r') xmldocdata = xmldoc.read() xmldoctree = etree.xml(xmldocdata) items in xmldoctree.iter('item'): item_id = items[0].text customername = items[1].text itemname = items[2].text location = items[3].text rate = items[4].text shop=shop.objects.create(item_id=item_id,customername=customername, itemname=itemname,location=location,rate=rate) shop.save() shops = shop.objects.all() context={'shops':shops} return render(request,'index.html', context) i using above logic save data in database xml file.i not getting er

iphone - iOS project shows linker error for i386 -

Image
today tried integration of urbanairship in ios project. got linker error saying -logging not found i386 architecture. so removed i386 architecture lib. lipo -remove i386 libuairship-1.4.0.a -output libuairshipnew then got lots of linker error i386 after adding this. why still checking i386 ? used ios in valid architecture. how can remove dependency i386? updates 1: sorry confusion, need i386 run in simulator. how can fix original problem - undefined symbols architecture armv7: "_logging", referenced libuairship-1.4.0.a update 2: finaly got solution hit https://support.urbanairship.com/customer/portal/questions/3170-push-api-libuairship-1-4-a-missing-required-architecture-i386 removed line: extern bool logging; , line around line 32: if (logging) { \ to: if (1) { \

c# - Razor/Javascript, best practice -

im pretty new mvc-razor , left code thats abit confusing me. i have model in view , model create list. @for each item in model @<li><a href="#" data-id="itemone">click me</a></li> i have javascript makes bindning; $("a[data-id]").click(function(e) { $( "#popup" ).dialog({resizable: false, width:800, height: 400, title: "" }); }); and populate static window; <div id="popup" title="popup"> <h1>mypopup<h1> </div> all code in 1 view i want populate window of models-item-data (ie, item click on gives me popup items data) , have come locked mindset, idea have kind of open razor variable model data, loop through items create equal amounts of pop-up-window given identifier, when javascript called use variable there. feel stupid. there easy (better looking)way solve problem? you use ajax. have real an

jquery - How can I setDraggable(false) on layer by name -

i have problem in program. want setdraggable of layer false. have no idea how set it. created layer when user clicks button. , layer has different name. name of layer set "abc"+i. variable increment. i'm using jquery-1.8.3.js, jquery-ui.js, , kinetic-v4.3.2-beta.js. document.getelementbyid('computer').addeventlistener('click', function(e) { draw(images); layer.add(img); stage.add(layer); i++; }, false); and here code of function draw function draw( images ) { img = new kinetic.rect({ x: 50, y: 150, width: 50, height: 50, fillpatternimage: images.abc, name: "abc"+i, draggable: true }); } then when user double click on layer, dialog box appear. , saved name of layer variable name. layer.on( 'dblclick', function(evt) { var shape = evt.shape; name = shape.getname(); $( "#dialog-form" ).dialog( "open" ); }); $( "#dialog

c++ using vector of employee pointers -

i have created vector class template , have done employee classes of hourly , salaried. want use vector of employee pointers instead of array of employee pointers, i'm trying when run breaks while have no error listed. also, have used at function like( payroll.at(i)->writefile(out); ) access element, don't know what's wrong. suggestion? thanks here code: myvector class template: #include <iostream> #include <string> #include <cassert> #include <algorithm> const int capacity = 4; template <class t> class myvector { public: myvector(); myvector( int size); myvector( int size, const t & initial); myvector(const myvector<t> & v); ~myvector(); int capacity() const; int size() const; void push_back(const t & value); //t & operator[](unsigned int index); myvector<t> & operator=(const myvector<t> &); void clear(); t at(int i);

javascript - Selection making a field mandatory -

i new javascript , have been doing university assignment based around creating form in html , javascript. in assignment have been asked make field mandatory based on whether specific option chosen in previous drop-down box. if 'uws student' or 'uws staff' selected drop-down list field 'student number/staff number' becomes mandatory otherwise not mandatory field if 'uws student' or 'uws staff' selected field 'institution/company' must automatically filled in 'university of western sydney' here segment have been using: <b>registration category:</b> <select> <option value="uws student">uws student</option> <option value="student @ institution">student @ institution</option> <option value="uws academic">uws academic</option> <option value="other uws staff">other uws staff</option> <option value="academic inst

How can I parse the JSON string output from HTTP POST in iOS -

i send parameters using post method server , there got response , store in string "serverresponse" .this server response stored in string { "caridentifier":[ {"carid":"91"}, {"carid":"93"}, {"carid":"114"}, {"carid":"117"} ] } i have separate json parsing code,but dont know how can give input json parsing codes. following json parsing code -(void)getcarlist:(nsstring *)serverresponse { dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_high, 0), ^{ nsobject *recommendedcarjson = nil; nsdata *recommendedcarsdata = [nsdata datawithcontentsofurl:[nsurl urlwithstring:serverresponse]]; nslog(@"%@",recommendedcarsdata); if(recommendedcarsdata) recommendedcarjson = [nsjsonserialization jsonobjectwithdata:recommendedbooksdata options:nsjsonreadingmutablecontainers error:ni

ruby - Why images are not showing in my rails basic app -

Image
my index.html.erb code - <h1>listing products</h1> <table border="1"> <% @products.each |product| %> <tr> <td><%= product.title %></td> <td><%= product.description %></td> <td><%= image_tag(product.image_url, :class => 'list_image') %></td> <td><%= product.price %></td> <td><%= link_to 'show', product %></td> <td><%= link_to 'edit', edit_product_path(product) %></td> <td><%= link_to 'destroy', product, method: :delete, data: { confirm: 'are sure?' } %></td> </tr> <% end %> </table> <br /> <%= link_to 'new product', new_product_path %> and images under app\assets\images ..but still images not appearing on front end. when firebug it, believe image tag correctly forming...let me know missing in part

oracle10g - NHibernate generator for a property value (either from a sequence or autoincrement) -

i have following nhibernate mapping , corresponding class. mapping works fine. want value of field 'rfpid' auto inserted starting '1'. <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping namespace="ibeam.core.models" assembly="ibeam.core" xmlns="urn:nhibernate-mapping-2.2"> <class name="rfp" table="est_mrfp" schema="test$tran"> <id name="id" type="long"> <generator class="sequence" > <param name="sequence">test$masters.global_sequence</param> </generator> </id> <property name="rfpid" column="rfpid" type="string" not-null="true" /> <property name="title" column="title" type="string" not-null="true" /> </class> </hibernate-mapping> how can