Posts

Showing posts from February, 2015

Render Prawn pdf and rqrcode display QR with Ruby on rails -

creating ruby on rails web application qrcode display qr code in pdf iam using gem 'rqrcode-with-patches', require: 'rqrcode' gem 'prawn' my post controller show pdf view def show @qr=rqrcode::qrcode.new(request.url) respond_to |format| format.html format.pdf pdf = postpdf.new(@post) send_data pdf.render, filename: "post#{@post.id}.pdf", type: "application/pdf", disposition: "inline" end end end post_pdf class postpdf < prawn::document def initialize(post) super({top_margin: 30, page_size: 'a4', page_layout: :landscape }) @post = post post_id post_title qr_code end def post_id move_down 10 text "post id: #{@post.id}" end def post_title move_down 10 text "post title: #{@post.title}" end def qr_code move_down 10 @qr=rqrcode::qrcode.new(request.url) end end i got error on display pdf, i

osx - Bash script: How to remote to a computer run a command and have output pipe to another computer? -

i need create bash script able ssh computer or machine b, run command , have output piped .txt file on machine how go doing this? list of computers ssh , run command of output append same .txt file on machine a. update: ok went , followed other guy suggested , seems work: file=/library/logs/file.txt ssh -n username@<ip> "$(< testscript.sh)" > $file what need instead of manually entering ip address, need have read list of hostnames coming .txt file , have place in variable substitute ip address. example be: ssh username@variable in "variable" changing each time word read file containing hostnames. ideas how go this? this should it ssh userb@machineb "some command" | ssh usera@machinea "cat - >> file.txt" with commands: ssh userb@machineb <<'end' | ssh usera@machinea "cat - >> file.txt" echo hostname=$(hostname) lastchecked=$(date) ls -l /applications/utilities/disk\ utility

iron router - Meteor: How to implement text search on a collection along with other find queries in Meteor? -

i have app , users can create own private notes. i trying implement search function these notes. notes stored in collection schema: note = threadid: params.threadid date: date userid: user._id, html: params.html in router (using iron-router) use data function return users note data page: notes.find({threadid: @params._id}) then in jade iterate on note , show them each notes +note but want include search function user can search own notes. i want search html field of each note. want filter notes threadid field. basically this notes.find({threadid: @params._id}).search('test', field: {html: true}) which finds notes specific threadid field, , searches html field of notes query term 'test' and once find them, how update page new data? --------------------------------------update ----------------------------------------- so got searching working, loose reactivity on notes. kind of bummer. looking better way this. notes = note

c# - Entity Framework Lazy Loading Does Not Work -

Image
i migrating project ef 4.0 ef 6.0. trying properties navigated entity after insert new entity. code runs without problem in ef 4.0 when try run in ef 6.0 gettin nullreference exception. user entity: public partial class users { public int rid { get; set; } public string name { get; set; } public nullable<int> langref { get; set; } public virtual language language { get; set; } } language entity: public partial class language { public language() { this.users = new hashset<users>(); } public int rid { get; set; } public string name { get; set; } public virtual icollection<users> users { get; set; } } test code: test1entities testent = new test1entities(); users user = new users(); user.name = "asd"; user.langref = 1;//that id refer english record in language entity testent.users.add(user); testent.savechanges(); string lang = user.language.name;//should return "english". language pro

python - Where are flask-peewee's admin files? -

i'm trying deploy website made own server, , done, except admin page flask-peewee has no css styling. css files admin page stored, can serve them apache? if don't know i'm talking about, here's link: flask-peewee admin

Start javascript animation after an image has loaded -

i'm looking way initiate text animation after background image has loaded. specifically, h1 element should animate after div#image-bg has loaded it's background image. i'm using wow.js animate objects , developer's intention initiate movement on scroll. see full site issue exists, it's @ abbyaker.com. here's stripped version of html page: <html> <head> <link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/animate.css"> </head> <body> <div id="container"> <!-- - - - - - - - - - - - - - intro - - - - - - - - - - - - - --> <div id="headwrap"> <div id="image-bg"></div> <div id="intro"> <h1 class="white wow fadeinup" data-wow-duration="700ms" data-wow-delay="400ms">hello</h1>

sbt - How to copy config files as part of packaging for use in deployment? -

