Posts

Showing posts from March, 2013

python - Ruby on Rails : Dependencies and Nodes -

i have simple problem needs solving. have code sorts out tasks dependant on other tasks. examaple tasks a, b, c, , d. these need sorting in order of dependancies. example, task b can completed after task d done. therefore order of tasks : a d b c i have code in python, there way make code work in rails (as in correct syntax/method) class node: def __init__(self, name): self.name = name self.edges = [] def addedge(self, node): self.edges.append(node) require 'set' class circulardependencieserror < exception end class task attr_reader :name, :depends def initialize(task_name, dependencies=[]) @name = task_name @depends = set.new dependencies end def add_dependencies(*d) @depends.merge d end def <=>(rhs) if depends.include?(rhs.name) , rhs.depends.include?(name) raise circulardependencieserror, "#{name} , #{rhs.name} depend on each other" elsif rhs.depends.include? name

Android Switching Activities Black Screen -

i'm trying start activity in main activity using method: public void switchtoread(){// switches reading view displays text tts engine reads off. intent intent = new intent(getapplicationcontext(),readout.class); intent.putextra("response", res); startactivity(intent); } this starts following class: package com.example.webview; import android.os.bundle; import android.app.activity; import android.app.progressdialog; import android.content.context; import android.content.dialoginterface; import android.content.dialoginterface.onclicklistener; import android.content.intent; import android.speech.tts.texttospeech; import android.text.method.scrollingmovementmethod; import android.view.menu; import android.view.view; import android.widget.button; import android.widget.textview; public class readout extends activity implements texttospeech.oninitlistener, onclicklistener { boolean paused = false; string lefttoread = null; string res = null

javascript - How to generate modal popup of each row creation using datatable js -

i using datatable js in mvc4. want generate modal popup on each row creation when table create data fill , open each modal popup on each radio button click. $('#hotel').datatable({ bdestroy: true, bprocessing: true, sajaxsource: '@url.action("selecthotel_tripinfo", "cl_invoices")', aocolumndefs: [ { atargets: [0], "mrender": function (data, type, full) { newhotel(full[0]); return "<input id='btnresp' type='radio' class='open-addrespdialog btn btn-primary' data-toggle='modal' data-target='#examplemodal1' data-whatever='' data-id=" + data + ">"; }

javascript - Ajax won't call Codeigniter controlllers's method -

i'm total beginner ajax (don't know jquery @ all) i've been using simple ajax without jquery, want simple call codeigniter's controller method. dont know i'm wrong at. here's ajax function , controller: function usernameonchange() { var username = document.getelementbyid("register_username").value; if (username.length == 0) { document.getelementbyid("usernameglyph").classname = "glyphicon glyphicon-remove"; return; } else { var xmlhttp = new xmlhttprequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid("usernameglyph").classname = 'glyphicon glyphicon-ok'; } }; var link = "<?php echo base_url("index.php/test/checkusername?username="); ?>" + username

c# - Entity framework 6: referring to UserProfile -

i trying write asp mvc app custom dbinitializer, i'm getting error: additional information: member identity 'mailmail.models.maildbcontext.video_userprofile' not exist in metadata collection. i have video class: public class video : entity { public string name { get; set; } public string path { get; set; } public virtual userprofile userprofile { get; set; } } and dbinitializer: public class maildbinitializer : dropcreatedatabasealways<maildbcontext> { protected override void seed(maildbcontext context) { userscontext usercontext = new userscontext(); if (!webmatrix.webdata.websecurity.initialized) { websecurity.initializedatabaseconnection("defaultconnection", "userprofile", "userid", "username", autocreatetables: true); } var mongol1 = new { email="mail2@mail", username="tom"

Overloading Operator [][] c++ -

this question has answer here: operator[][] overload 15 answers let there class : template <class a_type,int sizea,int sizeb> class matrix { a_type mymatrix[sizea][sizeb]; int sizea_val; int sizeb_val; public: matrix(); matrix(a_type val); int getsizea()const{return sizea_val;} ; int getsizeb()const{return sizeb_val;}; a_type mini() const; double avg() const; matrix operator+(const matrix& b) { matrix<a_type,sizea,sizeb> tmpnew; (int i=0;i<sizea;i++){ (intj=0;j<sizeb;j++){ tmpnew[i][j]=mymatrix[i][j]+b[i][j]; } } return box; } }; it working exept matrix operator+(const matrix& b) function i want work co want create operator [][], possible? i want example if see

hadoop - Where moved to trash files go? -

Image
i have following questions regarding "move trash" functionality in hue gui: where these files go? how long stored? can restore them? 1) /user/hduser/.trash hduser unix(operating system user, can windows user if using java client windows + eclipse ) user. 2) depend on below configuration in core-site.xml <property> <name>fs.trash.interval</name> <value>30</value> <description>number of minutes after checkpoint gets deleted. if zero, trash feature disabled. </description> </property> 3) doing recovery method trash should enabled in hdfs. trash can enabled setting property fs.trash.interval (as above mentioned xml) greater 0. by default value zero. value number of minutes after checkpoint gets deleted. if zero, trash feature disabled. have set property in core-site.xml. there 1 more property having relation above property called fs.trash.checkpoint.interval . number of minutes between tra

