Posts

Showing posts from July, 2011

QML forwards/back mouse buttons handling -

i'm trying have qml application react forwards/back buttons (sometimes labeled buttons 4/5) on mice. seems mouse area/event allows signals on 3 main mouse buttons. is there way handle these buttons in qml? if @ list of predefined mouse buttons you'll see there forwardbutton , backbutton. "trick" need listen these buttons in qml mousearea set acceptedbuttons property. you either set listen forward , back: acceptedbuttons: qt.forwardbutton | qt.backbutton or listen mouse button: acceptedbuttons: qt.allbuttons putting together, mousearea this: mousearea { acceptedbuttons: qt.allbuttons onclicked: { if (mouse.button == qt.backbutton) { console.log("back button"); } else if (mouse.button == qt.forwardbutton) { console.log("forward button") } } }

javascript - twitter typeahead create extra link in dropdown -

i'd override default behavior of twitter typeahead. when suggestion shows, i'd able add <a> or <button> tag, when specific button clicked, doesn't typical dropdown row submit. i know how templating render button/link in template, can't figure out how override whole row click individual button click. templates: { header: '<h3 class="search-set">asdf</h3>', suggestion: function(context) { return mustache.render(template, context); } } thanks in advance. well, use custom events triggered typeahead on selection. if need button it's more of mustache question really. 1 solution add onclick handler generated html via jquery, e.g. suggestion: function(context) { var html = mustache.render(template, context); $('button', html).on('click', function(){alter('something')}); return html; }

objective c - Core Data and a UIActivityViewController -