i use sbt 0.13.5 build project few config files meant human-edited after deployment. using sbt-native-packager 's stage command builds basic output directory structure deployment. results in bin folder start script , jars in lib folder. great. that leaves text config files should copied conf folder verbatim alonside bin/ , lib/ folders ( not included in jar ). how can copy these configuration files output directory on filesystem (not jars) using sbt? default universal convention copy files/directories under src/univeral/. so, include conf/ directory in distribution, add src/universal/conf , copy configuration files there. credit: this link

Static function variables in Swift -

i'm trying figure out how declare static variable scoped locally function in swift. in c, might this: int foo() { static int timescalled = 0; ++timescalled; return timescalled; } in objective-c, it's same: - (nsinteger)foo { static nsinteger timescalled = 0; ++timescalled; return timescalled; } but can't seem in swift. i've tried declaring variable in following ways: static var timescalleda = 0 var static timescalledb = 0 var timescalledc: static int = 0 var timescalledd: int static = 0 but these result in errors. the first complains "static properties may declared on type". the second complains "expected declaration" (where static is) , "expected pattern" (where timescalledb is) the third complains "consecutive statements on line must separated ';'" (in space between colon , static ) , "expected type" (where static is) the fourth complains "consecutive sta

c++ - how to iterate through boost unordered_map? -

i want iterate through members of unordered map. there many simple examples on web, including on site, , yet none of them compile. apparently examples previous non-standard stl version, old, , new gcc 4.7.2 can't handle them. please not suggest new auto iterator c++11. there day when libraries validated that. until then, want old 1 work. (see below have tried) here test code: #include <iostream> #include <boost/unordered_map.hpp> #include <string> int main(int argc,char *argv[]) { boost::unordered::unordered_map<std::string,int> umap; //can't gcc accept value_type()... //umap.insert(boost::unordered_map::value_type("alpha",1)); //umap.insert(boost::unordered_map::value_type("beta",2)); //umap.insert(boost::unordered_map::value_type("gamma",3)); umap["alpha"]=1; //this works umap["beta"]=2; umap["gamma"]=3; //can't gcc compile iterator

yii2 - How can I call a console command in web application in Yii 2.0 -

i have console command generate user report. want call same web application. using yii 2.0.0 beta version.i tried follow answers given in post how call console command in web application action in yii? since yii 2.0 structure different yii 1.1 ,i errors if try include command/userreportcontroller.php .can guide me on this? you should use extension https://github.com/vova07/yii2-console-runner-extension

haskell - Creating a `State [Int] Int` -

