Posts

Showing posts from May, 2012

c - How to display uid, size and file's type? -

i'm using gcc 32bit compiler. used stat() function, not giving information type of file. there function or way find these? i believe looking st_mode member of struct stat. from stat(2) manpage: status information word st_mode has following bits: #define s_ifmt 0170000 /* type of file */ #define s_ififo 0010000 /* named pipe (fifo) */ #define s_ifchr 0020000 /* character special */ #define s_ifdir 0040000 /* directory */ #define s_ifblk 0060000 /* block special */ #define s_ifreg 0100000 /* regular */ #define s_iflnk 0120000 /* symbolic link */ #define s_ifsock 0140000 /* socket */ #define s_ifwht 0160000 /* whiteout */ #define s_isuid 0004000 /* set user id on execution */ #define s_isgid 0002000 /* set group id on execution */ #define s_isvtx 0001000 /* save swapped text after use */ #define s_irusr 0000400 /* read permission, owner */ #define s_iwusr 0000200

angularjs - Can I declare a variable in html? -

given <li>document printing - <a href="http://{{displaysandbox()}}/{{displaycase()}}/printingservice/documentprintingservice.svc"> <span ng-class="{true:'value',false:'invalid'}[(sandbox && validcase())==true]">http://<span class="sandbox">{{displaysandbox()}}</span>.companyname.com/<span class="case">{{displaycase()}}</span>/printingservice/documentprintingservice.svc</span></a> <span ng-bind-html-unsafe="geturl('/printingservice/documentprintingservice.svc')"> </span> </li> i declare wrap in <div ng-var="subpath=/printingservice/printingservice.svc> so inside scope able <li>document printing - <a href="http://{{displaysandbox()}}/{{displaycase()}}{{subpath}}"> <span ng-class="{true:'value',false:'invalid'}[(sandbox && validcase())==true]"&g

php - Magento shell command fatal error: Class "Mage" not found -