Are HTML buttons with no values submitted in a form? -

if have <button class="button yellow" type="submit" name="button">log in</button> and submit it, gets posted server button has name no value attribute? the reason ask i'm parsing html forms, , need post named values send data server. got others covered, wasn't sure button. according html spec , button's value either determined value attribute or empty string. button's value submitted form if button has name , used initiate form submission. if button in example clicked, resultant submission be: "button=" (quotes added) some browsers (mainly older ie versions) have incorrect implementations of button behaviour either set value button's contents or submit button values regardless of initiation source.

c++ - Access member of returned struct in boost lambda/phoenix -

i want replace older code simpler, functor based code. don't want introduce functor class , use boost::lambda/phoenix don't have c++11 @ hand. old code looks this int player = ...; point middlept = ...; for(point pt=<magic nested loops>) if(this->ismilitarybuilding(pt) && (this->getnode(pt).owner == player + 1)) return true; return false; i have function calls functor every point (encapsulating magic) , returns true when of calls returns true: template<class functor> bool checkpts(point middlept, functor f); translating first part of if easy: return checkpts(middlept, bind(&ismilitarybuilding, this, _1)); and 2nd i'd want like: bind(&getnode, this, _1).owner == player+1 not supported. what readable way of doing this? think might solvable binding reference this , calling functions directly using phoenix lambda did not found references go beyond simple 'hello world' lambdas accessing simple member or param

mysql - multiple nested callback functions before parent's callback in javascript -