i have app using core data persist data. have uiactivityviewcontroller setup on main vc. working expect to. my question when go grab items core data model, how have give every item within model? should using predicate sort items? edit this uiactivityviewcontroller setup. know of uiactivityviewcontroller actions dont show in sim fine. using email action show up. see nsstring , nsurl show without problem itemnames nsarray not showing up. should show in sim? - (ibaction)shareitem:(id)sender { nsstring *texttoshare = @"this random text put here"; nsurl *mywebsite = [nsurl urlwithstring:@"http://www.martylavender.com/"]; nsfetchrequest *fetchrequest = [nsfetchrequest fetchrequestwithentityname:@"item"]; fetchrequest.resulttype = nsdictionaryresulttype; nserror *error = nil; nsarray *results = [self.managedobjectcontext executefetchrequest:fetchrequest error:&error]; nsmutablearray *itemnames = [results valueforkey:@"itemname...

javascript - What is the point of object assigning to an empty object? -

i'm asking because saw here: https://github.com/bengrunfeld/react-flux-simple-app/blob/master/src/js/stores/appstore.js var appstore = assign({}, eventemitter.prototype, { emitchange: function() { this.emit(change_event); } }); i understand why assign eventemitter prototype, want of functionality of eventemitter ; , last object assign override emitchange event. why first parameter empty object ( {} )? necessary? i've seen done couple times. this due syntax of assign method takes first parameter object want put methods second object. can use existing object if don't have 1 pass new empty object {} assign copy methods , properties there , return modified. have @ this: https://developer.mozilla.org/en/docs/web/javascript/reference/global_objects/object/assign

javascript - Object doesn't support property or method 'setMap' -

i designing code jquerymobile, , weird error (that did not before): object doesn't support property or method 'setmap'. result, getcurrentposition not working properly, , can't actual user's position. this code links: <link href="omgapp-theme/themes/jquery.mobile.icons.min.css" rel="stylesheet" /> <link href="omgapp-theme/themes/omgapptheme.css" rel="stylesheet" /> <link href="omgapp-theme/themes/omgapptheme.min.css" rel="stylesheet" /> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" /> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> <!-- menu --> <link rel="stylesheet" href="assets/css/styles.css" /> <link ...

ruby - How do I change the context of lambda? -

if run code below error. class c def self.filter_clause param_1 puts param_1 yield # context of param class b end def hi "hello" end end class b def self.filter(value, lambda) code = lambda { filter_clause(value, &lambda) } c.instance_exec(&code) end filter(:name, ->{ hi }) end the error nameerror: undefined local variable or method `hi' b:class (pry):17:in `block in <class:b>' from understanding reason lambda running under context of class b . can't find method def hi . can't figure out how run under context of class c . essentially want able inject method being called in class accepts argument , block. for example: filter_clause("value", ->{ hi }) is possible? not sure if making sense. you're close. if want lambda(/block, really) execute in context of instance of c (since hi instance method on c), you'll need instantiate , instance_exec block on new in...

ruby - Is there a way to dynamically add a scope to an active record class? -

i trying dynamically add scope active record object. of things have been trying via metaprogramming not working. below sort of want achieve. class utilityclass def add_scope_to_class klass, name, lambda # should add # scope :published, -> { where(published: true) } code = lambda { filter_clause(value, &lambda) } klass.class_exec(&code) end end class article < activerecord::base end utilityclass.add_scope_to_class article.published # returns published articles i have tried couple of variations of plain ruby objects, thought asking question context might different ideas/answers. thanks. updated so far have managed come following it's not working class activesearch attr_accessor :collection attr_reader :params def initialize params={} @params = params end def results @collection = person.where(nil) params.compact.each |key, value| @collection = @collection.send("#{key}_filter", value) ...

flexbox - in Bootstrap col-xs-12 is not ocupying 100% width because the display: flex; property -

Image
i needed vertical align image left in site uses bootstrap. found solution here okay when resize xs screens property col-xs-12 shares space other column , not taking 100% width. how should make respect given space provided? /* small devices (tablets, 768px , up) */ @media (min-width: 768px) { .vertical-align { display: flex; align-items: center; } } i didnt read here

mysql - Selecting multiple rows at once when I know what ID's I want -

i have table 2 columns...id , content. is there way select data multiple rows @ once mysql database when know row id's want retrieve data from. possibly putting content column results array or sort if best way. trying prevent ton of sql query's. there 2 columns, id , content column. any input great. you can use in statement achieve this: select * mytable id in (1,2,3,4)

jquery - Javascript mobile device width check and class remove -

i need remove classes site if device width under 1200 px (because of mobile view). i tried use javascript, method worked fine: $(window).resize(function(){ var current_width = $(window).width(); if(current_width < 1200) $('a').removeclass("expand"); $( ".effects clearfix" ).remove(); $( ".overlay" ).remove(); $('#removeimg').removeclass('img').addclass('imgmobile');}); but problem is, works if resize window. if open site using smartphone (android 4.3, chrome) script not work. i tried write code failed: function checkwidth() { var width = (window.innerwidth > 0) ? window.innerwidth : screen.width; if (window.innerwidth < 1200) { $('#removeimg').removeclass('img').addclass('imgmobile'); } if (window.innerwidth < 1200) { $( ".effects clearfix" ).remove(); } if (window.innerwidth < 1200) { $( ".overl...

php - How can I split every space apart from when the space is within quotes? -

Image
i know how split spaces array: $array = array_filter(preg_split('/\s+/',$a)); but if string $a has quotes want regex ignore spaces within. for example: string: @ in txt "v=spf1 mx ip4:x.x.x.x ~all" would split array parts: @ in txt "v=spf1 mx ip4:x.x.x.x ~all" (don't mind if contains ' " ' or not) preg_split you can leverage pcre verbs skip , fail used discard patterns. idea discard within quotes, can use regex this: ".*?"(*skip)(*fail)|\s+ working demo however, if want use " or ' can use regex: (["']).*?\1(*skip)(*fail)|\s+ $keywords = preg_split("/([\"']).*?\1(*skip)(*fail)|\s+/", $a); preg_match_all on other hand, can use regex capture want using this: (".*"|'.*?'|\s+) working demo $re = "/(\".*\"|'.*?'|\\s+)/"; $str = "@ in txt \"v=spf1 mx ip4:x.x.x.x ~all\" ...

Range with chars or strings in Python arrays -

i pretty new python coming java, c, , haskell environment, wondering if there exist similar following strings , not numbers, have: for in range(5,11) print "index : %d" %i and result be: 5, 6, 7, 8, 9, 10 (each in new line of course). so, want have same strings, like: for c in range("a","e") print "alphabet : %s" %c i curious , have tried many things both strings , chars not obtain result want. in advance. strings iterable in python, can do: for c in 'abcde': print 'alphabet:', c alphabet: alphabet: b alphabet: c alphabet: d alphabet: e if want alternative explicit range , there's (rather ugly): for c in range(ord('a'), ord('e')+1): print 'alphabet:', chr(c) alphabet: alphabet: b alphabet: c alphabet: d alphabet: e range not take strings arguments in python, have convert characters ascii equivalents , again.

angularjs - NodeJS - Cannot set headers after they are sent - Multiple Calls -

i'm trying write app find city in mongodb collection , uses latitude , longitude returns find zip codes within distance. seems work, problem i'm getting error can't set headers after they've been sent. however, i've separated routes different requests don't understand why i'm still getting error. best way make multiple calls api? here router in node/express: // route city app.get('/cities/:zip', function(req, res) { // use mongoose city in database console.log(req.params.zip); var query = city.find({"zip" : req.params.zip}); query.exec(function(err, city) { if (err) res.send(err); res.json(city); }); }); // route find cities within 50 miles app.get('/matches/:latmin/:latmax/:lonmin/:lonmax', function(req, res) { console.log(req.params.latmin + req.params.latmax + req.params.lonmin + req.params.lonmax); var matches = city.find({latitude: {$gt: req.param.latmin, $lt:r...

python - Error in import M2Crypto -

i need use m2crypto in code. downloaded library zip file from: https://github.com/martinpaljak/m2crypto unzipped file. inside zipped file, found folder named: m2crypto, copied it, , paste in same directory code .py file resides. i added line from m2crypto import rsa, x509 but getting error: import __m2crypto importerror: no module named '__m2crypto' can me right way import external library python code? using windows system , type code using notepad++ please, consider in answer. edit: use python 3.4 to install m2crypto in windows, download 2 files (x64 or x86 version depends on system) link: https://github.com/dsoprea/m2cryptowindows . unzip 2 files in c: directory. then, type command: c:\python27\scripts>pip install --egg m2cryptowin64 note: in command, used m2cryptowin64 because installed. might need change if downloaded x86 version.

permissions to hive tables based on user roles -

how can specify permissions table in hive in way specific columns visible users when query according there roles( can use "views" if 150 different roles) you can use sentry give role based privileges. can create different groups , give access based on group. refer link

javascript - jQuery autocomplete select function not firing -

i writing re-usable wrapper around jquery autocomplete , reason can't select callback work. given code below, select() function never invoked. have screwed up? there hidden constraint on how specify select callbacks jquery autocomplete widget? note: half-written. trying select working. // note: 'input' jquery object. name.space.thingsuggest = function(input) { this.input = input; // set autocomplete widget on given input form. this.input.autocomplete({ source: name.space.thingsuggest.source_url, delay: 500, select: this.select.bind(this) }); this.input.autocomplete('instance')._renderitem = name.space.thingsuggest.renderitem; }; name.space.thingsuggest.source_url = // url name.space.thingsuggest.prototype.select = function(event, ui) { this.input.val(ui.item.label); return false; }; name.space.thingsuggest.renderitem = function(ul, item) { return $('<li>', { value: item.value }) .append(item.label + ...

oop - Global function or function with no name java for factory pattern -

i want declare factory class methods , attributes can used this: classfactory myobj = myobj("class1").method1("input 2"); it seems not valid java statement because java object oriented , don't let declare global function. if there mechanism let define function without name can define static function , use mentioned above. is there way implement in java in manner or other way? you can create public static method in class , can use globally. instance method public static boolean doeswork() { return true; } in public class named globalclass can accessed globalclass.doeswork() , return true .

currency - Money Rails Gem - null values -

i have monetised 2 models of rails 4 app money-rails gem. one called participants, other called funding. each of these models nested inside model, called scope. scope belongs project. the associations are: project has 1 scope; scope belongs project scope has 1 participant , has 1 funding; each of participant , funding belong scope. project accepts nested attributes scope. scope accepts nested attributes participant , funding. params each relevant attribute in participant , funding permitted in scope , project controllers models themselves. params scope permitted in scope , project controllers. in project form, ask several questions. form has nested forms each of models belong it. inside scope form, ask users 2 boolean questions, being: want participants? want funding? each of these models has follow question participation cost , funding (those attributes monetised). if answer questions true, reveal participant or funding form partial , ask how money want. i have 2...

php - SQLSTATE[42000]: Syntax error or access violation: 1064 default character set utf8 collate utf8_unicode_ci' at line 1 -

i'm trying migrate code mysql database keep getting error message. sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near ') default character set utf8 collate utf8_unicode_ci' @ line 1 public function up() { schema::create('user', function(blueprint $table) { $table->engine = 'innodb'; $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password', 60); $table->remembertoken(); $table->timestamps(); $table->integer('projectid')->unsigned(); $table->boolean('isstudent'); $table->boolean('iscompany'); $table->string('img'); }); schema...

