Posts

Showing posts from July, 2015

html - Some images not showing up in IE, but in Chrome. When I replace it with another it works -

i'm designing new portfolio website using template. i'm replacing gallery images own images, going wrong. own images not visible in ie, it works in chrome . know codes can't problem because when change original image, works fine in both chrome , ie. when "right click>properties" can't see details when i'm using own image example url. when i'm using original image can see details. i tried number of things: change .jpg .png --> doens't work change size own image size original image --> doens't work change filename --> doesn't work delete image image folder , replace --> doensn't work anyone knows can problem here? site isn't published yet, i'm still working previews in dreamweaver.

html - position:absolute reduces height -

.header2 { background-color:#cdd1cd; padding: 15px 0; } .header1 { background-color: #60db60; padding: 10px 0; } form { position: absolute } <div class="headers header1" id="header1"> <div class="logo"></div> <div class="slogan"></div> </div> <div class="headers header2" id="header2"> <form> <table> <tr> <td>email or mobile number</td> <td>password</td> </tr> <tr> <td><input type="text"></input></td> <td><input type="password"></input></td> </tr> <tr> <td> </td> <td><a>forgot password?</a></td> </tr> </table> </form>

android - Align Toolbar icons from right to left? -

Image
in application, have implemented languages including arabic language starts right left. want align icons in toolbar right_to_left . i tried layout_gravity="right" , gravity="right" nothing happed. my toolbar code: <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primary_color" app:popuptheme="@style/theme.appcompat.light"/> here want: official right-to-left support introduced android 4.2 (api level 17), work if minimum sdk level 17: 1) put android:supportsrtl="true" attribute in androidmanifest file support right-to-left layout directions. 2) secondly put code in activity's oncreate() methdod: if (g

mysql - correct way to handle select + insert to avoid duplicates errors -

hello have simple mysql innodb table 2 fields: id - autoincrement primary index name - unique index i importing data various sources in parallel , need make sure data not duplicated @ insert doing following: select `id` `table` `name` = <name>; if `id` <= 0 insert `table` set `name` = "<name>"; return auto_increment else return `id` this works 99.9999% of times can happen (and has happened me) 2 or more different scripts inserting same data because both select returned id <=0 both insert , 1 of them raises error. i have 2 possible solutions in mind not sure work best. one more piece of information: import not find elements in table more of elements inserted probability found grows. final table, after rough calculation, have approximately 7-10 million records : select `id` `table` `name` = <name>; if `id` <= 0 insert ignore `table` set `name` = "<name>"; auto_increment if auto_increment <=0 sel

multithreading - Is this way of generating random numbers safe and valid? -

i doing recreational low-level programming other day, , somewhere in code thing emerged (using pseudocode): cointoss program char out = '0'; void thread(){ out = '1';} int main(){ // creates thread run function provided // main() not wait thread finish runinownthread(thread); printr("%d", out); return 0; } now in our shell run cointoss program x number of times , end this: 0011011100001000 which can convert decimal , random number my question not whether efficient way of creating random number more can tell if end result random enough use no, using race condition not way generate random numbers. result nondeterministic, result heavily weighted towards 1 outcome. if don't care values being heavily weighted (that random enough you), go ahead.

forms - issue Drupal 7 submit button not work with theming -

hello have issue when redesign display of form in drupal 7. the submit boutton not work theme , not if it's displayed simply. i try check information releated nothing can me @ time. i hope there enough information me my form php: $form=array(); $form['myform']=array( '#type'=>'fieldset', '#title' => 'enter na' ); $def_na=''; if (isset($param['na'])) {$def_na=$param['na'];} $form['na'] = array( '#type' => 'textfield', '#title' => t('called number (na):'), '#default_value' => $def_na, '#maxlength' => 10, '#minlength' => 4, '#required' => true, //'#description' => t('set <em>yes</em> if category selected default.'), ); $def_period='daily'; if (isset($param['period'])) {$def_period=$param['period'];} $form['period'

android - Listview like button -

i use listview in app, want add button. public void likebutton(view view) { new postcomment().execute(); } postcomment class class postcomment extends asynctask<string, string, string> { @override protected void onpreexecute() { super.onpreexecute(); pdialog = new progressdialog(mainactivity.this); pdialog.setmessage("posting comment..."); pdialog.setindeterminate(false); pdialog.setcancelable(true); pdialog.show(); } @override protected string doinbackground(string... args) { // todo auto-generated method stub // check success tag int success; // random dummy data // need real values string user = "44"; string post = "12"; try { // building parameters arraylist<namevaluepair> params = new arraylist<namevaluepair>(); params.add(n

android - When using overridePendingTransition, modifying UI views in the called activity is very slow -

a few days ago, had problem updating action bar menu icon based on result of asynctask : updating action bar menu item due asynctask result without delay now realized problem not @ related asynctask or action bar . problem occurs if want change textview or other view . after time of trial , error realized problem caused overridependingtransition use in activity calls second activity (where want change icon): first activity (in onitemclick method): @override public void onitemclick(view view, int position) { ... intent intent = new intent(getactivity(), secondactivity.class); ... startactivityforresult(intent, anyvalue); getactivity().overridependingtransition(r.anim.slide_in_right, r.anim.no_animation); } the animation looks that: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromxdelta="100%p" android:toxdelta=&

excel - Further Summarize Pivot Table Results (Average) -

Image
this seems should simple, can't figure out morning. i've had coffee. returning 4 fields webfocus query: shipweek, ship date, part numberand quantity (qty). set query pulls 365 days of records when workbook opens. have summarized data pivot table. pivot table shows shipweek row 2 values: count of qty , sum of qty. works fine. what want beyond this, however, calculate range of returned results average weekly count , standard deviation. can using average() , stdev() functions , pointing 2 values ranges in pivot table. work once. i'd not have manually adjust range these formulas each time run query. theoretically, there same number of weeks in 365 days of data, may not case. if number of rows in pivot table changes, might skew results. surely there way in pivot table itself? pivot table offers "grand total" option, sum of records, don't know how equivalent of "grand total" average or standard deviation. if not in pivot table, d

encoding - mock java.nio.file.Paths.get do nothing but throw InvalidPathException -

i have 2 line of code: file file = new file("report_はな.html"); path path = paths.get(file.getcanonicalpath()); is there anyway can mock static method: paths.get(file.getcanonicalpath()); and throw exception invalidpathexception? i tried powermockito, seems not working powermockito.mockstatic(paths.class); powermockito.doreturn(null).dothrow(new invalidpathexception("","")).when(paths.class); the whole idea trying reproduce bug under english mac, mac default encoding setting us-ascii, path path = paths.get("report_はな.html"); throw invalidpathexception. as documented here , have jump through hoops mock "system" classes, i.e. classes loaded system classloader. specifically, whereas in normal powermock test @preparefortest() annotation identifies class static methods want mock, in "system" powermock test annotation needs identify class calls static methods (usually class under test). for instance,

math - What does positive_to_Qpositive_i in the QArithSternBrocot library do? -

i going through code q_denumerable.v in library qarithsternbrocot , came across. fixpoint positive_to_qpositive_i (p:positive) : qpositive := match p | xi p => nr (positive_to_qpositive_i p) | xo p => dl (positive_to_qpositive_i p) | xh => 1 end. what nr , dl mean? the library name , documentation refers stern-brocot tree , in fact encoding variant of called calkin-wilf tree . one root of tree, number 1, , constructors nr , dl indicate 2 children: if w represents p/q (with p , q coprime, i.e. rational in irreducible form) nr w represents ((p+q)/q) , dl w represents (p/(p+q)). function qpositive_i calculates (numerator, denominator) representation of qpositive value. the function positive_to_qpositive_i calculates calkin-wilf representation of positive integer given in binary notation.

javascript - Nesting callbacks for more than two tasks -

it possible determine order of two tasks using callbacks, shown below. a(b); function a(callback) { // callback(); } function b() { // next } see fiddle first a() , b() . i concatenate more 2 tasks . i´m dealing quite big functions, i´m looking that: a(b(c)); first a() , b() , c() . i'm not successful this. see fiddle is there easy way so, maybe without needing promises? you're calling b immediately, not passing callback a . you'll need use function expression: a(function(aresult) { b(c); }); of course, can avoid these returning closures functions: function a(callback) { return function(args) { // if (callback) callback(res); }; } function b(callback) { return function(aresult) { // next if (callback) callback(res); }; } function c(callback) { return function(bresult) { // next if (callback) callback(res); }; } which call this: a(b(c())(); (this kn

javascript - (Why) Can I not throw an exception out of a generator? -

i'm trying throw exception body of es6 generator function, it's not going through. part of es6 specification or quirk of babel? here code tried ( on babeljs.io ): function *gen() { throw new error('x'); } try { gen(); console.log('not throwing'); } catch(e) { console.log('throwing'); } if indeed specified es6 behavior, what's alternative approach signalling exception? you created iterator didn't run it. var g = gen(); g.next(); // throws 'x' ( on babel repl ) here's example: function *gen() { (let i=0; i<10; i++) { yield i; if (i >= 5) throw new error('x'); } } try { (n of gen()) console.log(n); // throw after `5` console.log('not throwing'); } catch(e) { console.log('throwing', e); }

C# - Prototyping an object model to generate pages from a database -

i'm on c# web dev course, , while have decent understanding of basic c#, have been moved onto object oriented. i have made basic news website, articles including text, images , titles. now c# work have been asked prototype object model allow generation of new articles (title, image, text) database. i'm still new oop, i've been 'thrown deep end of sorts'. the specification have been given this: "the basis of our work articles. our articles have title, 1 or more paragraphs of text, category , image. have following categories: local news; sport. all images have own titles, descriptions , filename. have daily-mail style sidebar “of shame” – these have sidebar items consisting of images, titles , single paragraph of text. both articles , side-bar articles need link address main article page , need able archive articles no longer displayed. home page of our site consists of current articles , sidebar, these both need ordered can display eye-catchin

linux - How can I add a PPA repository using Ansible? -

i'm trying add new repository server can install java ansible. unfortunately whenever try run playbook fails because of gpg error. can explain going wrong here , need in order fix this? i'm using ansible 1.7.2 , connecting localhost. i have simple playbook looks this: - hosts: home tasks: - name: add repositories apt_repository: repo='ppa:webupd8team/java' state=present when try execute it, following error: sal@bobnit:~/workspace$ ansible-playbook --ask-sudo-pass basic.yml sudo password: play [home] ******************************************************************* gathering facts *************************************************************** ok: [localhost] task: [add repositories] ****************************************************** failed: [localhost] => {"cmd": "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 7b2c3b0889bf5709a105d03ac2518248eea14886", "failed": true, "rc"

knockout.js - Access to data out of foreach knockout -

i have 3 similar foreaches, them choose items (chekboxes), these items displayed in data-bind="foreach: selectedbooks" data-bind="text: bookname" . but, how can access choses items outside of used data-bind="foreach: allbooks" , display data in other place. something data-bind="text: $root.username, $root.bookname, $root.somename" saving of order of selected items? i tried use documentations http://knockoutjs.com/documentation/binding-context.html still doesn't work. example http://jsfiddle.net/falkone/acdbrxy7/ you might want use knockout context debugger plugin chrome, it's useful when comes debugging mark up: https://chrome.google.com/webstore/detail/knockoutjs-context-debugg/oddcpmchholgcjgjdnfjmildmlielhof?hl=en

c# - WPF one pixel-wide line sometimes disappears -

Image
i'm trying make control draws red cross in center. want cross 1 pixel wide, , want disable antialiasing , make snap screen's pixels. the control works, if add inside grid has splitter, when drag splitter 1 of lines disappear. if put inside grid horizontal splitter, horizontal line disappear , if put inside grid vertical splitter, vertical line disappear. how can stop lines disappearing? here xaml code: <window x:class="wpftest.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:wpftest" title="mainwindow" height="600" width="800"> <window.resources> <local:halfvalueconverter x:key="halfconv" /> <style targettype="line"> <setter property="stroke" value="red"/>

android - Where to start with making mobile apps with zero programming experience? -

i've got simple question i'm sure won't have simple answer: have number of mobile app ideas 0 programming experience. start if want learn how make ios , google play apps? also, how long think take me reasonably educated , computer literate? you don't make google play apps. create android application publish google play. if want start programming go search tutorials app developing instead of flooding forum.

How to insert into my table from a file in mysql? -

i have file.dat follow: "evan","e","wallis","222222200","1958-01-16","134 pelham, milwaukee, wi","m","92000.00",null,"7" "jared","d","james","111111100","1966-10-10","123 peachtree, atlanta, ga","m","85000.00",null,"6" i insert these values table. i tried following did not succeed. load data local infile "c:/file.dat" table table ; there no error there warning , table not filled data. load data local infile "c:/file.dat" table table 0 row(s) affected, 64 warning(s): 1265 data truncated column 'fname' @ row 1 1261 row 1 doesn't contain data columns... here how table created. create table table( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex c

Android Java - Reading in Text File of Integers, Storing Integers in Array, and Graphing Them -

so, code, trying read in .txt file contains integers, store integers array list via parseint(), , graphing points via graphview. have done debugging code , have noticed none of points being graphed , when test out code printing values array list via label, crashes app. unsure of going on, think on right track in process. here code below. *note: used textview labels tests determine if data read in (in case it's not). in advance! mainactivity.java package com.example.anjanarajagopal.graph; import android.os.bundle; import android.support.v7.app.actionbaractivity; import android.view.menu; import android.view.menuitem; import android.widget.textview; import com.jjoe64.graphview.graphview; import com.jjoe64.graphview.series.datapoint; import com.jjoe64.graphview.series.linegraphseries; import java.io.bufferedreader; import java.io.inputstream; import java.io.inputstreamreader; import java.util.arraylist; import java.util.list; public class mainactivity extends actionbaracti

linux - Find the most common line in a file in bash -

i have file of strings: string-string-123 string-string-123 string-string-123 string-string-12345 string-string-12345 string-string-12345-123 how retrieve common line in bash ( string-string-123 )? you use awk this: awk '{++a[$0]}end{for(i in a)if(a[i]>max){max=a[i];k=i}print k}' file the array a keeps count of each line. once file has been read, loop through , find line maximum count. alternatively, can skip loop in end block assigning line during processing of file: awk 'max < ++c[$0] {max = c[$0]; line = $0} end {print line}' file thanks glenn jackman useful suggestion. it has rightly been pointed out 2 approaches above print out 1 of occurring lines in case of tie. following version print out of occurring lines: awk 'max<++c[$0] {max=c[$0]} end {for(i in c)if(c[i]==max)print i}' file

Crack sha256 when you know the pass form -

is possible write code can crack sha256 hash when know form of password? example password form *-********** 12-13 characters long and: the first char 1 number 1 25 second 1 hyphen in each char third 1 end, can put a...z , a...z , 0...9 after guessing each pass, code converts pass sha256 , see whether result hash equal our hash or not , print correct pass. i know possible numbers big number (26+26+10)^10 want know that: is possible write such code? if yes, possible run whole code in less 1 day (because think takes lot of time complete whole code)? since can't ask write code me, how , can ask code? you cannot "crack" sha256 hash no matter how information know plaintext (assuming crack mean derive plaintext hash). if knew password not determine procedure reversing hash. in technical terms, there no known way perform preimage attack on sha256 hash. that means have resort guessing or brute forcing password: you have prefix, can value in [

javascript - problems with EaselJS getCacheDataURL -

i have problems using getcachedataurl . function work correctly in chrome dont work in ie 10 , firefox. so: var cont = new createjs.container(); var cont.cache(0,0,50,50); var bitmap = new createjs.bitmap(cont.getcachedataurl()); var stage = new createjs.stage(); stage.addchild(bitmap); instead of using todataurl, use cont.cachecanvas source, creates bitmap points canvas created cache. faster exporting canvas image , using image. var bitmap = new createjs.bitmap(cont.cachecanvas); additionally, second line looks wrong: var cont.cache(0,0,50,50); var doing nothing in context.

javascript - Check if array contains? -

write function receives array of foods , checks if contains values "pizza" , "bacon". if either of values missing, add array. var foods1 = [ "cookies", "steak" ]; var foods2 = [ "pizza", "salad" ]; var foods3 = [ "pizza", "salad" , "bacon", "chili" ]; function addfoods(array){ if( !== 'pizza' && !== 'bacon'){ // if it's till here put inside if array.push('pizza'); array.push('bacon'); } } addfoods(foods1); use indexof check see if either food in array , add if not: function addfoods(array){ if (array.indexof('pizza') === -1) array.push('pizza'); if (array.indexof('bacon') === -1) array.push('bacon'); } demo

Spring cloud, config server can not start, how to config uri for git -

i pretty interested in spring cloud project , testing it, blocked immediately. in pom: added dependency: <dependency> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-config-server</artifactid> </dependency> for main application: @configuration @enableautoconfiguration @enableconfigserver public class springconfigserverapplication { public static void main(string[] args) { springapplication.run(springconfigserverapplication.class, args); } } so based on documentation, need add enableconfigserver , tried start it, error: org.springframework.beans.factory.beancreationexception: error creating bean name 'environmentrepository' defined in class org.springframework.cloud.config.server.configserverconfiguration$gitrepositoryconfiguration: invocation of init method failed; nested exception java.lang.illegalstateexception: need configure uri git repository so, how can config ur

reporting services - SSRS 2008 - SubReport page break is ignored -

i have 1 master report contains 3 subreports. 1) subreport lob, contains 4 line charts , table; 2) subreport site, contains 4 line charts , 2 tables; 3) subreport site details, contains 1 table. issue: when master report executes, subreport #1 recognizing pagebreak, subreport #2 & #3 getting combined in subreport #2 though set "page breaka after" in 2 tables in subreport #2. tables positioned @ bottom of line charts. have 1 more subreport created totals 4 subreports in master repor, giving me issue in splitting subreport #2 , #3. please advise. thanks. create new rectangle in report, drag , drop subreport #2 rectangle. right click on rectangle , select rectangle properties. on general tab, click "add page break after" checkbox. should put page break between subreports #2 , #3.

html - How to get the current state of DOM in PHP? -

i have annoying problem. have dynamic website users can create kind of elements. example: start empty list this. <div id="list"> <ul> </ul> </div> then can add list items it. can click print button send list server , create pdf them. works when list not created dynamically. when try real code dynamic html element creation php file not "see" these created elements because looking @ index.html on server. this code works on static pages: <?php require('/mpdf/mpdf.php'); $html = file_get_contents("index.html"); $stylesheet = file_get_contents('css/style.css'); $dom = new domdocument; $dom -> loadhtml('$html'); $save = $dom -> savehtml('$dom'); $list=explode("<div id=\"list\">",$save); $list=explode("</div>",$list[1]); $mpdf = new mpdf(); $mpdf -> writehtml($stylesheet,1); $mpdf -> writehtml($list[0],2); $mpdf->output(

objective c - Is there a way for a method in a derived class to not override the base class method -

i in process of learning objective-c coming c++ background. wanted know if there way derived class method has same signature base class not override it. read every method in objective-c virtual.are there ways in derived class not override base class method simulated ? i have following 2 classes @interface foo_base : nsobject -(void) base_method; -(void) shared_method; @end @interface foo_der : foo_base -(void) der_method; -(void) shared_method; @end and when use this foo_base *b = [[foo_der alloc]init]; [b shared_method]; //derived class method called. i know inside derived class method [super shared_method] //call base class method no, in objective-c if derived class implements base class method same signature, overridden. create "helper" function if want access base class method directly. - (void) callsupersharedmethod { [super sharedmethod]; }

C++ how to read what I want from a file? -

how can assign variable c++ code value structured .txt file example? if have following input.txt structured this: <name> "john washington" <age> "24" <id> "19702408447417" <alive status> "deceased" in c++ code if have ifstream read("input.txt",ios::in); char name[64]; read>>name;//name point john washington string int age; read>>age;// cout<<age return 24; int id; read>>id;// cout<<id return 19702408447417 char alivestatus[32]; read>>alivestatus;//alivestatus point deceased string; how can make work above? as @πάντα ῥεῖ mentioned in comments, need implement parser can interpret <> tags within file. additionally, recommend reconsidering data types. specifically, given there's no special reason you're using char [] , please switch std::string . don't know use case of code, if input.txt happens contain data thats larger si

python - Why are the values being made into "None" instead of "LIVE"? -

this game of life program. when tested it, surrounding(row,col) function returned 0 if configuration file indicated 8 squares made "live." ran test printing board after opening configuration file, , turns out instead of making indicated squares 'live,' ones 'live' 'none' no 'live' values being counted. [[none, none, none, 0, 0, 0, 0], [none, 0, none, 0, 0, 0, 0], [none, none, none, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]] when print board . can't see i'm missing here? live = 1 dead = 0 def board(canvas, width, height, n): row in range(n+1): col in range(n+1): canvas.create_rectangle(row*height/n,col*width/n,(row+1)*height/n,(col+1)*width/n,width=1,fill='black',outline='green') n = int(raw_input("enter dimensions of board: ")) width = n*25 height = n*25 tkinter import * import math window=tk(

Excel 2013 power query - SQL query with a dynamic parameter -

however have looked web cant find simple(!) example show how use , have sql query use in dynamic parameter value. what i'm looking end user able change value in column in spreadsheet (parametertable?) , refresh data using new value parameter. perhaps example describes best i'm after. i have table in excel have 2 columns, named parametername , parametervalue. these have values parm1 , 1 (sorry appears cant post image here) the query this, if 1=1 retrieve current date (this oracle should same other databases) select sysdate dual 1 = 1; how should change above use paramatername , parametervalue, i.e. rightmost "1" changed dynamically value. if value else "1" no results returned. thanks in advance i have way pass parameter power query. make sure works. step 1: create table named "infodesk" in excel, or can name wish. table "infodesk" contains column "script" place sql script in column. step 2: create

How do you define custom hash for strings in ruby? -

i hash strings in ruby characters in each string without order, example want anagrams have same hash value. is possible? how about: require 'digest' string = "mysupersamplestring" sorted = string.chars.sort.join p sorted # => => "msssaeegilmnpprrtuy" digest::md5.hexdigest(sorted) # => "ef86bea3ade82ae7bf0409952bc83fd7" chars "splits" string letters sort sorts letters array join joins array of letters 1 string hope helps!

ios - Changing the layout of an AlertController -

i have used following code try , change layout of uialertcontroller using nib dialog shows , looks same each time regardless of nib specified, looks translucent grey box, @ bottom of screen. class alertdialogviewcontroller: uiviewcontroller { var message: string = "" override init() { super.init(nibname: "signupviewcontroller", bundle: nil) //below 2 lines important custom transitions. transitioningdelegate = self modalpresentationstyle = .custom } required init(coder adecoder: nscoder) { super.init(coder: adecoder) } //other code dialog controller // . // . // . } extension alertdialogviewcontroller : uiviewcontrolleranimatedtransitioning { func transitionduration(transitioncontext: uiviewcontrollercontexttransitioning) -> nstimeinterval { return 0.5 //add own duration here } func animatetransition(transitioncontext: uiviewcontrollercontexttransitioning) { //add presentation , dismiss animation transition here. } } extension

autohotkeys expression not evaluating -

i have simple autohotkeys macro test if window active. if it's active, want stop until window becomes inactive , re-activated again. the problem test whether window inactive not working. here code: ^w:: ;hotkey fires done = false settimer, checkpopups, 10000 ; check every 10 seconds annoying popup checkpopups: if ( winactive("volume spike - down") ) { ;specific lines when active window true msgbox (%done%) if (!done) { msgbox hello done := true } } ifwinnotactive volume spike - down { done = false msgbox not } return when runs, first message box indicating state of done (which false @ beginning). (!done) not evaluate true , second message box (hello) not fired. idea wrong here? autohotkey conceives true / false -boolean expressions 1 / 0 . if you, wouldn't use former keywords @ all. but still, can, have change initialisation to done := false (store expression). done = false same done := "false" (string assi

shader - GLSL lightsaber - per vertex lighting -

i'm using script render lightsaber (in blender), works fine until start rotating lightsaber: @ point blade goes crazy. please suggest me better way write code? looked (to me) best way achieve this, there surely smarter ones. vertexshader = """ varying vec3 varyingnormaldirection; varying vec3 varyingviewdirection; void main() { varyingnormaldirection = normalize(gl_normalmatrix * gl_normal); varyingviewdirection = normalize(gl_modelviewmatrix * gl_vertex); gl_position = gl_modelviewprojectionmatrix * gl_vertex; } """ fragmentshader = """ varying vec3 varyingnormaldirection; varying vec3 varyingviewdirection; void main() { // project 2 vectors on plane y = 0 vec2 normaldirection = normalize(varyingnormaldirection.xz); vec2 viewdirection = normalize(varyingviewdirection.xz); const vec4 color = vec4(1.0,1.0,1.0,0.3); // opacity equals infinity when view , normal have angle of 0, // equals 0.

mysql - JSON Object building in SQL. Should I build the objects in SQL or in my Application? -

i generating json objects via sql query, however, thinking should building objects in application logic (node.js) instead. given following structure , query; way query data transformed? for full example @see http://sqlfiddle.com/#!9/81cf5/1 ** expected output json ** { id: <int> parent_comment_id: <int> content: <string> created: <int> user: { id: <int> username: <string> name_first: <string> name_last: <string> } tags: { <string>:<int|string> } } table structure create table `comment` ( `id` bigint(20) unsigned not null auto_increment, `parent_comment_id` bigint(20) unsigned default null, `user_id` bigint(20) unsigned not null, `content` text character set utf8mb4 collate utf8mb4_unicode_ci, `created` timestamp not null default current_timestamp, primary key (`id`) ) engine=innodb ; create table `comment_tag` ( `id` bigint(20)

android - Intents and google maps api v2 -

i know question silly, i'm bit confused intents.from code below want separate in 2 classes showmap , locationmap.how can this??the fist contain map(fragmentactivity), call second class in want find user's current location , return marker map(first activity).thanks in advance!here class want separate: public class locationmap extends fragmentactivity implements locationlistener{ private googlemap googlemap; private latlng latlng; textview tvlocation; markeroptions markeroptions; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.location_maps); // getting google play availability status int status = googleplayservicesutil.isgoogleplayservicesavailable(getbasecontext()); // showing status if(status!=connectionresult.success){ // google play services not available int requestcode = 10; dialog dialog = googleplayservicesutil.geterrordialog(status, t

cypher - How to add weight as label to vertex? -

i want add weight vertex. i have first step going in r-studio. following code gives dataframe weight: query = " match (p)-[:refers_to]->(q)<-[:refers_to]-(r) (id(p) < id(q)) return q.name, count(q) weight order weight desc " newvalue = cypher(graph, query) how can weight added vertex label? following not work me because adds weight node instead of vertex: query = " match (p)-[:refers_to]->(q)<-[:refers_to]-(r) q.name, count(q) weight set q.weight = weight " cypher(graph, query) thanks! i think you're trying add weight edge (or relationship) rather node (or vertex). in order add weight property of edge, need bind variable, , can set property before: query = " match (p)-[r1:refers_to]->(q)<-[r2:refers_to]-(r) q.name, count(q) weight set r1.weight = weight, r2.weight = weight " cypher(graph, query) note can't tell of relationships want weight on, in example i'm doing both. thing here i'm bin

c++ - How to run valgrind with basic c example? -

installation: bzip2 -d valgrind-3.10.1.tar.bz2 tar -xf valgrind-3.10.1.tar then: ./configure make make install or simplier sudo apt-get install valgrind how run valgrind on simple program example1.c #include <stdlib.h> int main() { char *x = malloc(100); /* or, in c++, "char *x = new char[100] */ return 0; } run: valgrind --tool=memcheck --leak-check=yes example1 valgrind: example1: command not found output console: valgrind: example1: command not found it looks good. need add ./ before executable. without it, valgrind fails find , reports 'command not found' . valgrind --tool=memcheck --leak-check=yes ./example1 ^

jquery - paragraph Select() doesn't work in javascript -

here html code <div id="dialog" title="basic dialog" style="display: none"> <p id="para">copy key</p> <p id="key">4567887654345678</p> </div> <button>open dialog</button> the div appears dialog on button click, , have "key" text selected when dialog opens here javascript same, < p> doesn't appear selected $(function() { $( "button" ).click(function() { $("#dialog" ).dialog(); $( "#dialog" ).show( "slow" ); $("#key").select(); }); }); how can make < p> pre-selected ? change key paragraph editable element, such textarea: <textarea id="key">4567887654345678</textarea> jsfiddle it appears need editable text field select text in.

C# Convert Color to argb -

this question has answer here: convert color byte value 4 answers how convert color argb array int pseudo example color color=nw.getpixel(i, j); int[] argbarray = color.toargbarray(); result: argbarray[0]=255 (alpha) argbarray[1]=241 (red) argbarray[2]=128 (green) argbarray[3]=69 (blue) i searched through google, did not give sense of needed i googled c# color bytes , first result convert color byte value still no sense? btw: way be: color color = color.fromargb(1,2,3,4); //alpha,red, green, blue var argbarray = bitconverter.getbytes(color.toargb()) .reverse() .toarray(); argbarray[0]=1 (alpha) argbarray[1]=2 (red) argbarray[2]=3 (green) argbarray[3]=4 (blue)

Parsing Google News RSS with PHP -

i want parse google news rss php. managed run code: <? $news = simplexml_load_file('http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=n&output=rss'); foreach($news->channel->item $item) { echo "<strong>" . $item->title . "</strong><br />"; echo strip_tags($item->description) ."<br /><br />"; } ?> however, i'm unable solve following problems. example: how can hyperlink of news title? as each of google news has many related news links in footer, (and code above includes them also). how can remove description? how can image of each news also? (google displays thumbnail image of each news) thanks. there go, need particular situation: <?php $news = simplexml_load_file('http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=n&output=rss'); $feeds = array(); $i = 0; foreach ($news->channel->item $

iteration - function doesn't continue to loop -

my function acting little bit weird. def cow_latinify_sentence(sento): ''' converting english cow latin ''' alpha = list("bcdfghjklmnpqrstvwxyz") finale = [] worda = "" word in sento.split(): finale.append(word) in finale: if i[0].lower() in alpha: lista = list(i.lower()) worda = worda.join(lista[1:] + [lista[0]]) + "oo" else: return word + "moo" return worda when run sentence like: cow_latinify_sentence("cook me eggs") it returns: ookcoo . correct, doesn't loop around other words in sentence. the function should return: ookcoo emoo omesoo eggsmoo in addition that, if have sentence like: cow_latinify_sentence("aran likes art") it returns last element ( artmoo ) in sentence being converted so i'm guessing issue loops. i've tried changing positions of return state

osx - NSTableView single click action -

how capture event of single-clicking on row of nstableview , trigger action? (idealy, should trigger action left clicks only, not right clicks, not required.) implementing -tableviewselectiondidchange of table view's delegate close want. however, if row selected, clicking on row again doesn't call -tableviewselectiondidchange since selection didn't change. connect selector action event on table view (better interface designed), - (ibaction)onaction:(id)sender { nstableview* tableview = (nstableview*)sender; // use tableview.selectedcolumn/tableview.selectedrow selection } you can connect code if want fro viewdidload: [self.tableview setaction:@selector(onaction:)];

Sending print output to a file in Python script -

this question has answer here: correct way write line file? 8 answers how go sending output of print command new file? have python script need redirect output @ end of print statement file can't seem find way accomplish redirect. why doesn't "print (stuff redirected) > newfile.txt" work? any appreciated! as mentioned in this post , set standard output file object. import sys sys.stdout = open('file', 'w') then, print statements should go directly file.

java - Autowiring by constructor in Spring creating more objects -

i creating demo understand how can inject prototype bean singleton bean using constructor autowiring. here code first bean is public class independentbean { private string independentname; public independentbean() { system.out.println("independent called"); } public string getindependentname() { return independentname; } public void setindependentname(string independentname) { this.independentname = independentname; } } now creating independent bean package com.sample.beans; public abstract class dependentbean { private independentbean d1; private independentbean d2; public dependentbean() { system.out.println("default constructor dependent"); } public independentbean getd1() { return d1; } public void setd1(independentbean d1) { system.out.println("setting d1"); this.d1 = d1; } public independentbean getd2() {

css3 - Trouble with dropdown menu and what CSS to use when styling the parent menu button -

how keep text in parent button in main menu indented when hover on child menu options? here work in progress: http://sr.hi-speedinter.net/ the rollover state top level button in main menu has blue tab behind button requires padding added when hovered over. in off state, menu wording has vertically line content below it. in other words, first child (labelled 'staging') has move horizontally depending on state. i have managed keep blue tabs applies when hovering on child, can't seem affect word in first-child only. i have thought .primary-navigation li:first-child:focus:active > would correct, doesn't expect. i've done quite bit of research , several times thought had answer..but no joy. can tell me how this?

How to Revert in-built Dataset in R? -

how revert in-built dataset in r? happened transform it, want use original datset now. if mtcars dataset got transformed, calling data(mtcars) again original dataset. ie. mtcars <- mtcars[,2:3] ncol(mtcars) #[1] 2 data(mtcars) ncol(mtcars) #[1] 11

variables - C++ int with preceding 0 changes entire value -

i have strange problem if declare int so int time = 0110; and display console value returned 72 . when remove 0 @ front int time = 110; console displays 110 expected. two things i'd know, first of why preceding 0 @ start of int , there way stop 0110 @ least equals 110 ? secondly there way keep 0110 returns 0110 ? if take crack guess @ variable name i'm trying operations 24hr time, @ point time before 1000 causing problems because of this. thanks in advance! an integer literal starts 0 defines octal integer literal. in c++ there 4 categories of integer literals integer-literal: decimal-literal integer-suffixopt octal-literal integer-suffixopt hexadecimal-literal integer-suffixopt binary-literal integer-suffixopt and octal-integer literal defined following way octal-literal: 0 octal-literal opt octal-digit that starts 0. thus octal integer literal 0110 corresponds following decimal number 8^2 + 8^1 that equal 72

java - Writing to the datastore without closing Persistence Manager -

how commit database when updating object using persistencemanager without closing it? you need commit transaction. don't need close persistencemanager. persistencemanager p; ... p.currenttransaction().begin(); .... //do work p.currenttransaction().commit();

mongodb - Combining koa-passport with koa-router (getting user data) -

i have created login able login user , store user if new in database. the user redirected / , checked if authenticated or not, see below (app.js): .get('/', function* () { if (this.isauthenticated()) { yield this.render('homesecure', {}); // <-- need user data here } else { yield this.render('homepublic', {}); } as commented in code, send user object of logged in. have no idea how hold of id of person logged in documentation koa in general not complete of express. i using koa-generic-session-mongo handle sessions. here googlestrategy (auth.js): var user = null; // ... var googlestrategy = require('passport-google').strategy; passport.use(new googlestrategy({ returnurl: 'http://localhost:' + (process.env.port || 3000) + '/auth/google/callback', realm: 'http://localhost:' + (process.env.port || 3000) }, function (identifier, profile, done) { var emails =