reading through learn haskell , i'm trying construct stack [int] int : ghci>import control.monad.state ghci> let stack = state ([1,2,3]) (1) :: state [int] int <interactive>:58:20: couldn't match expected type `s0 -> (state [int] int, s0)' actual type `[t0]' in first argument of `state', namely `([1, 2, 3])' in expression: state ([1, 2, 3]) (1) :: state [int] int in equation `stack': stack = state ([1, 2, 3]) (1) :: state [int] int how can create stack [int] int ? it depends on you're trying do. state s a newtype kind of function type (specifically s -> (a, s) ), doesn't make sense make state value list. simplified (internal) definition of state looks like newtype state s = state { runstate :: s -> (a, s) } though won't use state constructor directly, illustrate fact state s a value consists of function. you need function updates state in way (which consid

perl - Run Hypnotoad HTTP server to serve up XHTML page -

i having bit of problem serving dot xhtml page using hypnotoad. the xhtml file starts off perhaps not declaring allow hypnotoad display other text when head on localhost port 8080. <?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="http://www.w3.org/1999/xhtml; charset=utf-8" /> <title> index </title> <link rel="stylesheet" href="book.css" type="text/css" /> when open page locally without server in middle renders fine in firefox, when created myapp.pl , stuck in sub-folder name of public serves text on port 8080. any appreciated. i'm not familiar perl, not it's headers thoug

sql server - SQL: How to display the top 10 list of the users name who has the most item? -

i new sql , thought need basics. i want display top 10 users name , amount of users friends. how ? the top 10 list out user has friends count in descending order proble m have no clue how code . app_id user app_friends_id users friends app_id app_friends_id 40 20 40 10 30 30 40 50 there 3 app_id 40 , want display app_id 40 , app_friends_id's total count 3. sorry bad explanation. if understand, can try this: select top 10 app_id,count(app_id) 'count_of_friend' table group app_id order 2 desc the result is: app_id count_of_friend 40 3 30 1

grails - Test UrlMapping Paths for Resource Controllers -

in grails 2.3 , above, there concept of resource controller. however, not seem work asserturlmappings concepts. /foo (resources:"foo") then in url-mappings-report following appears: controller: foo | | /foo | action: index | | /foo/create | action: create | post | /foo | action: save | | /foo/${id} | action: show | | /foo/${id}/edit | action: edit | put | /foo/${id} | action: update | patch | /foo/${id} | action: patch | delete | /foo/${id} | action: delete however, in following file, urls cannot tested: @testfor(urlmappings) @mock(foocontroller) class foourireversemappingsspec extends specification { def "ensure basic mapping operations foo uris"() { expect: asserturlmapping(url, controller: expectctrl, action: expectaction) { id = expectid } where: url | expectctrl

eclipse - How to find where a method is used in Java project -

Image
i working on learning project created else. not followed proper coding method (no comments , on). im finding difficult find method used. tried "find" searches particular class im unable answer. im working in eclipse. can please me out. you can select method want find , use "ctrl +h" , references search. i hope can you.

start apache & mysql from desktop script in ubuntu -

on lubuntu 14.04 (desktop) have installed apache web server , mysql server and, because of low ram (only 1024mb), decided remove them startup (with sudo update-rc.d -f apache2 remove , editing /etc/mysql/my.cnf file ). now, every time want development have sudo service apache2 start , sudo service mysql start in terminal. wich fine. my question is: commands executed .sh file? file can double-click desktop? far got #!/bin/sh sudo service apache2 start sudo service mysql start you can scripts mentioned. apache: #!/bin/sh sudo service apache2 start mysql #!/bin/sh sudo service mysql start

vb.net - How do I arrange Items in a List-box? -

i working on vb windowsforms application. form has listbox contains numbers items . not arranged numeric sequence like.. 01 09 02 07 ... i want arrange them numeric sequence such as.. 01 02 07 09 ... i have not got idea doing so. thank you you can use method , call sort function... private sub sortlistbox(byval listbox listbox) dim templist new list(of integer) each li in listbox.items templist.add(integer.parse(li.tostring())) next templist.sort() listbox.datasource = templist end sub then call after have added items... sortlistbox(listbox1)

What are the guidelines for implementing Java Checkstyle checks? -

i newbie static code analysis tools java checkstyle. downloaded checkstyle package , see 2 sets of checks: checkstyle_checks.xml sun_checks.xml . i compared these , geosoft_checks.xml master list of available in checkstyle ...essentially 4 table full outer join see checks included in of 3 sources. checks | source -----------|-------------------------------------------------------- 134.......| all available 75.........| checkstyle_checks.xml ( plus suppressionfilter pointing suppressions.xml ) 63.........| sun_checks.xml 73.........| geosoft_chekcs.xml ( after removing 4 don't work in checkstyle 5.7 ) doublecheckedlocking packagehtml tabcharacter genericillegalregexp i've done analysis on sun_checks , geosoft_checks determine ones can safely remove based on actual findings in code base (of course can come along , violate 1 of many checks not included in either) are there recent guidelines checks include won't unnecessarily frustra

Android MediaController Play/Pause button and Seekbar doesn't Refresh -

i using mediacontroller.mediaplayercontrol in order display mediacontroller @ bottom of custom view can't work properly. when play music first time there should pause button visible instead there play , when press button music paused correctly , state remains same , after working properly. when play next song, old mediacontroller widget gets overlapped new one. , progress/seek bar doesn't refresh while music playing. updates when on mediacontroller pressed (play/pause, forward, etc). i found these questions similar mine don't think answers got solve problem. android mediacontroller play pause controls not refresh properly android mediacontroller seekbar not refreshing android videoview playback controls show "play" instead of "pause" though file playing this how initialize controller: private void setcontroller() { controller = new musiccontroller(this); controller.setprevnextlisteners(new view.onclicklistener() { @over

Puppet exec log_output equivalent in Chef execute -

in puppet, exec resource has attribute called log_output can define when log output of command (true, false or on_failure). does chef have similar directive or common workaround achieve same result? the output of commands gets logged when log level set debug . easiest way on command line chef-solo , chef-client, -l debug .

java - How wrap json array to custom object with collection via Gson? -

how wrap json array custom object collection containing array via gson? have following json string: [ { "showid":410, "siteid":85, "name":"Майстер і маргарита", "duration":7200, "providerid":1016, "events":[ { "siteid":85, "eventsiteid":0, "providerid":1016, "eventid":1178, "hallid":0, "premiere":false, "origin":"20140912190000" } ] } ] and want deserialize object bellow: public class shows { private list<show> shows; public list<show> getshows() { return shows; } public void setshows(list<show> shows) { this.shows = shows; } } this json message represent

sql server - Convert actual time to float in SQL -

how can convert specific time or actual time, in sql, float number? e.g., if 09:59:57 want float number: 0.416634556 in excel. thank all. take @ this, may find answer here: cast , convert (transact-sql) select cast(convert(datetime, col1) float) newvalue table1

python - Why is stack_data() returning an empty array? -

i have following functions defined. reason, stack_data() returns empty array , cannot figure out why. have suggestions? general suggestions on improving coding style, form, readability, etc. helpful. general debugging tips great too. example of should happening: input: print(stack_data(np.array([[1,1,1,2,2,2,3,3,3],[4,4,4,5,5,5,6,6,6],[7,7,7,8,8,8,9,9,9]]), 0.33)) output: [4,1,4,2,2,3,4,4,4.5,7,7,7.5,9,9] def _fullsweep_ranges(spec_data): start = [x x in range(0,len(spec_data[:,1])) \ if spec_data[x,1] == spec_data[:,1].min()] stop = [x x in range(0,len(spec_data[:,1])) \ if spec_data[x,1] == spec_data[:,1].max()] return zip(start,stop) def _remove_partial_fullsweeps(spec_data): ranges = _fullsweep_ranges(spec_data) first_min_index = ranges[0][0] last_max_index = ranges[-1][1] return spec_data[first_min_index:last_max_index+1,:] def _flatten_data(spec_data): row = 0 flat_data = [] running = false whil

.net - Limit the maximum process-instances by counting the amount of Mutexes? -

i've written next code prevents multi-instancing via mutex , extend funcionality allowing set maximum number of allowed instances, should decide whether want allow single instance or multi-instace of 3 instances (for example). i've tried figure out how count amount of mutexes of process, didn't find about. by other hand i've found lot of posts in stackoverflow explaining how count amount of processes it's filename, i'm not interested in of 'cause i've choosed mutex detection me more secure. someone me in whim?. this have done: namespace partial friend class myapplication #region " properties " ''' <summary> ''' gets current process mutex identifier. ''' </summary> ''' <value>the current process mutex identifier.</value> ''' <exception cref="system.formatexception">the specified value n

mandrill - how to send transactional emails using mailchimp -

i new mail chimp please me integrate transnational emails using mail chimp , mandrill.better provider example integration code. thanks you don't mention trying achieve. in general, don't want use mailchimp - want focus on mandrill. mailchimp when have existing list of users , want send emails or of them @ same time - such newsletters. mandrill when need send 1 user (or small group of users) occasional emails notification purposes - such alerts, receipts, acknowledgements, etc. assuming have application sends emails users via smtp, can integrate mandrill changing smtp server settings in application use mandrill smtp settings, can find @ top of smtp & api credentials page in mandrill admin area. alternatively, if need send programatically, refer documentation on api wrappers started.

c# - Change background button color on click -

i'm developing windows phone 8 app , have 2 buttons. once click on first 1 it's color changed, when click on second 1 , color changed color of first button not set default. can't access first button click event of second one. how can highlight 1 button , set color of 1 default on click? edit: here can't access second button within first event handler. private void firstbutton_click(object sender, routedeventargs e) { (sender button).background = new solidcolorbrush(colors.green); } private void secondbutton_click(object sender, routedeventargs e) { (sender button).background = new solidcolorbrush(colors.green); } why can't access first button second one? similar this: private void firstbutton_click(object sender, routedeventargs e) { (sender button).background = new solidcolorbrush(colors.green); secondbutton.background = new solidcolorbrush(colors.lightgray); } private void secondbutton_click(object sender, routedeventargs e

Do Spring transactions propagate through new instantiations -

i'm working on bunch of legacy code written people before me , i'm confused particular kind of setup , wonder if has ever worked begin with. there managed bean in spring has transactional method. @transactional(propagation = propagation.requires_new, rollbackfor = throwable.class) public boolean updatedraftandlivepublicationusingfastdocumentsofmysite(list<fastdocumentlite> fastdocumentlites, long mysiteid) throws exception { ... } now inside method find new instantiations calling update methods fe: boolean firstfeed = new mysiteidupdate(publishing, sitedao, sitedomainservice).update(siteid, fastdocumentlites.get(0).getmysiteid()); from understanding on ioc new class isn't managed spring , it's variable in bean. going further inside update method see service gets called. @transactional(propagation=propagation.required, rollbackfor=throwable.class) public void activatesubdomainforsite(long siteid, boolean activationofsite) so if there tra

codeigniter - HTML button loop -

Image
hello guys i'm trying figure out how can add more textboxes clicking add button. i'm using codeigniter framework here view: <form action="save_new_inventorytype" method="post"> <fieldset> <legend>add new inventory type</legend> <label id="lbl_tablename" name="lbl_tablename">inventory type name:</label> <input type="text" id="txt_tablename" name="txt_tablename" size="30" /><br> <label id="lbl_columns" name="lbl_columns" style="position: absolute; top: 276px;">column name:</label> <label style="position: absolute; top: 276px; left: 352px;">type:</label> <label style="position: absolute; top: 276px; left: 565px;">length/values:</label><br> <br> <input type="text" id="

r - An equivalent of xpd=TRUE for ggvis -

i playing ggvis , came following code: library(ggvis) mtcars %>% ggvis(~disp, ~wt) %>% layer_points() %>% scale_numeric("x", domain = input_slider(50, 500, c(100, 400)), nice = false) %>% scale_numeric("y", domain = input_slider(0, 6, c(1, 5)), nice = false) this enables me dynamically resize plot. problem when resizing of data points plotted outside range. there option xpd=true base r graph clip plotting region, data points not in range of axes not plotted?

mysql - Show all rooms and reservation -

i have 3 table type (id, libel) bedroom (id, name, type) reservation (id, name, libel, start_date, end_date, room) i want make application rooms , reservations between 2 dates. have following query $sql = 'select r.id, r.name, r.start_date, r.end_date, r.libel, r.statut ,c.name room, t.libel type ' . 'from type t inner join bedroom c on t.id = c.type left join reservation r on c.id = r.room' . 'where ( :start_date between r.start_date , r.end_date ' . ' or :end_date between r.start_date , r.end_date' . ' or r.start_date between :start_date , :end_date' . ' or r.end_date between :start_date , :end_date) order c.'.$ordercolumn.' asc'; but appears rooms reserved between start_date , end_date. $sql = 'select reservation.*, bedroom.*, type.* reservation ' . 'right join bedroom on reservation.room = bedroom.id ' . 'inner join type on

VB.Net XSLT transformation for converting single xml file to multiple html file -

i have designed xslt2.0 file transform single xml file multiple html files. have succeeded in transformation using xslt tools, looking vb.net code perform above transformation. me in regard, in advance. -hari microsoft not provide xslt 2.0 processor in .net framework need use third party solutions .net version of saxon 9.5 or xmlprime. see http://www.saxonica.com/documentation/index.html#!dotnet/dotnetapi api of saxon on .net , see http://www.xmlprime.com/xmlprime/doc/2.9/using-xslt.htm api of xmlprime.

git - Can I commit and push in Java from within the code? -

i have program automatically updates files website , periodically uploads them well. in past, uploaded files through ftp pretty simple , worked okay . i have since moved github pages, , syncing website through github program manually simple, have no idea how automate within own program. is possible update website within code, , if so, how go doing that? use library (called jgit): http://www.eclipse.org/jgit/

javascript - ZeroClipboard and RequireJS - ZeroClipboard is not defined -

i'm attempting use zeroclipboard inside angularjs/requirejs application. i have put zeroclipboard.js location /assets/js/vendors/zeroclipboard.js i have set main.js of requirejs application main.js requirejs.config({ paths: { jquery: 'vendors/jquery.min', 'clipboard': 'vendors/zeroclipboard', underscore: 'vendors/underscore-min', angular: 'vendors/angular.min', 'angular-route': 'vendors/angular-route.min', 'controllers': 'controllers', 'services': 'services', 'filters': 'filters', 'directives': 'directives', 'app': 'app' }, shim: { underscore: { exports: '_' }, 'jquery': { 'exports': 'jquery' }, 'angular': { exports: 'angul

What is the difference between concepts Custom Task and Enhanced Task in Gradle? -

i meet in gradle documentation these concepts. difference between them? from know custom task class encapsulates logic, enhanced task , difference between them? a simple task in gradle instance of defaulttask , not out of box. make have add code task definition in build script. an enhanced task instance of different class (for example copy task instance of copy ) , has behaviour out of box. need configure behaviour in build script (eg tell copy , to) a custom task enhanced task instance of class wrote yourself.

authentication - As an authorized user on a site with Wordpress? -

have site on wordpress. in short: need authenticate user site without using function in wordpress. user authorization did so: $time = time() + 2 * 86400000; $data = 'adminjdwd|'.$time; $key = '$l*gvjdckiub;.sj<code>=tpvo)mykm%lbh{<e?b3_%$l2eqwo2z/iukc|&fbo|</code>mq>e'; $salt = 's[rr@?wa7k]qmdboi9e?k<code>mdrpg+1!w?&u)devf-p^0h;od6.x+xbdygf4^l:y</code>c'; $key = hash_hmac('md5', $data, $key.$salt); $hash = hash_hmac('md5', 'admin|'.$time, $key); $cookie = 'admin|'.$time.'|'.$hash; setcookie('wordpress_logged_in_'.md5('http://wp.ru'),$cookie,$time,'/','.wp.ru'); user authorizes no problems, if user administrator, control panel not let me. cookies register authorize administrator? there separate cookie /wp-admin pages. i'm not sure how admin cookie constructed, should in right direction. try: setcookie('wordpress_'.md

git - how to redo bad merge but keep some of my later commit? -

the history this: a<───┬─ badmerg <── c <── d b<───┘ now realized conflict resolution in merge bad. want redo merge again, keep commit c , d. how can this? the easiest end riskless way comes mind is: 1 - create new branch named "backup" on commit d not checkout branch. stay on current one. 2 - hard reset current branch either commit or b (pick if want merge b a) 3 - merge b 4 - cherry pick c , d 5 - if good, delete backup branch.

embed - doxygen with embedded graphviz uml diagrams -

i embed own diagrams in doxygen documentation. possible create own diagrams using graphviz textual description inside sourcecode? yes, have @ \dot command. note can include message sequence charts via \msc . dia files using \diafile , of release 1.8.8 plantuml diagrams via \startuml ... \enduml block.

wpf - What type of c# project should an SSDT model be placed in? -

sorry if totally noob question can't seem find starting point on this. from i've gathered far ssdt developed idea used in different project that of main app database related coding. figured instead of complaining how old version back, i'd try things way , see how goes can't seem handle on begin on here. basically want use code first approach , create database designer. if i'm going create new project handle entity framework, type of project should be? c# class library, wpf.. else? i'm not sure if it's of relavance app i'm working on wpf app , database mysql. if want use code-first approach, means database generated code. thus, not have separate database-project, since mean database kept in 2 places. therefore, options are: use code-first. means class library (although asp.net mvc has context entities in asp.net mvc project, let's call exception rule). class library contain classes database generated. use database project, ssdt

c# - How to pass argument to Event Handler in Xamarin IOS -

how pass string argument eventhandler? viewcontroller(a) written event handler public event eventhandler valuechanged; void responsecompleted(object sender, commoncode.responseeventargs e){ this.invokeonmainthread (delegate { if (valuechanged != null) { valuechanged (this, new eventargs (e.responsedata)); // e.responsedata string datatype. } }); } viewcontroller(b) relateddatasource.valuechanged += delegate { response data viewcontrollera } you can use generic eventhandler. example: public event eventhandler<string> valuechanged; void responsecompleted(object sender, commoncode.responseeventargs e){ this.invokeonmainthread (delegate { var handler = valuechanged; if (handler != null) handler(this, e.responsedata); }); } relateddatasource.valuechanged += (s, responsedata) => { //your data in responsedata variable }

c# - How to create at runtime a .NET exe file assembly from already compiled classes -

i need create executable file assembly @ runtime. main goal compile types actual project (.dll) performing compilation task, without using strings keeping code needs compiled output exe file. maintaining strings during code development/refactoring nightmare. shown in example below, when refactor class codetocompile, need remember change string codetocompile in runtimecompiler.compile() method: using system; using system.codedom.compiler; using microsoft.csharp; namespace runtimecompiler { public class compiler { public void compile() { string codetocompile = @"public class codetocompile { public static void main(string[] args) { console.readline(); } }"; csharpcodeprovider codeprovider = new csharpcodeprovider(); icodecompiler icc = codeprovider.createcompiler(); co

jquery - unrecognized expression a[href=javascript:void(0)] -

i'm used jquery 1.10.2 , on 1 page there error uncaught error: syntax error, unrecognized expression a[href=javascript:void(0)] in developer tools show error in first line jquery library instead of: $('a[href=javascript:void(0)]'); you need add quotes surrounding value of attribute: $('a[href="javascript:void(0)"]');

Artificial intelligence application development in PHP -

i new ai development , looking guide line start. i'm php developer , if 1 have experience ai developing in php, please help. prefers ai related libraries , etc... to develop ai applications, php seems not best choice. script language intended create websites etc., not to, e.g., steer robot. of course can use php learn concepts, makes sense switch want create "serious" applications related topic. to topic, recommend udacity course "intro articial intelligence", see https://www.udacity.com/course/cs271 - absolutly free take courses. ai not simple topic, interesting. luck , have fun!

c - User error: Reset failed (STM32373 ARM4) -

Image
i using stm32737 mcu , iar ide. i have built own pcb stm32737 interface analog circuit, , bluetooth module. i programming using smd in st-link v2 when try download program mcu, prompt me error: user error: reset failed i have tried on 3 pcb, 2 failed , 1 download success. the fail download reason "reset failed" error message. may know possible cause above failure? info update found stupid problem: schematic design fault. there unwanted component blocking reset voltage. remove component , device ready go.

How to go next page after login successfully using angularJs? -

i have restful api login has written in " laravel php ". have use restfull api angularjs. , after getting login response, new page should open, doing using " ngroute ", not able properly. can tell how can this. here code: var qaapp = angular.module('qaapp', ['ngroute', 'emoji', 'ngsanitize']); //route provider 1 page page qaapp.config(function($routeprovider , $locationprovider) { $routeprovider. when('/', { templateurl: 'login.html', controller: 'loginctrl' }). when('/login', { templateurl: 'qa.html', controller: 'askbyctrl' }). otherwise({ redirectto: '/' }); }); login controller: function loginctrl($scope, $http, $location){ // create blank object hold our form information // $scope allow pass between controller , vi

android - Opening app on notification click? -

i open app when user clicks on notification , if not in foreground. so far got this: private void adnotification(ad ad) { pendingintent dummyintent = pendingintent.getactivity(this, 0, new intent(), intent.flag_activity_new_task); intent notificationintent = new intent(this, splashscreen.class); store storefromad = ad.getstorefromad(); notificationintent.putextra("uzlet", new gson().tojson(storefromad)); pendingintent contentintent = pendingintent.getactivity(this, 0, notificationintent, pendingintent.flag_cancel_current); mnotificationmanager = (notificationmanager) this.getsystemservice(context.notification_service); notificationcompat.builder mbuilder = new notificationcompat.builder(this).setsmallicon(r.drawable.icon).setautocancel(true).setcontenttitle(ad.ad_title) .setstyle(new notificationcompat.bigtextstyle().bigtext(ad.ad_text)).setcontenttext(ad.ad_short_text); mbuilder.setcontentintent(dummyintent); //checks

Synchronous HTTP call in Scala -

i need perform single synchronous http post call: create http post request data, connect server, send request, receive response, , close connection. important release all resources used call. now doing in java apache http client. how can scala dispatch library ? something should work (haven't tested though) import dispatch._, defaults._ import scala.concurrent.future import scala.concurrent.duration._ def postsync(path: string, params: map[string, any] = map.empty): either[java.lang.throwable, string] = { val r = url(path).post << params val future = http(r ok as.string).either await.result(future, 10.seconds) } (i'm using https://github.com/dispatch/reboot example) you explicitly wait result of future, either string or exception. and use like postsync("http://api.example.com/a/resource", map("param1" -> "foo") match { case right(res) => println(s"success! result $res") case left(e) =>

javascript - Rename button text having no id -

Image
i have html as: <div class="k-button k-upload-button"> <input id="files" name="files" type="file" data-role="upload" autocomplete="off"> <span>select files...</span> </div> above html text (tags) cant change. i want change text : select files... to : select file for tried: $(".k-button.k-upload-button").find("span").text("select file"); but did not worked. please me. how can change text??? edit1: .k-upload-button span:before { content: 'select file'; position: relative; left: 4444px; display: inline; } .k-upload-button span { position: relative; left: -4444px; display: inline; } css solution the span removed viewport , pseudo child put in place. have example! css .k-upload-button span { position: relative; left: -9999px; } .k-upload-button span:before { content: 'select f

Empty all XML-nodes of a certain type using C# -

i have xml document built using following structure: <a> .... <b> <c> </c> <d> .... </d> </b> </a> <a> .... i parse xml document using c# , output document in b-nodes emptied, without losing b-node. creating following result: <a> ... <b /> </a> <a> ... can show me way this? linq xml make pretty simple: var doc = xdocument.load(...); var bs = doc.descendants("b").tolist(); foreach (var b in bs) { b.replacenodes(); } (use replaceall instead of replacenodes if want remove attributes within b nodes well.)

Edit and add. Contents of a JSON file in Java -

so have found few previous topics on how none of them made sense me. wondering if explain how edit , add following: { "users": { "account1": { "name": "username1", "id": "user1id", "shown": "do show" }, "acount2": { "name": "username2", "id": "userd2id", "shown": "do show" }, }, "selectedaccount": "account1", i wish add new account accounts 1 , 2. wish change selectedaccount's value. any appreciated. so i'm still needing this, doing: jsonobject jsonobj = new jsonobject(sb.tostring()); jsonobject profiles = jsonobj.getjsonobject("users"); jsonobject jsonattribute = new jsonobject(); jsonattribute.put("name", "username0"); jsonattribute.put("id", "user0id&q

android - DDMS has blank screen -

Image
when last used ddms android studio tried open *.hprof file, whole screen changed blank. now screen blank. reinstall android studio, eclipse , of course sdk, no effect. can tell me how reapir it? thank you i had problem too, , arrived @ same way (trying open heap dump *.hprof file). resetting perspective not work. how fixed it: go .android folder in home directory there should monitor-workspace folder; move backup directory (or delete it) restart ddms

bit manipulation - Move integer to the nearest divisible by 4 in C++ -

i'd move integer nearest 'divisible 4' number in c++, not if number divisible 4. here's best attempt, i'm sure suboptimal: offset = (offset & 3) ? (offset | 3) +1 : offset; there must surely fast way of doing doesn't include tertiary if statement? additional note: in case offset 32-bit int. offset = (offset + 3) & ~(decltype(offset))3; or #include <type_traits> // ... offset = (offset + 3) & ~static_cast<std::remove_reference<decltype(offset)>::type>(3); if need support possibility offset reference type, such size_t& . @baummitaugen. it seems work when offset wider int without type cast, offset = (offset + 3) & ~3; , uncertain whether or not mandated language standard. this algorithm can described in english "add 3 round down". the rounding down part done setting 2 least significant bits 0 binary arithmetics. unsetting of bits done applying binary , inverse bit pattern, i

python - Depth buffer does not work on Android, but does work on Linux (using Kivy) -

Image
i wrote simple example of problem. from kivy.app import app kivy.uix.widget import widget kivy.core.window import window kivy.resources import resource_find kivy.graphics.transformation import matrix kivy.graphics import * kivy.graphics.opengl import * import random class root(widget): def __init__(self, *larg, **kw): super(root, self).__init__(*larg, **kw) self.vertices = [[-1,-1, 0, 1,-1, 0, 1, 1, 0, -1, 1, 0]] kw['shader_file'] = 'shaders.glsl' self.canvas = rendercontext(compute_normal_mat=true) shader_file = kw.pop('shader_file') self.canvas.shader.source = resource_find(shader_file) self.canvas: self.cb = callback(self.setup_gl_context) pushmatrix() translate(0, 0, -5) in xrange(10): translate(.5, 0, -.5) self.render(self.vertices, (random.random(), random.random(), random.random())) popmatri

spring data - How to find nearest value using queryDSL JPA -

i want rewrite following sql using querydsl jpa , spring data querydslpredicateexecutor : select * roadobject order abs(positionm - 1000) i've tried this: predicate predicate = roadobjectpredicates.topredicate(filter); // condition... qroadobject obj = qroadobject.roadobject; orderspecifier order = new orderspecifier<>(order.asc, obj.positionm.subtract(1000).abs()); iterable<roadobject> test = roadobjectdao.findall(predicate, order); but throws: java.lang.classcastexception: com.mysema.query.types.expr.numberoperation cannot cast com.mysema.query.types.path edit full stacktrace java.lang.classcastexception: com.mysema.query.types.expr.numberoperation cannot cast com.mysema.query.types.path @ org.springframework.data.querydsl.qsort.toorder(qsort.java:89) ~[spring-data-commons-1.7.1.release.jar:na] @ org.springframework.data.querydsl.qsort.toorders(qsort.java:72) ~[spring-data-commons-1.7.1.release.jar:na] @ org.springframework.data.querydsl.qsort.<i