html - Centering multi div -

i trying center multiples div works cross browser. <style> .boxcontent { width: 288px; height: 288px; background-color: #777; margin: 2px; display: inline-block; } .boxcontainer { background-color: #333; text-align: center; display: table; } </style> <body> <div class="container"> <div class="row"> <div class="boxcontainer center"> <div class="boxcontent">asda</div> <div class="boxcontent">asda</div> <div class="boxcontent">asdas</div> <div class="boxcontent">asda</div> <div class="boxcontent">asdas</div> <div class="boxcontent">asda</div> <div class="boxcontent">asda</div> ...

Run a specific task in Task Scheduler using ASP.NET C# -

i have button in asp.net web application. want button invoke task in task scheduler. didn't find exact code invoke task task scheduler. please help....!!! have @ documentation library. wrapper windows task scheduler. http://taskscheduler.codeplex.com which wrapper task scheduler windows api https://msdn.microsoft.com/en-us/library/windows/desktop/aa383614(v=vs.85).aspx using wrapper can interact task scheduler code this using (taskservice ts = new taskservice()) { task t = ts.gettask(taskname); if (t != null) { // status here or runtime var isenabled = t.enabled; var runs = t.getruntimes(startdate,enddate); } } now should remember can not poll status of task while holding asp.net request processing cycle. best can checking status in ajax calls until task finished. meanwhile re-evaluate design , suitability of task scheduler purpose. securing website while allowing access task scheduler might challenge. 1 other option windows servi...

c# - Listview with multiple columns not acting properly when height of Item expanded -

Image
hello need multicolumn control variable heights , expand/collapse capability. approach far this- <listview grid.row="1" itemssource="{binding mycollection}" scrollviewer.horizontalscrollbarvisibility="disabled" grid.issharedsizescope="true" verticalcontentalignment="center"> <listview.itemspanel> <itemspaneltemplate> <wrappanel></wrappanel> </itemspaneltemplate> </listview.itemspanel> <listview.itemtemplate> <datatemplate> <control:ucnewsfeed margin="6" datacontext="{binding post}" /> </datatemplate> </listview.itemtemplate> </listview> please notice ucnewsfeed usercontrol given below- <grid x:name="maingrid"> <grid.rowdefinitions> <rowdefinition height="57"/> <rowdefinitio...

eclipse - How to deploy a project using oracle 11g XE as backEnd to a Java front end -

i want know how deploy project using oracle 11g express exition end , java front end. i have used java , ms access end in supplied .mdb file project. don't know how deployment works if use oracle end , java front end. the ide i'm using eclipse. deploying oracle 11g express when comparing ms access comparing chalk , cheese. worlds apart. deploying oracle express installing other piece of software. have chose options , specify passwords (need record those) when installing oracle express. usually when deploying (and re-deploying) application installation of db software done once. if changes need made data in database change scripts preferred options.

android - How to see data in ParseObject in Parse Explorer? -

Image
this screenshot of parse explorer. has 2 objects gamescore , testobject . these created using parse sdk android. how can see data in these objects in parse explorer? i not clear question. think might solution. can browse data in object in "core" menu. "core" menu can found @ top of web page. hope helps. :)