when run command within /shell/ directory: php -f regularpromos.php why receive error? php fatal error: class 'mage' not found in /var/www/vhosts/yoohoo/httpdocs/shell/regularpromos.php on line 28 this regularpromos.php: <?php require_once 'abstract.php'; class mage_shell_regularpromos extends mage_shell_abstract { //day of week repeat promotion protected $day; //id of promotion protected $promoid; //rule process object protected $rule; public function mage_shell_regularpromos($promoid, $day) { $this->day = $day; $this->promoid = $promoid; $this->rule = mage::getmodel('salesrule/rule'); } public function run() { date_default_timezone_set('america/new_york'); $nextweek = date('y-m-d', strtotime('next '. $this->day)); $rule = $rule->load($this->promoid); $rule->setfromdate($nextweek)

php - Unable to generate route value_user_create -

i have problem symfony2-project sonataadmin- , userbundle. installed , configured according both admin- , userbundle-documentations , tried running, seems fine start. can both bundles come out-of-the-box. when try access list of users admin-dashboard (default path /admin/sonata/user/user/list ), this: an exception has been thrown during rendering of template ("unable generate url named route "value_user_create" such route not exist.") in "sonataadminbundle:crud:list.html.twig". as described, neither did change default routing informations provided sonata, nor did overwrite controller or anything. according symfony console router:debug route admin_sonata_user_user_create , amoungst other crud-routes, exists (pointing /admin/sonata/user/user/create ) so me seems value in route-name value_user_create not replaced admin_sonata_user -prefix, that's thought , cannot prove it. anyways can't find place fix problem, every , tip might helpful her

java - Using JSoup to parse text between two different tags -

i have following html... <h3 class="number"> <span class="navigation"> 6:55 <a href="/results/result.html" class="under"><b>&raquo;</b></a> </span>**this text need parse!**</h3> i can use following code extract text h3 tag. element h3 = doc.select("h3").get(0); unfortunately, gives me in tag. 6:55 &raquo; text need parse! can use jsoup parse between different tags? there best practice doing (regex?) (regex?) no, can read in answers of this question , can't parse html using regular expression. try this: element h3 = doc.select("h3").get(0); string h3text = h3.text(); string spantext = h3.select("span").get(0).text(); string textbetweenspanendandh3end = h3text.replace(spantext, "");

excel - save global variables in spreadsheet -

i have module load of global variables. name of global variables in module saved in first column, , global variable value saved in second column i.e public variable1 string public variable2 string public variable3 string variable1 = david variable2 = chicken variable3 = apple column a: variable1, variable2, variable3 column b: david,chicken,apple i can think of 3 ways go this. you set global variables properties , have thier values stored in cells on worksheet. execution of code slower, values persist , viewable/editable on spreadsheet. for example, define string property 'foo' acts global variable put in global module: public property foo() string foo = debugsheet.[b2] end property public property let foo(value string) debugsheet.[b2] = value end property you use named ranges globals, eg debugsheet.[foo] a third way have hardcoded save , load routines explicitly save each global specific cell in spreadsheet. works if save routine has run sinc

java - Does a binary tree contain another tree? -

alright guys, asked question in interview today , goes this: "tell if 1 binary tree contained inside binary tree or not (contains implies both in structure , value of nodes)" i thought of following approach: flatten larger tree as: {{{-}a{-}}b{{-}c{-}}}d{{{-}e{{-}f{-}}}g{{{-}h{-}}i{{-}j{-}}}} (i did write code this, {-} implies empty left or right sub-tree, each sub-tree enclosed within {} paranthesis) now smaller sub-tree need match pattern: {{.*}e{.*}}g{{{.*}h{.*}}i{{.*}j{.*}}} where {.*} denotes empty or non-empty sub-tree. at time thought, trivial regex pattern matching problem in java bamboozled. feel, have transformed problem (created 1 monster out of another). is there simple regex 1 liner match these patterns? understand there might other approaches solve problem , might not best one. wonder if solvable. i'm not sure interviewer meant "contained inside binary tree". if interviewer asking method check whether subtree of

javascript - jquery function to access hidden divs -

the code below general template music page. the slideshow moves song/image gallery forward or sequentially, alas, ' switchfeature ' function, should allow jump various tunes listed in sidebar, doesn't seem working. can point out error is, or needs done make work? thanks! <!-- music.php --> <?php require 'header.php' ?> <script type="text/javascript"> $(document).ready(function() { $(".tuneslides").hide(); var idname = ["#tune1", "#tune2"]; var indexnum = 0; $(idname[0]).fadein(1000); $("#slidenext").click(function() { $(idname[indexnum]).fadeout(300, function() { indexnum++; if (indexnum > 1) {indexnum = 0;} $(idname[indexnum]).fadein(500); }); }); $("#slideback").click(function() { $(idname[indexnum]).fadeout(300, function(

codeigniter - I am getting mysql error check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 4 -

i getting sql error "you have error in sql syntax; check manual corresponds mysql server version right syntax use near '?' @ line 4 select cm.user_id, chat_message_content, u.firstname chat_message cm join user u on cm.user_id = u.user_id cm.chat_id= ?" model function get_chat_messages($chat_id) { $query_str = "select cm.user_id, chat_message_content, u.firstname chat_message cm join user u on cm.user_id = u.user_id cm.chat_id= ?"; $results = $this->db->query($query_str, $chat_id); return $results; } try putting quotes around question mark if it's value in database you're filtering by: $query_str = "select cm.user_id, chat_message_content, u.firstname chat_message cm join user u on cm.user_id = u.user_id cm.chat_id= '?'";

c# - How to associate a customized number with exception -

i have code want throw 2 exceptions; however, exception same different values. know elegant generic way determine of these errors occurred. i know can 2 try catches or can set boolean determine success of query. aware can done in 1 query; however, need able determine if company key wrong or if pa id wrong. know can create own exception , add additional field it. unfortunately, not believe of these optimal solution , has been bothering me quite time. any information best practice appreciated. using (var ora = new oracleconnection(data.connectionstring)) { string sqlgetcompanyid = "select company_id companies key = :key"; string sqlvalidatedelete = "select * pa pa_id = :paid , company_id = :cid"; ora.open(); int companyid = 0; using (var command = ora.createcommand()) { command.commandtext = sqlgetcompanyid; command.parameters.add(":key", oracledbtype.varchar2).value = ckey; using (var reader = com

php - Facebook Graph API requests on page events returns empty result array -

i created php script year ago, requests events facebook page, , still works fine- except 1 page , since recently. $config = array(); $config[ 'appid' ] = '468554113184955'; $config[ 'secret' ] = 'app_secret'; $config[ 'fileupload' ] = false; // optional $facebook = new facebook( $config ); $res = $facebook->api( '/stadtpalais/events?fields=id,name,start_time,description,updated_time,picture.type(large)', 'get' ); i tried request app ending same result, think retrieving new app secret wouldn't help. the script working appid , secret , without user login. try graph explorer app access token '468554113184955|app_secret' (use own id , secret) reproduce error. change page other page , work. can page admins prevent these public requests through settings? (i haven't found 1 yet.) event title or description or whatever trigger error facebook sends empty array? some time ago read facebook might force us

java - Maven uses wrong jdk -

i have env.variable $java_home points folder jdk7 if execute "mvn -version" see next macbook-pro-erik:~ erik$ mvn -version 728-version apache maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-28 06:15:32+0400) maven home: /users/erik/distribs/maven/apache-maven-3.1.0 java version: 1.6.0_51, vendor: apple inc. java home: /system/library/java/javavirtualmachines/1.6.0.jdk/contents/home default locale: en_us, platform encoding: macroman os name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac" how enforce maven use correct jdk? have java.lang.unsupportedclassversionerror becouse of issue :( solved by: echo java_home=`/usr/libexec/java_home -v 1.7` | sudo tee -a /etc/mavenrc

excel - Moving Occupied Rows up above Blank ones with VBA code syntax error -

i have syntax error in if statement confused about, seems compiler shouldn't require = expected : = error on if isempty(activecell) activecell.offset(0,-1) range(zen).select oak = 1 oak = oak + 1 if isempty(activecell) activecell.offset(0, -1) else: if isempty(selection.offset(0, -1)) copy selection(activerow(e - m).range) paste selection.offset(0, -1) loop until oak = ruby here code in entirety dim ws worksheet dim rng1 range dim ruby integer dim ruby2 integer set ws = sheets("belmont") set rng1 = ws.columns("c").find("*", ws.[c1], xlvalues, , xlbyrows, xlprevious) dim zen string zen = rng1.address(0, 0) range(zen).select ruby = activecell.row ruby2 = ruby - 11 dim stones() boolean redim stones(1 ruby) dim z integer z = 1 if isempty(activecell.offset(2, 0)) stones(z) = 0 selection.offset(-1, 0).select z = z + 1 else stones(z) = 1 selection.offset(-1, 0).select z = z + 1 end if loop until z > ruby2 range(zen).select oak = 1 oak = oak + 1

java: puzzle about generics structure -

i have puzzle creation of structure: interface transform represent general physical transformation, , class poincaretransform represent specific type of transformation. thing this public interface transform { public transform compose(transform t); } public class poincaretransform implements transform { private matrix matrix; public transform compose(transform t) { ... } } but method compose(transform t) take poicaretransform because necessary have matrix compose with. possible solution using generics public interface transform<t extends transform<t>> { public t compose(t t); } public class poincaretransform implements transform<poincaretransform> { private matrix matrix; public poincaretransform compose(poincaretransform t) { ... } } but not satisfactory because not conceptually clean, elegant , there trouble again: poincaretransform subclasses have same problem before. also, definition, have generics around project! i'

How to change Android Notification using Accessibility API -

i able intercept notifications using accessablity service. block events seen : @override public void onaccessibilityevent(accessibilityevent event) { log.d(tag, "inside onaccessibilityevent"); if (event.geteventtype() == accessibilityevent.type_notification_state_changed){ sqldb db = new sqldb(this); notificationobject no = new notificationobject(); no.setnoficationpackage(string.valueof(event.getpackagename())); no.setnotificationtext(string.valueof(event.gettext().tostring())); no.setnotificationdtm(new date()); db.addnotification(no); log.d(tag, "saved event"); } } what want change notification not considered missed call event. possible on os 4.0+? thanks. another application's notification read-only. so, code "notification.a = b; "cause permission problem. public void onaccessibilityevent(accessibilityevent event) { // todo auto-generated

desire2learn - Super Admin not being enrolled in newly created program in valence desire 2 learn -

i'm working valence desire 2 learn api , making call /d2l/api/lp/1.3/orgstructure/ create new program (and passing proper object , receive proper object back). getting object , when log desire 2 learn program has been created cannot access it. listed not enrolled highest possible role (super admin cascading) should have access everything. ideas why or how can happen? i have been able confirm defect way api operates create custom org units. when api creates custom org unit, user/roles should getting enrolled in org unit via cascading enrollment not being enrolled, whereas if create custom org unit through web ui, cascading enrollment take place. i have logged defect you; internal reference number prb0042167. please have approved support contact (or account or partner manager) reach out desire2learn's support desk if request status updates, , refer number.

c++ - What is the difference between "hard-coding" and passing in arguments in regard to memory? -

so title question. in memory, arguments can located on stack or heap depending on how initialized, how hard-coded information dealt with? as example, use constructor ifstream what difference between this: void function(){ ifstream infile("home/some/file/path"); } vs void function(char* filepath){ ifstream infile(filepath); //filepath points character array contains home/some/file/path } could memory implications arise use of 1 on other? (multithreading lead heap corruption if char* isn't free'd correctly? etc). i trying understand difference , possible implications can apply answer larger problem. insight welcome , feel free correct me if i've made incorrect statements/assumptions! literals (which first example shows) placed static initialization portion of executable (which why, if on *nix system), can use command strings , obtain list of literals in application. your 2nd example should modified to void function(const c

vb.net - add string between strings if they are not null or empty -

supossing have 4 strings want add or operator between them: dim s1="db = 45 , frec = 500 " dim s2="db = 25 , frec = 1 " dim s3="db = 5 , frec = 2 " dim s4="db = 15 , frec = 4 " so dim result = "db = 45 , frec = 500 or db = 25 , frec = 1 or db = 5 , frec = 2 or db = 15 , frec = 4" thw woul easy concatenating strings dim result= s1 & " or " & s2 & " or " & s3 & " or " & s4 however in general, of strings empty or null if concatenate empty strings for instance s2 = "" dim result = "db = 45 , frec = 500 or or db = 5 , frec = 2 or db = 15 , frec = 4" which incorrect, thinking replace strings "or or" dim result = result.replace("or or", "") is there better approach? quick solution hard code cases guess not good (i cannot change design of this, strings used on several other things) in c#: string.join(

Breeze BeforeSaveEntity create new entity for foreign key -

when i'll try create new timeslot want add userid. save all, userid new 1 , code create new user instead of set foreign key. during debug user.id correct , timeslot.user.id correct. protected override bool beforesaveentity(entityinfo entityinfo) { // return false if don’t want entity saved. if (entityinfo.entity.gettype() == typeof(timeslot) && entityinfo.entitystate == entitystate.added) { var timeslot = (timeslot)entityinfo.entity; var user = uow.users.getbyid(userid); timeslot.user = user; return true; } else { return true; } }

Javascript for loop not appending list in dictionary -

and i'm not sure understand problem @ all. var vtf=[]; // dictionary maps number-> list var length; var s; // list of numbers s.length = length // length , s set values for(i=0; i<length; i++) { var f=s[i]; if(f in vtf) vtf[f].push(i); else vtf[f]=[i]; } so check if vtf contains value f=s[i]. if appends list contained @ vtf[f] , if doesn't makes new list element. the problem after running every index of vtf contains first added despite me knowing every value saved in vtf should have list of multiple elements. i can't understand i'm doing wrong. when put alerts inside if statement don't pop when put them outside loop, same value, show it's evaluating true number of times.

rest - Spring MVC Spring Security and Error Handling -

i'm using responseentityexceptionhandler global handling error , working normal, except want handle wrong request spring. logic overriding handlenosuchrequesthandlingmethod should handle this, insted of handling get http status 404 - type status report message description requested resource not available. apache tomcat/7.0.37 i got when enable debuging in console: warn : org.springframework.web.servlet.pagenotfound - no mapping found http request uri just clarify handling mean i'm returning json. any idea how handle this? the reason right there , in dispatcherservlet class; sends error response without bothering call exception handler (by default). since 4.0.0.release behaviour can changed throwexceptionifnohandlerfound parameter: set whether throw nohandlerfoundexception when no handler found request. exception can caught handlerexceptionresolver or @exceptionhandler controller method. xml configuration: <servlet>

c++ - Disable delegate of curtain QTableView cell -

how can disable delegates of curtain cell. current edit (when double clicked) me need on 3rd cell of each row, , 1st , 2nd, need disable action(delegate). astandarditempointer->seteditable(false) did job

android - Sony SmartWatch Control Extension, displaying a view from my App -

i display output (a bitmap) of existing app xyz on smartwatch. understand, control api way go, existing examples sony sdk , opensource projects (8game , musicplayer) aren't clear me. right in assumption, need following classes integrated existing app? mycontrolwatch.java myextensionreceiver.java myextensionservice.java myregistrationinformation.java what else need , how smartwatch display bitmap? have send control_start_request_intent and, if yes, should that? have change given samplecontrolextension result? yes, classes need display control extension. don't need send control_start_request_intent necessarily. if want start control extension extension. look in sample code in samplecontrolsmartwatch.java class included in /samples directory of sdk. check animation() class constructor example. need create layout add bitmap call showbitmap().

xslt - How to call an external java function with Xalan processor -

i'm having trouble call external java function in xsl code xalan processor. the error : exception in thread "main" java.lang.runtimeexception: java.lang.nosuchmethodexception: extension function, not find method org.apache.xml.utils.nodevector.incrementpropertyid([expressioncontext,] ). i have java class named util.java in folder execute compile command. in xsl file, i've declared namespace follow : <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java" xmlns:util="xalan://util"> and call function using : <xsl:copy-of select="util:incrementpropertyid(blablabal)"/> so suppose problem comes namespace, wrong ? also, it's xsl 1.0 stylesheet. thanks help edit : in util.java file, have no package declared since i'm @ r

r - Horizontally shift boxplot bars' position using ggplot2 -

Image
i need shift bars in boxplot horizontally on plot (left or right). there way can adjust boxplots' x-axis position without changing x-axis? the code using generate boxplot listed below, plot <- ggplot(aes(y = score, x = date, fill = category), data = data_r1000) + geom_boxplot(width=0.8) + ylim(20,100) + labs(title = "us_marketor") + theme(legend.position="bottom") + theme(panel.background = element_rect(fill = "transparent",colour = na)) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) + scale_fill_hue(c=50, l=85) the results looks this i have tried using position = position_dodge/position_jitter none of them works. output plot multiple boxplot bars, , have removed background , grids. want shift these bars left side or right side of default position. add coord_flip() code: plot <- ggplot(aes(y = score, x = date, fill = category), data = data_r1000) + geom_boxplot(width=0.8) + ylim(20,10

Creating LI dynamically in Jquery -

this question has answer here: jquery .append of </select> tag ignored [duplicate] 5 answers $.each(data.trendingproducts, function (i, item) { $("#trendcontent").append('<li>') .append('<div class="product-wrapper">') .append('<div class="image-wrapper">'); $("<img/>").attr("src", item.image).appendto("#trendcontent"); $("#trendcontent").append('</div>').append('</div').append('</li>'); }); <ul class="large-block-grid-3 small-block-grid-3"> <div id="trendcontent"></div> </ul> hi trying create unordered list in jquery lists not formed properly. suggestions/help? there few problems code: you not need append

javascript toggle and anchor -

i starting in javascript, need help. have simple javascript toggles div on webpage. div working well, because in footer of page, opens , cannot see content. how make toggle scroll down entire div can seen? i found similar examples other scripts, have not been able apply them here. this javascript function toggle() { var ele = document.getelementbyid("showindex"); var text = document.getelementbyid("displaytext"); if(ele.style.display == "inherit") { ele.style.display = "none"; text.innerhtml = "show list"; } else { ele.style.display = "inherit"; text.innerhtml = "show list"; } } this html <div id="indexslider"> <a href="#showindex"><a id="displaytext" href="javascript:toggle();">show list</a></a> </div> <div id="showindex">

shell - Selecting a value from output of ps -eaf -

suppose want select 6547 output of "ps -eaf" command, how do it? want select value , give "kill" command kill process. root 6547 1 0 aug07 ? 00:00:00 root 14805 2 0 aug07 ? 00:00:00 root 17443 30043 0 16:21 pts/0 00:00:00 you may have write small shell script - contain below option - pidlist=`ps -eaf | awk ' print $2'` pid in pidlist cmd="kill -9 $pid" `$cmd` now based on critieria (like process name, user etc) can take action specific process. jist here use awk command exact column.

php - Can not figure outsyntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING -

i querying database , recordid int. have line of code when echo out value of $content['recordid'] prints out numeric value, when put in here error: syntax error, unexpected t_encapsed_and_whitespace, expecting t_string or t_variable or t_num_string. but if replace $content['recordid'] numeric value works properly $sqlcommentamount = "select * `info` `recordid` = $content['recordid']"; leave out '' within [] ... $content[recordid]"; see documentation example #8: http://php.net/manual/en/language.types.string.php#language.types.string.parsing.simple example #8 simple syntax example <?php $juices = array("apple", "orange", "koolaid1" => "purple"); echo "he drank $juices[0] juice.".php_eol; echo "he drank $juices[1] juice.".php_eol; echo "he drank juice made of $juice[0]s.".php_eol; // won't work echo "he drank $juices[kool

javascript - Angular Directive to Directive call -

if have directive you're using multiple times on page how can 1 directive communicate another? i'm trying chain directives in parent child relationship. when directive clicked want filter directive b have children of selected item in directive a. in case there may infinite number of directives , relationships on page. normally have directive call filter method on each of it's children, , each child calls it's child continue filtering down hierarchy. but can't figure out if calling methods 1 directive possibe. thanks it sounds looking directive controller. can use require: parameter of directive pull in directive's controller. looks this: app.directive('foo', function() { return { restrict: 'a', controller: function() { this.qux = function() { console.log("i'm foo!"); }; }, link: function(scope, element, attrs) { } }; }); app.directive('bar', function

mysql - Regarding containing string -

i trying search based on string input have 1 table called vuln_info. if search way select vuln_id vuln_info vuln_name="self-signed ssl/tls certificate" it returns result expected. however, sometime input can be "self-signed ssl/tls certificate present" or "machine self-signed ssl/tls certificate" what way result? i tried use option select vuln_id vuln_info vuln_name "%self-signed ssl/tls certificate present%" select vuln_id vuln_info vuln_name "%machine self-signed ssl/tls certificate%" i 0 result.

jquery - How do I check whether the result data set from an AJAX call has only 1 parent node? -

please refer if statement in code: function createprojecttree(sc) { $.ajax({ type: "post", url: "../api/projects/searchprojects", data: sc, contenttype: "application/json; charset=utf-8", datatype: "json", success: function(data) { if (data contains 1 parent node) { //redirect page x page } else { buildtree(data); } }, }); } the result of call xml , need check whether has 1 parent node (regardless of number of children). how go doing this? you can use length property of jquery object: if ( $(data).length === 1 ) { // ... } note if response's type of request xml, should set datatype property xml , not json .

http put - eXist-db size limit -

i'm trying upload file exist-db using put request , getting following message: 500 server error: form large 392430>200000 how can override limit? answered on exist-open mailing list @ http://markmail.org/message/njpvhheytnlhiidu .

javascript - Chained select boxes with jquery/php/database not working -

it seems chained selects accomplished json, unfortunately it's more convenient me use database accomplish this. it's there, reason second select box not loading properly. instead it's loading entire html page it's on , i'm not sure why. here's i've got (note make_list() , model_list() functions built return array appropriate respective criteria) the js: $(document).ready(function(){ $("select#type").attr("disabled","disabled"); $("select#category").change(function(){ $("select#type").attr("disabled","disabled"); $("select#type").html("<option>loading...</option>"); var id = $("select#category option:selected").attr('value'); $.post("select_type.php", {id:id}, function(data){ $("select#type").removeattr("disabled"); $("select#type&q

ruby - Rails 4.0 User Authentication With Devise + Omniauth -

i understand don't have facebook set yet (that seems similar different beast), right now, based on understanding, should able sign in twitter username , "you signed in!" , display username says <span>logged in <%= current_user.username %>.</span> also, on separate note, love know why flash.notice isn't working me. deprecated in rails 4 or missing in application.html.erb file them show? i'm working from: http://railscasts.com/episodes/235-devise-and-omniauth-revised here code i'm working with. https://github.com/erosenberg/devise-app edit : ok, sorry wasn't specific, figured wall of text less responses shortened it. essentially i'm trying work railscast devise working omniauth. in past i've gotten omniauth devise working on own, , bringing them has been whole new challenge -- considering every tutorial has told me different way , of them seem outdated. way have set way railscast recommends -- add omniauthcallback

python - Error when creating GIF using images2gif.py -

i'm trying create gif file using images2fig.py visvis package with simple code: import glob pil import image visvis.vvmovie.images2gif import writegif images = [image.open(image) image in glob.glob("*.png")] filename = "test.gif" writegif(filename, images, duration=0.2) i got error file "c:\python27\lib\site-packages\visvis\vvmovie\images2gif.py", line 575, in writegif gifwriter.writegiftofile(fp, images, duration, loops, xy, dispose) file "c:\python27\lib\site-packages\visvis\vvmovie\images2gif.py", line 436, in writegiftofile fp.write(globalpalette) typeerror: must string or buffer, not list how fix this? i'm using python 2.7.5, pillow 2.1.0, numpy 1.7.1-2, standard installation python(x,y) 2.7.5 on windows, , visvis 1.8 latest version. tried reinstall packages did not help. still same error. friend of mine reproduced error on computer too. @korylprince fixed problem following 2 changes: i uni

java - Switch statement in non-anonymous private OnClickListener class not working? -

i've tried quite few different tactics achieve desired result, nothing making these buttons they're 'sposed to... have 14 buttons. 4 text "x", digitone, digittwo, digitthree , digitfour. then, there 10 "1", "2", etc, named "one", "two", etc. buttons tied same onclicklistener use switch statement determine button pressed, find soonest display button (buttons marked "x"), , change buttons text entered digit. want happen is: say clicks "5" button. if first button pressed, first "digit" button change displaying "x" "5", , so-on, so-forth. not happening... in fact, nomatter i've tried, nothing happening. not error... error nice, @ least i'd know logical flaw -_-. here's code: the button declarations: one=(button)findviewbyid(r.id.button1); two=(button)findviewbyid(r.id.button2); three=(button)findviewbyid(r.id.button3); four=(button)find

android - Listen for location and orientation changes -

i working on idea android app requires me listen location changes , orientation changes. basically want find out if facing towards point, require me find orientation of phone. want keep track of location changes want know if user closer or further away point. have location listener sorted can location against number of stored points in database. how go listening orientation changes @ same time? possible implement 2 listeners in same activity. by orientation changes mean changes in direction user facing not phone orientation such landscape or portrait. wanting monitor onsensorchanged , retrieve azimuth for listening orientation changes can use onconfigurationchanged() and add configchanges in manifest activity : <activity android:name=".myactivity" android:configchanges="orientation|keyboardhidden" android:label="@string/app_name">

Learning CSS div placement , positioning -

i learning css, trying place div red background below body, can't seem make fit body, whenever adjust width doesn't align body,when tried place center , 100% width, occupies 100% of width of page not align white background area, whenever 80% align left , not align white background area. please point me right direction. i'm stuck :( the code have far here: http://pastebin.com/vpmgbzq2 thanks in advance. make footer div out of tabs div , no need of position: absolute on it. make following changes: #footer { margin-top:80%; height: 20px; width:50%; text-align:center; background:#c00; } here fiddle . also seems trying make responsive design let me tell way proceeding not right 1 it. may read responsive design ethan marcotte learning it. edit make following changes: give height: 400px; or required table div . make footer div out of table div . either remove margin-top or change 5% or 10% required in

activerecord - Rails pass array to partial using collection -

i'm trying iterate through regular array (not activerecord), , render partial using each element. in view (i'm using slim): == render partial: "layouts/display_elements", collection: my_array my partial (for now) contains: = "#{display_element}" however, i'm getting following error: undefined local variable or method `display_element' #<#<class:0x007f7fe2e6ca58>:0x007f7fe51e0408> is limit of imposed not using activerecord? have resort to = my_array.each |e| i not familiar slim-lang, think adding :as option work you: == render partial: "layouts/display_elements", collection: my_array, as: :display_element this allow access collection my_array display_item local variable within partial.

CSV Search AutoIT -

Image
i have csv file contains 4 columns, want search column 2 , change corresponding data in column 4 using autoit: col 1 col 2 col 3 col 4 1 502 shop 25.00 2 106 house 50.00 3 307 boat 15.00 if columns separated tabs use stringsplit that. $s1 = '1 502 shop 25.00' $s2 = '2 106 house 50.00' $s3 = '3 307 boat 15.00' $i=1 3 $array = stringsplit(eval('s' & $i), @tab) consolewrite('column 2: "' & stringstripws($array[2], 8) & '"' & @crlf) consolewrite('column 4: "' & stringstripws($array[4], 8) & '"' & @crlf) next this sample code print: column 2: "502" column 4: "25.00" column 2: "106" column 4: "50.00" column 2: "307" column 4: "15.00" edit this example creates csv file, reads file in , searches every line '106'. if string fou

multithreading - PySide timers/threading crash -

i've written pyside windows application uses libvlc show video, log keystrokes, , write aggregated information keystrokes file. i'm experiencing 2 bugs causing application crash (other question here -> https://stackoverflow.com/questions/18326943/pyside-qlistwidget-crash ). the application writes keystroke file @ every 5 minute interval on video. users can change playback speed, 5 minute interval may take more or less 5 minutes; it's not controlled timer. the video continues playing while file written, i've created object inheriting threading.thread file creation - intervalfile. information file written passed in constructor; intervalfile doesn't access parent (the main qwidget) @ all. threading object use in app. there no timer declared anywhere. intermittently, application crash , i'll following message: " qobject::killtimers: timers cannot stopped thread ". the code creates intervalfile (part of customwidget, inherited qwidget): def

html5 - Clicking HTML 5 Video element to play, pause video, breaks play button -

i'm trying video able play , pause youtube (using both play , pause button, , clicking video itself.) <video width="600" height="409" id="videoplayer" controls="controls"> <!-- mp4 video --> <source src="video.mp4" type="video/mp4"> </video> <script> var videoplayer = document.getelementbyid('videoplayer'); // auto play, half volume. videoplayer.play() videoplayer.volume = 0.5; // play / pause. videoplayer.addeventlistener('click', function () { if (videoplayer.paused == false) { videoplayer.pause(); videoplayer.firstchild.nodevalue = 'play'; } else { videoplayer.play(); videoplayer.firstchild.nodevalue = 'pause'; } }); </script> do have ideas why break play , pause control button? not bring old post landed on question in search same s

c# - ASP.NET DES encryption with encrypted text length equal to plain text length -

i looking encrypt string of text using des algorithm requirement encrypted string length should same plain text string length. have tried use option ciphermode.cts, getting cryptographicexception "specified cipher mode not valid algorithm." thanks in advance. as stated in this codeproject article time ago. the cts mode not supported of symmetric encryption algorithms shipped .net framework bcl. included support new symmetric algorithms might derive symmetricalgorithm class @ later time. this article 2002, after doing further investigation, quote above seems still accurate. fortunately though, bouncy castle support cts. public static byte[] encrypt(byte[] data, byte[] key, byte[] iv) { bufferedblockcipher cipher = new ctsblockcipher(new cbcblockcipher(new aesengine())); icipherparameters keyparam = new parameterswithiv(new keyparameter(key), iv); cipher.init(true, keyparam); return cipher.dofinal(data, 0, data.length); } public sta

PyQt4 uic Compiler -

system information macosx 10.8.4 macports 2.2.0 py27-pyqt4 @4.10.2_2 (active) qt4-mac @4.8.5_0 (active) qscintilla @2.7.2_0 (active) python27 @2.7.5_1+universal (active) hi all, i following error message: importerror: no module named pyqt4.uic.compiler when attempting install tortoisehg following command: sudo pip install thg-mac i think i've setup $path correctly too. here's echoed output: /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/x11/bin any ideas how solve this? i not mac user, information may debug. on debian, uic module provided package called pyqt4-dev-tools, not pyqt4 itself.

jquery - Call Editable after modal loads -

i have bootstrap modal call: <a href='/urltoloadcontentfrom' data-toggle="modal" data-target="#driverprofile">view driver information</a> the page displays following url needs editable <a href="#" class="editable" data-type="text" data-pk="1" data-url="/post" data-title="enter username" data-mode="inline">link here</a> i need bind "editable". initialize editable $('.editable').editable(); i tried initialize with: $('#driverprofile').on('shown', function () { $('.editable').editable(); }); but seem fire before content displayed , not initialized. any ideas? "editable" library i'm using: http://vitalets.github.io/x-editable/ i ended doing following call when loading editable: $('.modal-body').editable({selector: '.editable'}); this binds editable .m

c# - how to test that the wpf gui thread is Alive -

i have modal wpf application , need way monitor if application still working , gui responding using other process cannot think of idea how can done. on other applications raise "alive" event main loop don't have clear main loop in wpf app. is adding dispatcher timer application raise event idea? am converting comment answer on request. i think you're looking process.responding property. return whether ui responsive or not. note: process.responding cannot used process doesn't have ui. if process has user interface, responding property contacts user interface determine whether process responding user input. if interface not respond immediately, responding property returns false. use property determine whether interface of associated process has stopped responding. if process not have mainwindowhandle, property returns true. for more info take @ process.responding

c# - DontDestroyOnLoad is not Working on Scene? -

i need apply dontdestroyonload on scene.is possible? i need not disturb scene when going in scenes also.here i'm sending mail,when ever clicking send button going authentication in mail server in time scene idle means not responding until come response mail server,so on time show 1 loading bar in scene.this not process.the entire scene hang until came response mail server,so how solve this? void awake() { dontdestroyonload(this.gameobject); } when loading new level, scene , game objects of previous scene destroyed unity. if want protect game object can use function. dontdestroyonload(gameobject); it important note when say: this.gameobject pointing pretty same thing, happens this points directly script attached gameobject. don't need this part, gameobject do. ideally protect gameobject inside void awake() void awake() { dontdestroyonload(gameobject); } the above code prevent unity destroying gameobject unless game closes or @ later p

javascript - display data from database based on drop down selection -

pls me. hav drop down contain shop , shop b.shop has value 1 , shop b has value 2. when select shop dropdown want list data database table corresponding each shop.. html shop select >shopa >shopb and js $("#shop").change(function(){ // selected user's id var id = $(this).find(":selected").val(); // load in userinfo div above $("#container").load("table_data.php?id="+id); }); does table_load.php return html elements? jquery documentation: description : load data server , place returned html matched element. your php script needs generate html elements inserted container. also, don't need selector, sufficient: var id = $(this).val();

html - Using Affix in Bootstrap 2.3.2 -

i'm trying create sidebar this sidebar overlaps footer.i need sidebar move when scroll reaches end.( link) here code: css: .bs-docs-sidenav { background-color: #ffffff; border-radius: 6px 6px 6px 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.067); margin: 60px 0 0; padding: 0; width: 228px; } .bs-docs-sidenav > li:first-child > { border-radius: 6px 6px 0 0; } .bs-docs-sidenav > li:last-child > { border-radius: 0 0 6px 6px; } .bs-docs-sidenav > li > { border: 1px solid #e5e5e5; display: block; margin: 0 0 -1px; padding: 8px 14px; } .footer { background-color: #f5f5f5; border-top: 1px solid #e5e5e5; margin-top: 70px; padding: 30px 0; text-align: center; } .affix-top { position: absolute; top: 0px; bottom: auto; } .affix-bottom { position: ab

android - Handling HTTP request redirect in java -

i'm writing network android application uses http requests data. data html format. use apache httpclient , jsoup. when i'm out of traffic mobile internet provider, redirected providers' page saying should pay money. of course, bad idea parse page. how detect occured page substitution? this code know final target of request, if isn't page asked for, provider page. defaulthttpclient httpclient = new defaulthttpclient(); httpcontext localcontext = new basichttpcontext(); httpget httpget = new httpget("http://www.google.com/"); httpresponse response = httpclient.execute(httpget, localcontext); httphost target = (httphost) localcontext.getattribute( executioncontext.http_target_host);// final page of request system.out.println("final target: " + target); httpentity entity = response.getentity(); entityutils.consume(entity); thanks

c++ - how to prevent deadlock when using wxCRIT_SECT_LOCKER -

i'm writing singleton logger class in c++. class provides logging api multiple threads. make thread safe i'm using wxcrit_sect_locker macro. say have in logger class following functions (simple example): void logger::error( string msg ) { wxcrit_sect_locker(adapter_locker, gs_logbuffershield); // such getting/setting class members m_err_cnt++; do_log("error: " + msg); } void logger::warning( string msg ) { wxcrit_sect_locker(adapter_locker, gs_logbuffershield); // such getting/setting class members m_warn_cnt++; do_log("warning: " + msg); } void logger::do_log( string msg ) { wxcrit_sect_locker(adapter_locker, gs_logbuffershield); // such getting/setting class members m_log_cnt++; cout << msg << endl; } problem: when logger::warning() called we'll enter critical section twice, once in logger::warning() , 1 more time in *logger::do_log()*. if agree problem real , can cause deadlock, how can

mysql - PHP Only Selecting First Row? -

i have quick login form made school problem when try , login worked when want log first user (username: hbutler password: password) when try login other accounts page refresh have set if incorrect here code : <?php //create connection… //("where database is", 'database login' , 'database password' , "database name") $con=mysqli_connect("", 'root', 'root', "social"); //check our connection… if (mysqli_connect_errno($con)) { echo " sorry mate"; } $username = $_post['username']; $password = $_post['pawd']; $result = mysqli_query($con, "select * user_info"); $row = mysqli_fetch_array($result); $value = $row['username']; if($value == "$username") { $result = mysqli_query($con, "select * user_info username ='$username'"); $row = mysqli_fetch_array($result); $value = $row['password']; if($value == "$password

php - Iframe takes time to load -

i want show smartphp calendar in iframe take time load/show.a white/bland page shows @ start here code <table id="table_1" class="form_table" align="center" cellpadding="0" cellspacing="0"> <tbody> <tr><td width="1250" height="950"> <iframe id="myiframe" src="" width="100%" height="950" frameborder="0" /></iframe> </td></tr></tbody></table> here jquery $(document).ready(function(){ $('#myiframe').attr('src','http://mysite.com/smartphpcalendar/index.php'); }); i have 2 questions 1 - how can reduce loading time? 2- how show loading message/loader image users not disappoint , wait. why wait until whole site loaded trigger loading of iframes content? force delay way. instead of triggering loading $(document).ready... function put contens url in iframe

php - EntityMetadataWrapperException: unknown data property for field -

i have been trying update code use entity wrappers access field values. have this: $wrapper = entity_metadata_wrapper("node", $nid); print($wrapper->field_property_sample()->value()); instead of this: print($node->field_property_sample[language_none][0]["value"]); the problem encounter this: entitymetadatawrapperexception: unknown data property field_property_sample. is there way me workaround this? i have 10 of these fields can throw exception , getting ugly $wrapper = entity_metadata_wrapper("node", $nid); try { print($wrapper->field_property_sample()->value()); } catch (entitymetadatawrapperexception &e){ print(""); } /** repeat 10 times **/ is there function can more or less call this? $wrapper = entity_metadata_wrapper("node", $nid); print($wrapper->field_property_sample->exists() ? $wrapper->field_property_sample->value() : "" ); /** repeat 10 times **/

python 3.x - Sublime Text 3 internal image viewer -

Image
would possible create internal image viewer plugin sublime text 3? noticed in forum people have mentioned not possible st2 due fact api doesn't allow access ui , widgets, wondered if still case st3? sublime text 3 has built in image preview. it provides provides simple information image such pixels & size of image in status bar. feature first introduced in development build 3055 build after adding checkered backgrounds transparent images.

How can I implement paging for DataGridView in Winform scenario when using Entity Framework? -

all can find on net asp.net use. want retrieve page count amount of records database every time. isn't possible? the bottleneck seems disposal of context. dunno how resolve this. thanks. nico if need simple sql query can use example: using system; using system.data.sqlclient; class program { static void main() { // // name trying match. // string dogname = "fido"; // // use preset string connection , open it. // string connectionstring = consoleapplication1.properties.settings.default.connectionstring; using (sqlconnection connection = new sqlconnection(connectionstring)) { connection.open(); // // description of sql command: // 1. selects cells rows matching name. // 2. uses operator because name text field. // 3. @name must added new sqlparameter. // using (sqlcommand command = new sqlcommand("select count(*) dogs1 name @name", connectio

java - How to authenticate android user POST request with Django REST API? -

as of now, have django rest api , hunky dory web app, wherein have implemented user auth in backend. "login_required" condition serves web app, cookie based. i have android app needs access same api. able sign in user. need know how authenticate every user when make get/post request views? my research shows couple of solutions: 1) cookie-backed sessions 2) send username , password every get/post request(might not secure) any ideas? it sounds you're using django rest framework in case tokenauthentication might suitable. docs: this authentication scheme uses simple token-based http authentication scheme. token authentication appropriate client-server setups, such native desktop , mobile clients you don't need pre-generate tokens clients can ask 1 using built-in view obtain_auth_token configure in urls.py. once client has obtained token session can provide on subsequent api calls using authorization: http header. check out docs more i

networking - Does the idea of private ip address in ipv6? -

for idea of private, mean 10.*.*.* idea of ipv4. seems ipv6 don't conserve ip addresses these more. so, if want create private subnet don't want others know subnet number or access subnet ip address. can create own range of ip subnet number, seems in way, conflicts global ip address. i know idea of link local address, think that's useless when want several links constitute network. if setting private local network development/testing , don't have actual ipv6 connectivity of own (or isp stupid , gave /64) unique local addresses work fine you. however, unique local addresses cannot used connectivity global internet. if need this, should global addresses , proper firewall (as nat not needed , discouraged in ipv6 ). to /48 ula prefix, visit this generator , throw in mac address. (using mac address generate prefix specified rfc 4193 , defines unique local addresses.)