im using expressjs , mysql package. have user table, each user have many skills, projects, certifications stored in different tables. how can of these data single user object. getuserdatabyid(req.params.id, function (user) { if (user) { res.send(user); } } var getuserdatabyid = function (id, callback) { connection.query(usersql, id, function (err, rows) { if (rows[0]) { user = new user(rows[0]); //parse row data user obj // main problem //get skills , projects.... , asign user obj parsearraydata(skillsql, user.id, skill, function (skills) { user.skills = skills; } ); parsearraydata(projectsql, user.id, project, function (project) { user.projects = projects; } ); // here callback(user); } }); } var parsearraydata = function (query, id, obj, callback) { connection.pool.query(query, id, function (err, rows) { if (err) { throw err; } else { conso

javascript - $setValidity not working -

i have condition if user enters either contact number or email form should considered valid, make work tried use $setvalidity not working, below code: if($scope.contact.contactnumber || $scope.contact.email) { $scope.addcontactform.contactnumber.$setvalidity('required', false); $scope.addcontactform.email.$setvalidity('required', false); // in console show invalid true & valid false console.log('scope:', $scope.addcontactform); } it because doing wrong. should pass true second argument if want set field valid state. read documentation . below example how use $setvalidity correctly. angular.module('app', []); angular.module('app').controller('example', function () { this.setvalid = () => { this.form.contactnumber.$setvalidity('required', true); this.form.email.$setvalidity('required', true); }; this.setinvalid = () => { this.form.contactnumber.

mysql - Search by month and day mqsql -

i have table messages column date (format datetime) how can search messages date = xxxx-05-09 ? select * messages date = 'xxxx-05-09'; try this: select * messages extract(month date) = 5 , extract(day date) = 9;

Learning sources for UWP (Universal windows platform) -

can give me learning sources uwp app development? use "windows 10 development absolute beginners" series on channel9. it's not going in depth. i'd learn more anatomy of uwp apps , more advanced topics. i recommend looking @ mva courses on topics , level need. this one comprehensive course. can pick modules of interest - note updated in aug 2015 , things might have changed in meantime. there plenty of other resources can @ after that.

Magento custom pricing rule -

i need custom pricing rule can used fixed quantities. need apply discounts groups of items in cart. think custom salesrule way go need collection of products in cart instead of single product. ideas? edit to clarify, need able have 2 particular items within specified category have discount applied. let's call them product , product b. quantity of product , product b must sum specified number in shopping cart rule, example, 100 (quantity 50 product , quantity 50 product b typically). rule need apply applied products/sets of products/the cart multiple times, e.g., product c , product d should have discount applied if quantities sum 100. product a/b added cart again quantity not qualify discount, i.e. quantity < 100. use "shopping cart price rules" under "promotions" use combination of "conditions" , "actions" use "conditions" determine when rule start. use "actions" determine items apply rule to.

html - CSS3 transition on matrix transformation with jQuery on FF/Chrome -

i've written simple little transition animation on page load should reveal content little opening of window blind. uses combination of css3, set transition values, , jquery apply change transform: matrix values on page load. works fine in safari, life of me can't grasp why transition effect doesn't work on ff or chrome. in both browsers, 'blind' disappears reveal content after transition display, rather transitioning out in 4 vertical strips should. code below, i've put fiddle here (which, works in safari, can see sort of effect i'm expecting): https://jsfiddle.net/ebenezer66/783uh6k3/ the basic html: <div class="home__columnshades__div"> <div class="home__columnshades__div__column"> <div class="home__columnshades__div__columnone"></div> </div> <div class="home__columnshades__div__column"> <div class="home__columnshades__div__columntwo">&l

python - What happens when a spark dataframe is converted to Pandas dataframe using toPandas() method -

this question has answer here: requirements converting spark dataframe pandas/r dataframe 1 answer i have spark dataframe can convert pandas dataframe using topandas() method available in pyspark. i have following queries regarding this? does conversion break purpose of using spark itself(distributed computing)? the dataset going huge , speed , memory issues? if can explain ,what happens 1 line of code,that help. thanks yes, once topandas called on spark-dataframe out of distributed system , new pandas dataframe in driver node of cluster. and if spark-data frame huge , if doesnt fit driver memory crash.

ios - Swift Admob Interstitial Not Properly Dismissing Fully -

i added admob interstitial ads swift spritekit app. problem is, when interstitial ad dismissed, seems make own banner ad , place @ bottom of screen. won't go away , can't make go away. i have banner ad on menu scene displays on scene, , using prints have confirmed different banner. the problem banner blocks game , vital ui in store. need fixed, made way onto live version of app if has clue going on please post. reference, if need see app here link in app store. (and no, i'm not posting link try , earn $0.01 advertisements you.)

java - getPreferredSize() works on JFrame; why doesn't it work on Frame? -

Image
i hope problem confuses me. i tested getpreferredsize() on frame , on frame . in frame , getpreferredsize() returns 0 (both width , height), while in frame , returns non-zero numbers, working. i not sure part of coding in nolayout() method such getpreferredsize() returns 0, , ispreferredsizeset() returns false , implies preferred size not set. why not set? can help? thanks. below codings of simple test program. import java.awt.*; import javax.swing.*; public class test { public test(){ jframe frame = new jframe("absolutelayoutdemo"); frame.setdefaultcloseoperation(jframe.exit_on_close); container p = frame.getcontentpane(); p.setlayout(null); jbutton b1 = new jbutton("one"); p.add(b1); dimension size = b1.getpreferredsize(); system.out.println("size width "+size.width+" height "+size.height); jlabel label2 = new jlabel("text-only label"); p.add(label2); size = label2.getpr

sending "GET" request over proxy using httplib in python -

i trying send basic request "www.python.org" fetch "www.python.org/index.html" using httplib module in python.i use proxy server "10.1.1.19:80".my code error message shown.please suggest me mistakes i'm commiting.regards.... >>> import httplib >>> conn=httplib.httpconnection("http://www.python.org",80) >>> conn.set_tunnel("10.1.1.19:80") >>> conn.request("get","www.python.org/index.html",headers={"proxy-authorization":"basic "+"mzewntmzomdvewfs"}) traceback (most recent call last): file "<pyshell#3>", line 1, in <module> conn.request("get","www.python.org/index.html",headers={"proxy-authorization":"basic &

How to Search for a total Range in another Range in Excel -

in excel need sum values, if of full column of text values appears in specific column. in other words: "sum values [column x] country=y, id= [anything a2:a2000, formatted text]. if id isn't 1 of values in range, don't want row value country=y summed. i can't line-by-line, i'm looking syntax of range vs. range., since id "keys" in separate column countries summed by. column = individual countries, in separate table have long list of "valid" ids. main data table, want sumif widgets column country, id = 1 of ids in "valid' id table. you can use sumifs , sumproduct . let's sheet1 column has countries, sheet1 column b has ids, sheet1 column c has values, sheet2 column has ids match , tables have headers in row 1. formula being put on sheet1. =sumproduct(sumifs($c$2:$c$100,$a$2:$a$100,"countryname",$b$2:$b$100,sheet2!$a$2:$a$100)) sumifs gives sum of range c2:c100, range a2:a100 corresponds text "co

ios - Storing response data (10.5 Intellectual Property Restrictions) -

this may not direct programming question, although if possesses programatic solution appreciated. we building mobile application includes functionality obtaining users location , this, nearby places respective addresses. possible query our db information using streetnames, cities, regiions, countries, place names, etc. if not allowed store place information more 30 days (besides place id), naive solution query every single db entry place id in order obtain address used in lookup match. seems rather inefficient. have else encountered issue? ideas or hints? can come solution store id's in tree structure, place structure stored in db, puts in gray spot in relation tos. thanks lot!

jquery - Dynamically add and remove form elements within the group -

i have form , trying generate multiple input form element , remove remove button. generated form element has other set of form elements can added , removed separately. when click 'add wall' on new generated elements adding getting on first section only. should added , removed in same section 'add wall' here code have tried https://jsfiddle.net/m20w0p1p/ <!-- begin form--> <div class="form-body"> <div class="control-group" id="fields"> <div class="controls"> <form role="form" autocomplete="off" method="post" id="voilation"> <div class="form-group"> <label>title</label> <div class="input-group"> <span class="input-group-addon"> <i class="fa fa-envelope"></i

javascript - How do I send all window alerts to one text box -

i had assignment used window alerts user knew happening in game. have got update game different assignment time window alerts have go text box. text box has "click on selection" base text. how make window alerts overwrite text? the code below have window alerts: function check(guess) { if (diamond == guess) { window.alert("congratulations! have found diamond.") again = window.prompt("would play game? enter y or n.", "y"); if (again == "n" || again == "n") { window.alert("thanks playing.goodbye."); window.close(); } else { window.alert("the diamond has been hidden. can try again."); window.location.reload(); } } else { number_of_guesses = number_of_guesses + 1; if (diamond < guess) { result = "lower" } else { result = "higher" }

opencl - Do global_work_size and local_work_size have any effect on application logic? -

i trying understand how of different parameters dimensions fit in opencl. if question isn't clear that's partly because formed question requires bits of answer don't have. how work_dim , global_work_size , , local_work_size work create execution space use in kernel? example, if make work_dim 2 can get_global_id(0); get_global_id(1); i can divide 2 dimensions n work groups using global_work_size , right? if make global_work_size so size_t global_work_size[] = { 4 }; then each dimension have 4 work groups total of 8? but, beginner, using global_id indices global id's matter anyway. can tell pretty confused of can offer ...help. image made try understand question image decribing work groups found on google since stated bit confused concepts involved in execution space, i'm gonna try summary them before answering question , give examples. the threads/workitems organized in ndrange can viewed grid of 1, 2, 3 dims. ndrange used map each th

node.js - How does event-loop occur in Nodejs? -

this question has answer here: in node.js how event loop work? 2 answers nodejs event loop 5 answers nodejs known best simplification "single thread". know, single thread handles requests through event loop. want ask: is nodejs have 1 thread only? example, if there billion users on website, thread loop through billion times? or in fact there "small threads" large single thread use different stuffs? thank you!

javascript - HTML 5's <picture> lazy load (without jquery) -

i've programmed small lightbox viewing images on website. keep loading process fast "lazy load" fullsize image. @ moment browsers load preview (test.jpg?size=520px) , fullsize image (test.jpg). is there simple solution prevent browsers loading fullsize image until image clicked? the website using minimal javascript - found no "no javascript" solution. additionally prefer solution doesn't require large html strings inside .js file added on mouse click. most lazy load scripts change attribute key inside image tag. however, html 5 longer useful approach. maybe possible change <picture> tag ( <picture> <<>> <picture-disabled> ) , prefetch full size image? html: <div class="imagecc"> <picture onclick="lightboxshow('test004.jpg')"> <source type="image/webp" srcset="test004.webp?size=520px"> <img src="test.jpg?size

validation - jQuery date time event scheduler -

i unable find jquery plugin can setup multiple event day scheduler along validations on time. instance, typical schedule this: <table border="1"> <tr> <th>#</th> <th>date</th> <th>topic</th> <th>from</th> <th>to</th> <th>speaker</th> <th>total hours</th> </tr> <tr> <td>1. </td> <td><input type="text" size="10"></td> <td><input type="text" size="10"></td> <td><input type="text" size="5"></td> <td><input type="text" size="5"></td> <td><input type="text" size="7"></td> <td><input type="text" size="5"></td> </tr> <tr> <td>

Is there a site to see the status of YouTube APIs? -

i noticed today uploads via v2 data api seem slow compared normal. wondering if there site displays system issues , alerts developers can make sure issues known , if not can report them? i don't know how reputable api-status.com report status of youtube api . bugs, issues, downtime youtube api officially reported in google group . i found clicking "announcement emails" on left column of youtube dev page has link file api bug .

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

my .env: app_env=local app_debug=true app_key=myappkey app_url=http://localhost db_connection=mysql db_host=localhost db_port=3306 db_database=gestiontaller db_username=root db_password='root' cache_driver=file session_driver=file queue_driver=sync redis_host=127.0.0.1 redis_password=null redis_port=6379 mail_driver=smtp mail_host=mailtrap.io mail_port=2525 mail_username=null mail_password=null mail_encryption=null i've tried password ", ' , without, restarting server every time. i've tried changing localhost 172.0.0.1. yes, password correct, running mysql -u root -p introducing password root in prompt can go mysql. users table: +------------------+-----------+ | user | host | +------------------+-----------+ | debian-sys-maint | localhost | | mysql.sys | localhost | | root | localhost | | root1 | localhost | +------------------+-----------+ i've added homestead.yaml this: database_port: 3306

spring mvc - Invalid property 'username' of bean class [java.util.ArrayList]: Bean property 'username' is not readable or has an invalid getter method -

i getting error "invalid property 'username' of bean class [java.util.arraylist]: bean property 'username' not readable or has invalid getter method". i have correct form bean name username though, still getting error, please me resolve error..? public class user { private int userid; private string username; private string firstname; private string lastname; private string email; private string lastupdatedby; private string lastupdateddate; public int getuserid() { return userid; } public void setuserid(int userid) { this.userid = userid; } public string getusername() { return username; } public void setusername(string username) { this.username = username; } public string getfirstname() { return firstname; } public void setfirstname(string firstname) { this.firstname = firstname; } public string getlastname() { ret

How do we mutate a string in Javascript -

i have string t2 , want mutate string based on below if condition . tried .replace doesnt work. t2 = "<li class='coded_true'>"+tp_info.elements["info"].cdatas.join.strip+"</li>" if (tp_info.attributes["itcoded"]== "true") t2= t2.replace(t2,"<li class='coded_true itcoded_true'>"+tp_info.elements["info"].cdatas.join.strip+"</li>"); end thanks! there's no need use .replace() substitute entire string: t2 = t2.replace(t2, ...); at point, can assign replacement directly: t2 = "<li class='coded_true itcoded_true'>"+tp_info.elements["info"].cdatas.join.strip+"</li>"; though, since difference between them in class names, might consider trying determine ahead of time , build markup string afterwards. var t2_class = ['coded_true']; if (tp_info.attributes

Spring Integration with JMS backed channels - "Dispatcher has no subscribers" -

i newbie spring integration , trying execute basic producer/consumer application si , activemq. i see messages being produced , stored on queue, when consumer ( service activator in case) processes message , tries returning new message output channel, keep getting below warning messages : 11:28:14.425 warn [defaultmessagelistenercontainer-1][org.springframework.jms.listener.defaultmessagelis tenercontainer] execution of jms message listener failed, , no errorhandler has been set. org.springframework.integration.messagedeliveryexc eption: dispatcher has no subscribers jms-channel jsonresponsechannel. @ org.springframework.integration.jms.subscribablejm schannel$dispatchingmessagelistener.onmessage(subs cribablejmschannel.java:159) below snapshot of context xmls : common-context.xml --------------------- .............. <bean id="requestqueue" class="org.apache.activemq.command.activemqqueue"> <constructor-arg value="input_msg_queue" />

oracle - Set heading off is not working in SQLcl when set sqlformat csv -

i generating csv output using sqlcl. set sqlformat csv set heading off select * hr.employees rownum < 10; "employee_id","first_name","last_name","email","phone_number","hire_date","job_id","salary","commission_pct","manager_id","department_id" 100,"steven","king","sking","515.123.4567",17-jun-03,"ad_pres",24000,,,90 101,"neena","kochhar","nkochhar","515.123.4568",21-sep-05,"ad_vp",17000,,100,90 102,"lex","de haan","ldehaan","515.123.4569",13-jan-01,"ad_vp",17000,,100,90 103,"alexander","hunold","ahunold","590.423.4567",03-jan-06,"it_prog",9000,,102,60 104,"bruce","ernst","bernst","590.423.4568",21-may-07,"it_pro

mysql - SQL variable in IF exists -

i can't figure out correct way assign query output variable later use in insert clause. the error error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near 'set @lennuid = (select lend_id lend sihtpunkt=in_kuhu , kuupaev=in_' @ line 8 i've tried looking @ every guide on variables in sql none of them me solve this. iam using below code: create procedure proov( in_kuhu varchar(50), in_nimi1 varchar(50), in_nimi2 varchar(50), in_adre varchar(50), in_telo varchar(20), in_email varchar(100), in_date date) begin declare viga integer default 0 ; declare lennuid int; start transaction; if exists ( set @lennuid = (select lend_id lend sihtpunkt=in_kuhu , kuupaev=in_date)) insert broneering (lend_id, bron_aeg, eesnim, perenimi, aadress, telefon, email) values (lennuid, now(), in_nimi1, in_nimi2, in_adre, in_telo, in_email); else set viga=1; select 'muudatus ebaonnestus ',viga; end if; i

java - how to create dynamic rows of records for creating xls file using list -

Image
here after fetching records database have added data in list , have set session variables them can access in method using get(key) method of session successful .now want want create dynamic records setting list value in row unable so.it creates file there no record displayed .below code: package com.ca.actions; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.sql.connection; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import java.util.arraylist; import java.util.list; import java.util.map; import org.apache.poi.hssf.usermodel.hssfrow; import org.apache.poi.hssf.usermodel.hssfsheet; import org.apache.poi.hssf.usermodel.hssfworkbook; import org.apache.struts2.dispatcher.sessionmap; import org.apache.struts2.interceptor.sessionaware; import com.ca.database.database; import com.ca.pojo.event; import com.itextpdf.text.document; import com.itextpdf.text.element; import com.itextpdf.text.pagesize; impo