jquery - Error injecting angular $location service -

i need use $location service inside jquery(callback) function, tried following: $(function(){ ... stuff ... var $injector = angular.injector(['ng']); $injector.invoke(function($location){ var url = $location.url(); }); }); but uncaught error: [$injector:unpr] logged in console. how can use $location inside jquery callback?

html - How to pass multiple text field's updated value in the same row to controller using hyperlink? -

i have 1 jsp page in showing records in table in jsp. in table (the jsp) every row has 1 column have put 'edit' hyperlink. if updating value in text fields in same table. after clicking on link, want updated text field's value in controller. can 1 tell me how achieve goal? <table border="2"> <tr> <th>student id</th> <th>first name</th> <th>last name</th> <th>age</th> <th>contact no.</th> <th>click here edit</th> <th>click here save</th> </tr> <c:foreach items="${list}" var="currentstudent"> <%!int count = 0; %> <tr> <td> <input name = "sid" type="text" value= "${currentstudent.studentid}" size="10" /> </td> <td> <input id = "fn<%= count%>" name = "fn" type="text...

php - overflow: hidden pushes text down -

Image
when add overflow: hidden class of first span ( .welcome-show ), reason pushes other ones down bit. how can fix ? phtml: <div class="col-lg-6 pull-left"> <p> <span class="welcome-show">Здравей, <?php echo $this->escapehtml($user->nick) ?></span> <span class="rank">Ранк: <?php switch ($user->role) { case 1: ?> <span class="rank-vip">vip</span> <?php break; case 2: ?> <span class="rank-vipplus">vip+</span> <?php break; default: ?> <span class="rank-none">Никакъв</span> <?php break; } ?> ...

java - Access files and folders in Jar files -

there many similar questions not duplicate. similar "can't access files in jar file" there slight difference. lot of experimentation , forum reading, managed access contents of file , display them within jar file. problem if put file inside folder program no longer work though works when run class file. problem because when make games , other programs having different folders organisation "maps" , "spritesheets". made experimental program route out problem , here code it: try { inputstream = getclass().getresourceasstream("folder\\test.txt"); inputstreamreader isr = new inputstreamreader(is); bufferedreader br = new bufferedreader(isr); string line; while ((line = br.readline()) != null) { system.out.println(line); } br.close(); isr.close(); is.close(); } catch (exception ex) {} i ...

java - jtable returns only one row from the database -

