Posts

Showing posts from June, 2014

php - How to fetch data from an Array -

hi have written class data database, , in view creating instance of class data. everything seems working fine, when use print_r($emp_data) in view. returns data in following format, array ( [0] => 1 [emp_id] => 1 [1] => aftab [first_name] => aftab [2] => kirmani [last_name] => kirmani [3] => male [gender] => male [4] => 1 [added_by] => 1 ) but when use foreach loop gives me error message. warning: illegal string offset 'emp_id' in e:\xampp\htdocs\emp_management\views\view_all_employees.php on line 11 following code have written. class method public function get_employees(){ $query= "select * employees"; $query_run= mysqli_query($this->conn, $query); if(mysqli_num_rows($query_run) > 0){ $data= mysqli_fetch_array($query_run); return $data; } } view <?php

sql server - What is the best solution to design sql table relationship for a table that will be used by other tables -

i came upon rather interesting situation need guidance me design database schema follows "best practises" or done "the recommended way". my dilemma follows: i have event table basic properties such id, name, date etc. needs address info straight forward way extend table fields such street, city, country etc. have user table needs store address data. right thing create third table called address , set relationships between address/user , address/event. tricky part. table should hold primary key/foreign key. one way extend table address columns such eventid , userid . tables event , user "parent" table , address "child" table. address table hold foreign keys user/event's id primary keys. |eventtable:| |usertable: | |addresstable| | | | | | | |eventid pk | |userid pk | |addresid pk | |name | |name | |street | |othercolumn| |othercolumn| |city |

http - How do I trace the GET request from this html code? -

Image
after hitting submit in filling below form, <h1>our contact form</h1> <hr> <form action="process_form.php" method="get"> <p> title: <input type="radio" name="title" value="mr"> mr <input type="radio" name="title" value="mrs"> mrs </p> <p> first name:<br> <input type="text" size="15" name="first_name"> </p> <p> sur name:<br> <input type="text" size="15" name="surname"> </p> <p> gender: <select> <option value="select">select gender</option> <option va

What Redis data type fit the most for following example -

i have following scenario: fetch array of numbers (from redis) conditionally for each number async stuff (fetch db based on number) for each thing in result set db async stuff periodically repeat 1. 2. 3. because new numbers added redis structure.those numbers represent unix timestamp in milliseconds out of box numbers sorted in time of addition conditionally means fetch unix timestamp redis less or equal current unix timestamp in milliseconds( date.now() ) question redis data type fit use case having in mind code scaled n instances, n instances share access single redis instance. equally share load each instance read example first(oldest) 5 numbers redis. numbers unique (adding same number should fail silently) redis set seems choice reading m first elements redis set seems impossible. to prevent 2 different instance of code read same numbers redis read operation should atomic, should read numbers , delete them. if async operation fail on specific number ( steps 2

python - Get literal prefix of regex pattern -

here problem: there list of thousands of regular expressions. need regular expression matches given string. hopefully , these regexes mutually exclusive, if several regexes matching @ same time, i'm ok returning any of them. i assume of regular expressions starts literal prefix e.g.: " some_literal_string(?:\?some_regular_part)? " → " some_literal_string " i'd try following data structure make search fast: regexes = [index=prefix_length:{key=prefix:{*prefixes}] now, find prefix, need iterate index min(len(string), len(longest_prefix)) down 0 , extract subset of regexes: subset = regexes[i][string[0:i]] now need check each element match , if pattern found, return it, otherwise, continue next index . the question is: how literal prefix of regular expression in common case? i came following regular expression: (?:[^.^$*+?{\\[|(]|(?:\\(?:[^\dabbddsswwz]|0|[0-7]{3})))*(?![*?|]|{\d+(?:,\d*)?}) it's needed replace backsla

regular language - Theory of computation GATE 2012 -

Image
4) consider set of strings on {0,1} in which, every sub string of 3 symbols has @ 2 zeros. examples, 001110 , 011001 in language, 100010 not. strings of length less 3 in language. partially completed dfa accepts language shown below. the missing arcs in dfa i preparing gate next year why have taken gate question regarding question appreciated.thank you! answer option (d). first start language must not have 3 consecutive 0's. so,0 input 00 state must go dead state(q).and it's define in option (c) , (d). now,we have 2 option left. see state 10. in option (c) 0 input state 10 goes 10 only, it's loop , number 0's 10 it's stay on 10 , 10 final state it's accept language no of consecutive 0's , must not happen. left option (d) , (d) 0 input 10 goes state 00 , 1 more 0 00 it's goes dead state won't accept 3 consecutive 0's , our language want.and dfa should this. and done in option(d).sorry bad english.

javascript - How to order an array of ranges by position -

i range this, in div contenteditable mode : var sel = document.getselection(); var range = sel.getrangeat(0).clonerange(); //... comments.push(range); the text in div has html tags <br> , <mark> (highlighted comments). range.startoffset , range.endoffset concern container (and not div contenteditable mode), don't know how order ranges according position in text (from top bottom). help me, please. if want sort ranges starting positions, can use comments.sort(r1, r2) { var comp = r1.startcontainer.comparedocumentposition(r2.startcontainer); if(comp & node.document_position_following) return -1; if(comp & node.document_position_preceding) return +1; return r1.startoffset - r2.startoffset; }

need help a query in sql server 2008 -

hi have doubt in sql server table : patient patientno | refdoctor| loccode | status | sdate 100 | 31 |10 | 1 | 2012-05-03 100 | 32 |10 | 1 |1997-02-04 100 | 36 |10 | 1 |2014-09-16 100 |35 |10 | 1 |2013-05-03 100 | 50 |10 | 1 | 1988-05-08 100 | 20 |10 | 2 |2015-02-05 table : targetpatient patientno | refdoctor| loccode | status | sdate 100 | 21 | 10 | 2 | 2004-05-18 100 | 23 | 10 | 2 |2005-07-25 100 | 24 | 10 | 2 | 2006-06-22 100 | 26 | 10 | 2 |2012-05-14 100 | 28 |10 | 2 |2013-05-03 100 |29 |10 | 2 | 2014-09-26 100 | 33 | 10 | 2 | 2012-10-22 100 | 39 | 10 | 2 |2002-12-13 100 |41 | 10 | 2 |2012-05-13 here wa

excel - Clicking a button on a userform (calling the a button click event) -

i'm trying automate macro converts excel table latex source code simple macro. don't want use userform, i'm trying call button click of desired output want, i'm having problems. it excel2latex macro on ctan.org userform here project layout here here main sub, can see commented parts different things i've been trying after searching help. sub latex() newcontroller set .view = newview set .model = newdefaultmodel set .storage = newstorage .run application.wait + timevalue("00:00:02") frmconvert.cmdsave.object.value = true 'userform2.commandbutton1.object.value = true 'frmconvert!cmdsave.setfocus 'sendkeys "{enter}" 'call frmconvert.cmdcopy_click 'call frmconvert.cmdsv 'call frmconvert.cmdcopy_click 'call memento.saveconversionresulttofile 'application.wait + timevalue("00:00:03") 'application.run "frmconvert.cmdcopy_click

c# - How do you consume a core MVC WebApi into another Core MVC Application as of now? -

Image
i want separate presentation layer , business logic layer web service. have read wcf practically dead. looking information on how consume webapi(mvc6 web api) mvc6 or recommended way connect presentation layer web service business layer of now. i have seen older documents saying doing 1 way since been year since documents have been released assuming there better way now. you can use asp.net webapi expose data business layer presentation layer can achieved creating project of type asp.net webapi in following screenshot for more information on how achieve can refer following link describe how started mvc6 webapi creating asp.net web api mvc 6

mysql - sending variables to table PHP SQL -

im trying send variables table error $title , $body: undefined variable: title in c:\wamp\www\source\pishnahad.php on line 237 notice: undefined variable: body in c:\wamp\www\source\pishnahad.php on line 237 <div class='container' dir="rtl" > <label for='name'>نام: </label> <input type='text' name='name' id='name' value='<?= $fgmembersite->userfullname() ?>' maxlength="50" disabled="disabled"/><br/> </div> <div class='container' dir="rtl" > <label for='email'>ایمیل: </label> <input type='text' name='email' id='email' value='<?= $fgmembersite->useremail() ?>' disabled="disabled"/><br/> </div> <form name="form2" method="post" action="submit_shekayat" accept-charset='utf-8'> <div class=

Oracle SQL - Getting Max Date with several joins -

i think may overthinking this, i'm having issue when trying find max date several joins in oracle database several clauses. i've found many examples of simple max queries, nothing this. query works fine if add line in find records above specific date (there handful of results returned). however, want automatically recent date records bill table. database has additional table actual bill amount stored, adds layer. select p.purchase_id, p.account_id, b.bill_date, bp.current_amount purchases p join bill_purchases bp on p.purchase_id = bp.purchase_id join bills b on bp.bill_id = b.bill_id --need recent date bill table each bill p.type != 'cash' , bp.amount > '100.00' , p.status = 'approved' , p.purchase_id in ( ... list of purchases ...); i have tried doing subqueries max functions in them, not having luck. each query returns same amount of records original query. how rearrange query still retrieve of necessary columns , clauses while still

php - How to do a basic URL rewrite with mod_rewrite -

i don't understand why when use this: #rewriterule ^/?r/(.*)$ /index.php?n=$1 [l] to rewrite mysite.com/r/somewhat mysite.com/index.php?r=somewhat site work. but if use this: #rewriterule ^/?(.*)$ /index.php?name=$1 [l] to rewrite mysite.com/somewhat mysite.com/index.php?r=somewhat , site stop working. i don't understand why. can me? how can rewrite mysite.com/somewhat mysite.com/index.php?r=somewhat ? your 2nd rule cause infinite looping since target uri /index.php?r=somewhat matches .* . causes 500 internal server error. to fix need avoid rewriting files , directories using rewritecond this: rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^/?(.+)$ /index.php?r=$1 [l,qsa]

javascript - What is the difference between importing a function expression or a function declaration from a ES6 module? -

as understand ( see section 16.3.2.1 ), es6 allows different syntaxes function / class export operands. difference refers whether exported function needs interpreted @ import function declaration, in case write: export default function () {} // (a) or function expression: export default (function () {}); // (b) . as possible related sidenote: read imports hoisted, i'm not sure means in context. taking case of example: import foo 'my_module'; // (c) as understand it, above statement save exported function in foo variable. variable hoisted, or is, , when? most importantly, difference (in terms of setting foo ) when my_module exports function using (a) , when exports using (b) ? your question bit convoluted i'll try best explain everything. let's first establish how modules work in general. module has set of exported names, each of refer local variable in module. name of export not need same of local binding. 1 of exported names can default

javascript - Change div height to child div's height on click with JS -

i have div (divchatcontainer) top div (divchatcontainertop) have "span" element inside it. want container div resized "divchatcontainertop" height when "span" element clicked (ie: minimize chat window "divchatcontainertop" appears). html code: <div id="divchatcontainer" runat="server" style="overflow-y: scroll; box-sizing: border-box; word-wrap: break-word; width: 20%; max-height: 35%; position: fixed; right: 0px; bottom: 0%; box-sizing: border-box; background-color: #ebecef; border: solid #3a5896; border-width: 1px 0px 0px 1px; border-radius: 1px;"> <div id="divchatcontainertop" style="text-align: right; box-sizing: border-box; width: 100%; padding: 3px;"> <span style="float: left; box-sizing:border-box;width:50%;overflow:hidden;">left</span><span id="spanchatminimize" style="float: right">x</span>

c# - Circle line segment collision on corners -

Image
i found 2 amazing tutorials how detect , handle circle vs line segment collision. seb.ly tuts plus and implemented in c# without problems. solution because clean , simple 1 understand. there not explained how handle collisions on line ends/corners. whats best way add feature? on left side illustrated how function behave far. on right how want behave. cases 1 , 2 working great, how want. in case 3 circle not collide. have implement on right side. don't know how work. far have this: // line defined 2 points. // circle define point , radius. public static bool circlevsline(circle circle, vector2d circledirection, ref vector2d circlesolved, line line) { // circle position before movement. vector2d circle0 = circle.position; // circle position after movement. vector2d circle1 = circle.position + circledirection; vector2d linedirection = line.position1 - line.position0; vector2d linenormal = new vector2d(linedirection.y, -linedirection.x).norma

php - BDD Behat change expected value based on profile -

my behat feature file scenario: verify docs given i'm on "/docs" should see "link1" link href of "https://server1.xyz.com/link1" should see "link2" link href of "https://server1.xyz.com/link2" should see "link3" link href of "https://server1.xyz.com/link3" should see "link4" link href of "https://server1.xyz.com/link4" should see "link5" link href of "https://server1.xyz.com/link5" the expected value links changes based on profile. say, if run using server1 profile, link i'm expecting link1 "" https://server1.xyz.com/link1 " , if want run using server2 profile, link link5 i'm expecting "" https://server2.xyz.com/link5 ". so possible use parameter file example profile: server1 linkvar1: "https://server1.xyz.com/link1" linkvar2: "https://server1.xyz.com/link2" profile: server2 linkvar1: &

hadoop - Hive action fails in Oozie executed from Hue UI -

i executing oozie hive action , fails in hue ui following exception in hive logs: 2016-07-15 15:27:58,430 error org.apache.thrift.server.tthreadpoolserver: error occurred during processing of message. java.lang.runtimeexception: org.apache.thrift.transport.ttransportexception: unsupported mechanism type plain @ org.apache.thrift.transport.tsaslservertransport$factory.gettransport(tsaslservertransport.java:219) @ org.apache.hadoop.hive.thrift.hadoopthriftauthbridge$server$tugiassumingtransportfactory$1.run(hadoopthriftauthbridge.java:739) @ org.apache.hadoop.hive.thrift.hadoopthriftauthbridge$server$tugiassumingtransportfactory$1.run(hadoopthriftauthbridge.java:736) @ java.security.accesscontroller.doprivileged(native method) @ javax.security.auth.subject.doas(subject.java:360) @ org.apache.hadoop.security.usergroupinformation.doas(usergroupinformation.java:1651) @ org.apache.hadoop.hive.thrift.hadoopthriftauthbridge$server$tugiassumingtransportfactory

java - Opening existing embedded neo4j database -

i trying use scala on embedded jave neo4j api. having trouble opening database reading on subsequent occasions. code below should create 2 nodes , edge every time runs, return of them @ begining of each run. so, 0 nodes first time, 2 nodes second time, 4 third time etc. import org.neo4j.tooling.globalgraphoperations import org.neo4j.graphdb.factory.graphdatabasefactory import org.neo4j.graphdb.relationshiptype object tester extends app{ val db_path = "data/neo4j" object knows extends relationshiptype { override def name(): string = "knows" } val graphdb = new graphdatabasefactory().newembeddeddatabase(db_path) //seems reset whole directory println(graphdb) try { println("begin") val tx = graphdb.begintx() // database operations go here println(globalgraphoperations.at(graphdb).getallnodes.iterator) val nodes = globalgraphoperations.at(graphdb).getallnodes.iterator while (nodes.hasnext()) { println(nodes

c# - How to bind combo box to another value than the actual by offsetting it? -

i have combo box marked follows. <combobox selectedindex="{binding path=bonkey}"> <comboboxitem content="monkey" /> <comboboxitem content="donkey" /> </combobox> i'm binding object has bonkey field types integer, according declaration below. class thingy { public int bonkey {get; set; } ... } although works great , supposed to, there's programmatically technical issue keeping me @ night. indexes generated in manual mark 0 , 1. however, know values of integers 1 , 2. (i.e. monkey indexed 0 when related combo box item it's actual value in object used data source 1. analogously, monkey has index 1 in items of combo box corresponds 2 in object.) my intermediate solution knock off 1 in constructor right before setting data context, followed kick 1 when view being disposed. it's working can't proud, speak. public somedialog(thingy thingy) { initializecomponent(); thingy.bonkey--; dataco

sql server - Loop in a .bat file with different parameters -

i have .bat file renders ssrs reports in pdf format. report accepts 2 parameters studentid , subjectid. runs fine when try pass in each studentid , subjectid. i .bat file execute stored procedure has list of studentid , subjectid , run/loop through each studentid , subjectid. below .bat file code. @setlocal enableextensions enabledelayedexpansion @echo off set varserverpath=http://xyz/reportserver sqlcmd -q "exec dbo.storedproc_studentlist" -s servername -d databasename loop: rs -i c:\reportrender\student.rss -s%varserverpath% -e exec2005 -v studentid="36" -v subjectid="500" -v voutputfilepath="c:\reportrender\output\zyzreport.pdf" -v vreportpath="/student reports/reportname.rdl" -l 900 pause exit how can loop through "rs" command each results of stored procedure dbo.storedproc_studentlist this stored proc returns select '1' rownumber,'1789' studentid, '364' subjectid, 'c:\re

jquery - Add to current CSS top value -

i have jquery: $(".ta").siblings(".aname:eq(0)").css("top",+=$(".text").height()+15); but not working. have tried way too: $(".ta").siblings(".aname:eq(0)").css("top",'+=$(".text").height()+15'); but did not work. you have grab current top value, , add new value, , append "px" on when set value using .css() here like: var element = $(".ta").siblings(".aname:eq(0)"); var currtop = number(element.css("top").replace("px", "")); var amounttoadd = $(".text").height() + 15; $(element).css("top", (currtop + amounttoadd + "px")); and here working demo

php - Trigger MSQL big issue, sql not working? -

i trying build trigger, problems is not working. have syntax problems. need build trigger update table record in same table before table has been been updated. trigger below describes want not work. $deletequery = ' delimiter // create trigger after_insert_job_sent after insert on envato_customconfig_job_sent each row begin delete `envato_customconfig_job_queue` job_id = '.$value['job_id'].' , email -'.$value['email'].'; update `envato_customconfig_job_status` set `email_sent_count`= email_sent_count+1 job_id = '.$value['job_id'].' end; // delimiter; insert envato_customconfig_job_sent values ( null , '.$value['job_id'].', '.$value['email'].', now(); '; edit: why query append other records aswell?.... working on update add 1 last rec

r - How to remove certain special character occurrences from some elements in a vector? -

i have vector filled numbers read .csv file, of numbers preceded * ,that is, 12 34 *89 *45 34 i want remove * these elements while retaining types, is 12 34 89 45 34 how do this? try: as.integer(stringi::stri_extract_all(x, regex = "[[:digit:]]+", simplify = true)) which gives: #[1] 12 34 89 45 34

jquery - How to get atributes in <tr> tag when clicking an anchor inside a <td> that points to javascript function -

so need help. i have query sql database wich returns array data table. then have insert array data rows of table. this code block fills table data array: for ($i = 0; $i < $size; $i++) { print (" <tr> <td>".$users[$i][0]."</td> <td>".$users[$i][1]."</td> <td>*****</td> <td><a href='javascript:delete_user();'><img src='images/delete.png'/></a>/td> </tr> <tr>"); } when click in anchor points javascript function delete_user(); the function delete_user(); function delete_user() { $.ajax({ type: "get", url: "delete_user.php" , data: { id: "table row id here" }, success : function() { window.location.href='utilizadores.php'; } }); } i trying solve , if add atribute tag maybe jquery or js can it. my first attempt: for ($i = 0; $i < $size; $i++) { p

interpreter - Why is a part of my Python code interpreted diffently when I add a seemingly unrelated part? -

some background: i'm implementing gui interact equipment via gpib. issue arises in method: from tkinter import * tkinter import ttk import visa #pyvisa package. pyvisa.readthedocs.io time import sleep import numpy np #numpy package. scipy.org def onedsweep(): voltage =[] current =[] source = [] try: #gate = parsegate(gate1input.get()) #not implemented yet. min = float(gate1mininput.get()) #add check valid input #if min < .001: #throw exception max = float(gate1maxinput.get()) #add check valid input voltageinterval = .02 #prompt user interval? rm = visa.resourcemanager() sim900 = rm.open_resource("gpib0::1::instr") #add check session open. x = 0 volt = min while volt <= max: sim900.write("sndt 1, 'volt " + str(volt) + "'") #set voltage. sim900.write("sndt 7, 'volt? 1'") #ask port voltage. vnow = sim900.query("getn? 7, 50") #retri

Reading YAML config file in python and using variables -

say have yaml config file such as: test1: minvolt: -1 maxvolt: 1 test2: curr: 5 volt: 5 i can read file python using: import yaml open("config.yaml", "r") f: config = yaml.load(f) then can access variables config['test1']['minvolt'] style-wise, best way use variables config file? using variables in multiple modules. if access variables shown above, if renamed, need rename every instance of variable. just wondering best or common practices using variables config file in different modules. you can this: class test1class: def __init__(self, raw): self.minvolt = raw['minvolt'] self.maxvolt = raw['maxvolt'] class test2class: def __init__(self, raw): self.curr = raw['curr'] self.volt = raw['volt'] class config: def __init__(self, raw): self.test1 = test1class(raw['test1']) self.test2 = test2class(raw['t

angularjs - ng-repeat overrides property in function but not in view model -

i new angular , have problem using custom directive ng-repeat. want display posts rest interface , use _id property inside directive other purposes. however, turns out property 1 last displayed post when used inside function (test in sample below). when trying display id directly on viewmodel shows right one. hope makes sense. appreciated. //directive.js angular.module('app').directive('gnpost', mygnpost); function mygnpost() { return { restrict: 'e', controller: 'postctrl', controlleras: 'postctrl', bindtocontroller: { post: '=' }, scope: {}, templateurl: 'template.html' }; }; //controller.js angular.module('app').controller('postctrl', mypostctrl); function mypostctrl(postrestservice) { vm = this; vm.test = function () { return vm.post._id; }; }; // template.html <p>{{postctrl.post._id}}</p> //

javascript - How to initiate Gmaps in hidden element -

i have 1 element (#hidden-element) hidden default. when click on button (#btn-toggle) want make element visible. now, fine. element shows up, if click on button first time, maps won't shows up. click hide element, again show hidden element second time , map here. so, question is, how can shure map shows first time (i thing have initialize maps or that) , can somehow destroy map object? , destroying map object necessary? $(document).ready(function(){ // function showing map markers - gmaps4rails gem function showmap(){ var handler = gmaps.build('google'); handler.buildmap({ internal: {id: 'multi_markers'}}, function(){ var markers = handler.addmarkers([ { lat: 43, lng: 3.5}, { lat: 45, lng: 4}, { lat: 47, lng: 3.5}, { lat: 49, lng: 4}, { lat: 51, lng: 3.5} ]); handler.bounds.extendwith(markers); handler.fitmaptobounds(); }); } // hide element when docum

java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable error -

hi have problem importing support.v7.appcompat. imported android.support.v7.app.appcompatactivity libs folder, when start running log: 11-01 17:35:42.669: e/androidruntime(1873): fatal exception: main 11-01 17:35:42.669: e/androidruntime(1873): java.lang.noclassdeffounderror: android.support.v7.appcompat.r$styleable 11-01 17:35:42.669: e/androidruntime(1873): @ android.support.v7.app.appcompatdelegateimplbase.oncreate(appcompatdelegateimplbase.java:109) 11-01 17:35:42.669: e/androidruntime(1873): @ android.support.v7.app.appcompatdelegateimplv7.oncreate(appcompatdelegateimplv7.java:146) 11-01 17:35:42.669: e/androidruntime(1873): @ android.support.v7.app.appcompatactivity.oncreate(appcompatactivity.java:59) 11-01 17:35:42.669: e/androidruntime(1873): @ morisson.notowaniagieldowe.mainactivity.oncreate(mainactivity.java:17) 11-01 17:35:42.669: e/androidruntime(1873): @ android.app.activity.performcreate(activity.java:5104) 11-01 17:35:42.669: e/androidruntime(18

java - How to change Javafx default app image/icon/thumb -

i developed javafx application. want change java default icon of .jar file. tried primarystage.geticons().add(icon); but make change left top corner icon when running app not external view image. screenshot below: http://i.stack.imgur.com/gosha.png want change icon actually. all jar files have same icon , depends on os show icon on file depending on file type. primarystage.geticons().add(icon); the above line executed when jvm created application, doesn't make sense depend on particular piece code display icon :) if want change file icon, have wrap executable jar file create new native executable file (which depends on os). example - exe windows. new file contain image file displayed , jar executed. you can try using launch4j or jsmooth creating wrapper file.

how to convert string ($23.25) to Decimal -$23.25 in selenium with C# -

i using xpath string shown in format ($23.25) should converted -$23.25. have tried: decimal.parse(string, numberstyles.allowcurrencysymbol | numberstyles.number); but not returning negative value. instead of numberstyles.number use numberstyles.allowparentheses . var balance = decimal.parse("($23.25)", numberstyles.currency | numberstyles.allowparentheses); // -23.25 if format "-$23.25", here how : balance.tostring("$0.00") // -$23.25

linux - Simple C Program that creates 2 X11 windows -

i want create 2 windows in linux i'll later draw in separate thread. have non-deterministic bug second window create doesn't created (no errors though). here code. static void create_x_window(display *display, window *win, int width, int height) { int screen_num = defaultscreen(display); unsigned long background = whitepixel(display, screen_num); unsigned long border = blackpixel(display, screen_num); *win = xcreatesimplewindow(display, defaultrootwindow(display), /* display, parent */ 0,0, /* x, y */ width, height, /* width, height */ 2, border, /* border width & colour */ background); /* background colour */ xselectinput(display, *win, buttonpressmask|structurenotifymask); xmapwindow(display, *win); } int main(void) { xinitthreads(); // prevent threaded xio errors local_display = xopendisplay(":0.0"); window self_win, remote_win; xevent self_event, remote_event; create_x_wind

javascript - how to do something when property created with pure js -

i want when new property added object named session . example, create new property : session["name"] = 'yoza'; when session.name created, need something. how that? you use setter function. like session.set = function(property, value){ session[property]=value; somecallback(); }

android - How to use setArgument in FragmentActivity -

i able use setargument() passing data in fragment unable same thing in fragmentactivity use intent s pass data fragmentactivity : intent intent = new intent(context, myfragmentactivity.class); intent.putextra("some_key", "some_data"); context.startactivity(intent);

java - Why does the Iterator.next() method of ArrayList copy the elementData field? -

here source code of next() method in iterator provided arraylist.iterator() : public e next() { checkforcomodification(); int = cursor; if (i >= size) throw new nosuchelementexception(); // why copy entire elementdata outer arraylist class? object[] elementdata = arraylist.this.elementdata; if (i >= elementdata.length) throw new concurrentmodificationexception(); cursor = + 1; return (e) elementdata[lastret = i]; } why code jdk try copy entire data array elementdata inner class iterator, since inner class has access fields in outer class? expensive huge list. i know there must explanation behind code - it? my question why jdk try copy entire data array inner class iterator. expensive huge list. no, isn't. copies reference array, not array itself. o(1); not expensive @ all. elementdata have accessed itr.outerclass.elementdata , outerclass being implicit reference inner class carries outer, cha

javascript - Google Tag Manager custom timer event -

i javascript timer set send user's time on page google analytics. user's first interaction (landing page) timer send event: every 1 second 10 seconds every 2 seconds 30 seconds every 3 seconds 1 minute every 24 seconds 5 minutes every 60 seconds 15 minutes every 90 seconds 30 minutes this should result in maximum of 70 events. yes can setup event tag , trigger on timer event. here how trigger http://take.ms/mdmej .

javascript - Dynamically adding watchers to inputs -

i'm making dynamic form renderer gets list of fields database , renders them user can input data , send database. right im adding functionality set evaluations fields have options, making give number base evaluation depending on option select user. /* load fields database result looks $scope.fields = [{field_name: "dishes", input_type: "radio", options:["{number: 20, value: 'tuna'}", "{number: 30, value:'salmon'}"], id: "id1", is_evaluated: true }] know watcher wont dict info that's why keep option dicts strings (i dont remember correct jsonparse syntax assume wrote dicts correctly) */ watchers = []; for(field in $scope.fields){ if($scope.fields[field].is_evaluted == true){//there can fields don't have numeric evaluation watchers.push($scope.$watch(function(){ return $scope.values[$scope.fields[field].id]; }, function(){ console.log("watcher t

php - retrieving data that was edited with bootstrap wysihtm5 editor -

Image
while retrieving data database edited bootstrap wysihtml5 getting plain text screenshot. using php framework laravel 5.2 , mysql how can fix it? please help. in view: <div class="box"> <div class="box-body"> {{ $text->text }} </div> </div>

c++ - C++11, using vs typedef, templatized -

instead of typedef struct { double x,y; } point; c++11 supports using point = struct {double x, y;}; unfortunately, approach not work type t template <typename t> using point = struct {t x, y;}; is there way of resolving problem? using point = ...; type alias (formally called 'alias'). i.e., it's different syntax typedef type involved named in ... . template<typename t> using point = ...; alias template , type involved again named in ... . what both aliases , alias templates have in common both must refer type-id (c++11 [basic.scope.pdecl]p3). type-ids must in turn name types . (go figure.) the problem template<typename t> struct {t x, y;} not type, class template, , established alias templates must refer types. changing code resolve your problem, i've no idea haven't said is... ;-] regarding that, please see what xy problem?

ruby - Incrementing value in a hash -

this question has answer here: adding value in hash table 1 answer i want increment value of first item one. not understand why code not working puts sales_hash sales_hash.values[0] = sales_hash.values[0] +1 puts sales_hash i adding 1 first value in sales_hash . when print out sales_hash first value remains same. doing wrong? when use hash#values receive array contains copy of values in hash. therefor, assignment not change hash rather array containing values. moreover, should aware elements in hash ordered order of key's insertion, might cause unexpected results if access "position" in hash since insertions , deletions may change order of hash. if want update value in hash, should access using it's key, example: sales_hash[:my_sale] = sales_hash[:my_sale] +1

How do I write the contents of a hash to a file in Ruby? -

i have hash looks follows: character = {"name: " => "#$name", "weapon: " => "#$weapon", "armor: " => "#$armor"} i want print each key , each value file looks this. name: templar weapon: sword armor: heavy armor i use basic method understand going on. i've read there modules you, such marshal, basic method involves beginner-level code. this should work you. recommend reading more on files , iterating through hashes first though. yourfile = "/some/path/file.txt" file.open(yourfile, 'w') |file| character.each{ |k, v| file.write("#{k}: #{v}\n") } end

Eclipse, maven, Jersey REST service, servlet 3.0, Tomcat 7.0, HTTP 404 Error -

i know title looks many people have asked question before, did lot of research , couldn't find solution solves problem. i've spent 2 days on issue please me out! i trying build simple "hello world" type of restful web service eclipse kepler service release 2, jersey, eclipse build-in maven, servlet 3.0 , tomcat 7.0. when run service using "run as" --> "run on server", there no problem loading default "index.jsp" page, keep getting http 404 error when loading service. this image shows project layout. my class implements application following: package com.ys.java.ws; import java.util.hashset; import java.util.set; import javax.ws.rs.applicationpath; import javax.ws.rs.core.application; import com.ys.java.ws.resources.myservice; @applicationpath("/ys") public class myapplication extends application { @override public set<class<?>> getclasses() { set<class<?>> s = new hashs