i want table return data database without specifying number of rows, used autoincrement in default tablemodel doesnnot display rows, have define table outside actionlistener add jpanel,so problem table returns 1 row fro database int row = 1; object [] colnames = {"year","term","balance"}; jtable table4 = new jtable(new defaulttablemodel(colnames,++row)); jscrollpane pane = new jscrollpane(table4); saachs.addactionlistener(new actionlistener(){ public void actionperformed(actionevent e) { string adm = adms.gettext(); int row = 0; connection con = null; try { class.forname("com.mysql.jdbc.driver"); } catch (classnotfoundexception ex) { try { throw new exception ("driver not found"); } catch (exception e1) { // todo auto-generated catch block ...

Magento Error: After Theme upload on Magento 1.9 -

just uploaded new theme , error. cannot access website backend. here log: trace: #0 /home/xxxxxx/public_html/lib/varien/db/statement/pdo/mysql.php(110): zend_db_statement_pdo->_execute(array) #1 /home/xxxxxx/public_html/app/code/core/zend/db/statement.php(291): varien_db_statement_pdo_mysql->_execute(array) #2 /home/xxxxxx/public_html/lib/zend/db/adapter/abstract.php(480): zend_db_statement->execute(array) #3 /home/xxxxxx/public_html/lib/zend/db/adapter/pdo/abstract.php(238): zend_db_adapter_abstract->query('select `main_ta...', array) #4 /home/xxxxxx/public_html/lib/varien/db/adapter/pdo/mysql.php(428): zend_db_adapter_pdo_abstract->query('select `main_ta...', array) #5 /home/xxxxxx/public_html/lib/zend/db/adapter/abstract.php(737): varien_db_adapter_pdo_mysql->query('select `main_ta...', array) #6 /home/xxxxxx/public_html/lib/varien/data/collection/db.php(734): zend_db_adapter_abstract->fetchall('select `main_ta...', array)...

Getting hebrew json to php file -

i'm trying parse json file in php: http://www.oref.org.il/warningmessages/alerts.json this file contains hebrew letters cause encoding problems. my script: $content = file_get_contents('http://www.oref.org.il/warningmessages/alerts.json'); $json = json_decode($content); echo $json->id; it won't display anything. blank page. if echo $content; shows json file perfectly. json file example: { "id" : "1434292591050", "title" : "פיקוד העורף התרעה באזור ", "data" : [] } i've been reading few other similar problems , solutions none of them helped fixing problem. i've been trying use mb_detect_encoding , iconv didn't help. thank you! the file content you're getting in utf-16 charset. have convert it: $content = file_get_contents('http://www.oref.org.il/warningmessages/alerts.json'); $content=iconv("utf-16", "utf-8", $content); $json = json_decode...

osx - How to get custom table cell views into NSTableView? -

i have nstableview uses standard nstexttablecellview s want other cells contain ui component in table in 1 or 2 rows. question is: define custom cells cocoa finds them? i dropped custom nstablecellview xib (same xib in table is) , gave identifier. using code not find cell ... func tableview(tableview:nstableview, viewfortablecolumn tablecolumn:nstablecolumn?, row:int) -> nsview? { var view:nstablecellview?; if (tablecolumn?.identifier == "labelcolumn") { view = tableview.makeviewwithidentifier("labelcell", owner: nil) as? nstablecellview; view!.textfield?.stringvalue = _formlabels[row]; } else if (tablecolumn?.identifier == "valuecolumn") { if (row == 1) { view = tableview.makeviewwithidentifier("customcell", owner: nil) as? nstablecellview; println("\(view)"); // nil - not found! } else { view = tableview.ma...

php - How to enter a server IP into a mysql table? -

i want create page displays no of times visited , ip addresses visiting web page. for created mysql table displays new ip in new row, unable execute it. most likely, error in entering server ip table.here's full code: <html> <head> <title>delta sys ad task3</title> </head> <body> <?php $dbhost = 'localhost'; $dbuser = 'prabakar'; $dbpass = 'praba1110'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('could not connect: ' . mysql_error()); } mysql_select_db('server_ips', $conn); echo mysql_errno($conn) . ": " . mysql_error($conn). "\n"; $counter=1; $flag=0; $sql='select * ips'; $retval = mysql_query( $sql, $conn ); while($row = mysql_fetch_array($retval, mysql_assoc)) { if($_server[server_addr]==$row['ip']) break; else $flag=1; } if($flag==1) { $sql="insert ips values('$_server...

compatibility - Why does Microsoft Edge (formerly Project Spartan) prompt to open this website in Internet Explorer? -

does know triggers ms edge not open specific web page/site, instead prompt user open site in internet explorer? the message says: this website needs internet explorer this website uses technology work best in internet explorer. it not possible proceed using project spartan. there no rule set based on content of page cause prompt. the prompt controlled using "compatibility list" cloud-hosted list downloaded ms edge browser periodically. similar cv list in ie . in cases working sites on list migrate newer technologies @ time they'll removed list.

java - Moving all fields from one object into another -

can somehow move field values 1 object without using reflection? so, want this: public class betterthing extends thing implements ibetterobject { public betterthing(thing t) { super(); t.evolve(this); } } so, evolve method evolve 1 class another. argument <? extends <? extends t>> t class of object, you're calling evolve on. i know can reflection, reflection hurts performance. in case thing class in external api, , there's no method copy required fields object. as @olivercharlesworth points out, can't done directly. either have resort reflection (though wouldn't recommend it!) or series of field-by-field assignments. another option though, switch inheritance composition: public class betterthing implements ibetterobject { thing delegate; public betterthing(thing t) { this.delegate = t; } // thing methods (delegate methods) string thingmethodone() { return delegate.thin...

javascript - Share two instances between other classes -

i have 4 coffeescript classes following: class main constructor: (element) -> @element = $(element) @one = new one() @two = new two(@one) @dummy = new dummy(@one, @two) class 1 constructor: (class_two_instance) -> # class 2 constructor: (class_one_instance) -> # class dummy constructor: (class_one_instance, class_two_instance) # jquery -> new main($("#main")) i need class one , class two shared between other (actual or future) classes. what started pass them parameters, can see in main class @dummy = new dummy(@one, @two) but class one need pass @two . same thing class two need pass @one unfortunately seems not possible @ same time can see (i can't pass @two parameter new one() ): @one = new one() @two = new two(@one) is there way solve ? it sounds me though one , two shouldn't classes @ all, single objects: one = { data: "i'm one", method: () -> # ...

What is the difference between 65 and the letter A in binary? -

what difference between 65 , letter in binary both represent same bit level information? every character represented number. mapping between numbers , characters called encoding. many encodings use letter a number 65. since in memory there no special cells characters or numbers, represented same way, interpretation in program different.

bash - ipv6calc outputs wrong address when converting from ipv4 to ipv6? -

having strange issue while trying convert ipv4 list file ipv6: ipv6calc -q --action conv6to4 --in ipv4 1.1.23.1 --out ipv6 2002:101:1701:: trying validate result correct, used online converters , seems 1.1.23.1 2002:0:0:0:0:0:101:1701 (or else 2002::101:1701). last "::" should removed & 2002 should have ":". i don't want use sed/awk commands in order manipulate result, questions are: is there alternative cmd/linux sw? is somehow fixed inside ipv6 calc, doing wrong? thanks this correct 6to4 address. 6to4 subnet on format 2002:ip4_hi:ip4_lo::/48 . ip4_hi top 16 bits of ipv4 address, while ip4_lo low 16 bits of address. for example, ipv4 address 1.2.3.4 gives 6to4 subnet 2002:0102:0304::/48 . see 6to4 address block allocation more details. a different question whether address want? there other ways map ipv4 addresses ipv6 addresses. example, there ipv4-mapped ipv6 addresses , typically written ::ffff:1.2.3.4 . the address f...

export a list as a csv file in python and getting UnicodeEncodeError -

i want csv file list. list: temp = ['سلام' , 'چطوری' ] members of list in persian language. tried csv file code: import csv open("output.csv", "wb") f: writer = csv.writer(f) writer.writerows(temp) but terminal gives me error: unicodeencodeerror: 'ascii' codec can't encode character u'\u06a9' in position 0: ordinal not in range(128) how can solve , csv file? p.s when print temp , see these strings: [u'\u06a9\u0627\u062e \u0645\u0648\u0632\u0647 \u06af\u0644\u0633\u062a\u0627\u0646 | golestan palace', u'\u062a\u0647\u0631\u0627\u0646', u'\u062a\u0647\u0631\u0627\] but when call temp[1] this: کاخ موزه گلستان | golestan palace how can solve , csv file? why python encodes data , sometime doesn't? the csv library in python 2 cannot handle unicode data. fixed in python 3, not backported. however, there drop-in replacement 3rd party library fixes problem. try ...

jquery - getting "Error: jQuery111306513629604596645_1434294948077 was not called" error when cross domain ajax call? -

my ajax call is: $.ajax({ method: "get", contenttype: "application/json; charset=utf-8", url: "http://localhost:8080/viewalldoctorprofile", datatype: 'jsonp', crossdomain: true, success : function(json){ alert("24254"); }, error: function (xhr, ajaxoptions, thrownerror) { alert(xhr.status); alert(thrownerror); } }); i can see result json in inspect elements in browser, i'm getting error: error: jquery111306513629604596645_1434294948077 not called please me. thank in advance i assume 'jquery111306513629604596645_1434294948077' may wrapper of jsonp response - wraped within method should be? i can see ajax method not contain 'jsonpcallback' method. here have similar issue: callback function jsonp jquery ajax

php - invalid object or resource mysqli_stmt -

i want run multiple mysql queries( not concurrently). using prepared statements doing so. gist of code : <?php if(isset($_get['username'])&&isset($_get['activationid'])){ require_once("../database/db_connect.php"); $stmt= $mysqli->stmt_init(); $stmt->prepare("select username users username= ? , activationid= ?"); $username=$_get['username']; $activationid=$_get['activationid']; $stmt->bind_param("ss",$username,$activationid); $stmt->execute(); $row=$stmt->get_result()->fetch_array(mysqli_assoc); if(!strcmp($row['username'],$username)){ echo 'you registered successfully'; $stmt->prepare("update users set active=yes username = ?"); $stmt->bind_param("s",$username); $stmt->execute(); } } ?> and db_connect.php : <?php define('dbhost','localhost'); define('dbuser','root'); define...

Authorize user by retrieving credentials from LDAP and passing into OAuth 1.0a using Atlassian Stash REST API -

i have found projects, unsure if want. maybe give tutorials or examples, how , in stash can pass ldap credetials? docs explains gui way that.... thank very, much. update: question made in atlassians "ask" : https://answers.atlassian.com/questions/17893290/how-to-integrate-ldap-when-installing-in-puppet#

Pubnub chat set up for rails application -

i hoping clear confusion have using pubnub rails application. hoping use pubnub chat layer among users. users may able chat via ios/android/web(rails) throughout application. ** pubnub gem used when creating auth_key user, , changing access pam. ** it seems me serverless setup , javascript sdk should used instead of ruby sdk? flow seems more be: user registered through devise after signed up, rails app server uses user's id (or other uuid) create auth_key, stores in db. logic when creating 1:1 chat in rails application rails controller creates channel, set channel id, creates access 2 peers. is rougly logic? i not sure whether okay put pub_key , sub_key javascript client, seems can use pair create channels want. yes, you're right insights , logic laid out here valid. you don't need worry exposing pub , sub keys world because of access manager. secret key stored safely on server , you'll granting access particular channels serve...

jquery - tablesorter themes not working -

my code works except theme instructions tablesorter. have put themes in css folder inside tablesorter js. appreciate if can me. here code: <table id="dttable" class="table table-bordered table-responsive"> <thead> <tr> <th align="center">#</th> <th>desc</th> <th colspan="2" align="center">action</th> </tr> </thead> <tbody> <?php $query="select * eth" ; $records_per_page=10; $newquery=$ eth->paging($query,$records_per_page); $eth->dataview($newquery); ?> <tbody class "do-not-sort tablesorter-no-sort"> <tr> <td colspan="7" align="center"> <div class="pagination-wrap"> <?php $eth->paginglink($query,$records_per_page); ?>...

java - Calling a JMenuBar from another class -

i have following code gui button on , code jmenubar. menubartest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; import menubar.*; public class menubartest extends jframe implements actionlistener { jframe mymainwindow = new jframe("this title"); jpanel firstpanel = new jpanel(); jbutton btntest = new jbutton("refresh results"); guidmenubar mbr; public void rungui() { mymainwindow.setbounds(10, 10, 800, 800); mymainwindow.setdefaultcloseoperation(jframe.exit_on_close); mymainwindow.setlayout(new gridlayout(1,1)); createfirstpanel(); mymainwindow.getcontentpane().add(firstpanel); mymainwindow.setjmenubar(mbr.guidmenubar()); mymainwindow.setvisible(true); } public void createfirstpanel() { firstpanel.setlayout(null); btntest.setbounds(100, 100, 200, 50); btntest.addactionlistener(this); firstpanel.add(b...

php - How properly select data from DB according to filter in Eloquent? -

i have filter. filter contains 3 fields. call_date_from , call_date_till , telephone . so need select leads (lead model) table rows fit filter. in raw php + mysql write this: $sql = ' '; $post['call_date_from'] ? $sql .= ' `call_date` >= ' . $post['call_date_from']; $post['call_date_till'] ? $sql .= ' , `call_date` <= ' . $post['call_date_till']; $post['telephone'] ? $sql .= ' , `telephone` %' . $post['telephone'] . '%'; mysql: 'select * leads' . $sql; so how same in laravel eloquent? this how can filter in laravel eloquent using query scope . in model class lead extends model { public function scopecalldatefrom($query, $date) { if ($date) { return $query->where("call_date", ">=", $date); } else{ return $query; } } public function scopecalldatetill($query, $date) ...

angularjs - Set value for ng-model by javascript -

i have problem when using javascript angularjs. have text field id="longitude". <input type="text" data-ng-model="newwarehouse.longtitude" id="longitude"/> i set value of field javascript. var longitudevalue = document.getelementbyid('longitude'); longitudevalue.value = event.latlng.lng(); but when process controller of angular js can't value of field except type manual value field. should write in javascript set model value of field? everyone. when working angular, set/update value, use angular way of dealing things. what want update input field based on event. let click event of button. so, in html lets have this <a href="javascript:void(0);" ng-click="clickme()">click me</a> and update controller, click event binding $scope.clickme = function() { $scope.newwarehouse = { longtitude : 'longitute' }; }; i have created plunker referen...

c++ - codeforces shows WA but output is correct on terminal -

when submitted solution codeforces 551c , judge gives me wrong answer on 49th test case. when run same code on terminal (using g++4.9.2) answer comes out correct. #include <bits/stdc++.h> #include <algorithm> #define endl '\n' using namespace std; template <class t> inline void dbg(string s,t &a) { cout << s+" => " << << endl; } int n,m; int a[100005]; bool check(long long int time) { long long int consumed,temp=0,diff; for(int i=1;n!=0 && i<=m;i++) { consumed=n; while(n>0 && consumed<time) { if(!temp) temp=a[n]; diff=temp<(time-consumed)?temp:time-consumed; temp-=diff; consumed+=diff; if(!temp) n--; } } if(n==0) return true; else return false...

parse.com - How to use relations between a Parse subclass and an User - Swift -

i building quiz app , have class named "questions" in parse. when user answers question, wanted question removed questions needs answer. wanted add subclass named "questionanswered", boolean return true questions user had answered. problem boolean should unique each user. how can implement in parse , in swift? thank you. one way have relation user on questions called answeredby , , add user relation when answer question var relation = question.relationforkey("answeredby") relation.addobject(auser) question.saveinbackground() then, query questions haven't been answered user add questionquery.wherekey("answeredby", notequalto:auser) constraint question query. i'm not sure how scale though, ymmv. might want testing on if you're expecting decent traffic.

php - IP Address won't pass to e-mail body -

my php form setup pull ip address sender. form generates no errors...test e-mail received, not pass ip address body of e-mail. did wrong? here php form: <?php $owner_email='info@mywebsitedesign.com'; //smtp server settings $host = ''; $port = '465';//"587"; $username = ''; $password = ''; $subject='my website design'; $user_email=''; $message_body=''; $message_type='html'; $max_file_size=50;//mb $file_types='/(doc|docx|txt|pdf|zip|rar)$/'; $error_text='something goes wrong'; $error_text_filesize='file size must less than'; $error_text_filetype='failed upload file. file type not allowed. accepted files types: doc, docx, txt, pdf, zip, rar.'; $private_recaptcha_key='6lezwuksaaaaacmqrblmdpvdhc68nlb1c9ea5vzu'; //localhost $use_recaptcha=isset( $_post["recaptcha_challenge_field...

struct - Error Showing Access Violation in C++ -

struct root { struct qgroup { struct qpost { struct qcomment { struct qcomment *next; int likes; int address; } qcomment[100]; int likes; int comments; int address; } qpost[100]; int address; int posts; int users; }qgroup[8]; }*root = (struct root *)malloc(sizeof(struct root *)); getting access violation error @ following line. for(int i=0;i<5;i++) root->qgroup[i].address = i*128+1024*1024; please me out of this? tried both static allocation , dynamic allocation, both failed in reading data given in above loop. error starting of execution after main() root = malloc(sizeof(struct root *)); this has correct follows: root = (struct root *)malloc(sizeof(struct root )); no need cast struct root * since malloc returns void pointer , can assign other type in c. in case of c++ need ca...

javascript - Retain DOM contents on page refresh -

i display view(html page) making call particular controller's action(mvc). after make series of ajax calls(by clicking links) , update particular div. know when page refreshed starting view displayed url same hits starting controller/action , renders main view(content loaded through ajax calls lost) i want persist each dom state(rendered ajax calls) when page refreshed. studied , found can done using url hashing in javascript. i thinking of javascript method invoked each time page loaded. extract hash part , make call corresponding action , render view. is approach correct ? there better way of doing ?

php - Yii2 renderDynamic not working for setting form -

i have form on page using page cache on, need top part of form render dynamically csrf token changes every time, when put code in <?php $this->renderdynamic('return $form = activeform::begin();'); ?> i error call member function field() on non-object on line <?= $form->field($model, $nbateam['id'])->checkbox(['label' => null, 'data-seed' => $nbateam['seed']]) ?> i error in apache error log class 'activeform' not found i found workaround renderdynamic not seem work yii widgets. used jquery modify value of csrf token after page loaded cache. $this->registerjs("$(document).ready(function(){ $('input[name=_csrf]').val('".$this->renderdynamic('return yii::$app->request->csrftoken;')."'); });", view::pos_end);

html - Can't embed/link YouTube video -

i attempting embed/link youtube video html file. however, after copy , paste embed link youtube html document, nothing appears happen. here youtube link using: <iframe width="560" height="315" src="https://www.youtube.com/embed/- qz8gktwq04" frameborder="0" allowfullscreen></iframe> here full code (an assignment intro web class): <!doctype html> <html> <head> <title>intro</title> </head> <body> <h1 align="center" style="color:yellow; background- color:blue">introduction: textwrangler</h1> <div class="nav"> <div class="container"> <ul> <li><a href="intro.html">intro</a></li> <li><a href="pros.html">pros</a></li> <li><a href="cons.html">cons</a></li> </ul> </d...