Posts

Showing posts from March, 2015

javascript - Is there (should there be) any difference between native js defaultValue and jQuery prop(defaultValue)? -

i'm litte confused native javascript defaultvalue functionality. have understood value of html input must set , value initial default value. i wanted restore specific input (text) element default value when have inside click-event. (cancel button) //restore values var name_person = $(this).find('.nameofperson'); //attempt 1 name_person.val(name_person.defaultvalue); alert('restored value=' + name_person.val()); //this alerts nothing //attempt 2 name_person.val(name_person.prop('defaultvalue')); //this alerts default value alert('restored value=' + name_person.val()); why doesn't native defaultvalue attribute work when prop('defaultvalue') does? shouldn't same? initial value set value="bla bla bla" in input element. i got work (with jquery), wonder - missing something? it not work because name_person jquery object , jquery not have defaultvalue . need reference dom object name_person[0].defau...

java - JFrame does not show up in Eclipse -

i tried execute following code within eclipse (osx): public static void main(string[] args) { jframe frame = new jframe("test"); frame.setsize(new dimension(400, 30)); frame.add(new jbutton("hello")); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setvisible(true); } the frame not show following console messages: 2014-05-16 14:45:35.230 java[8685:903] [java cocoacomponent compatibility mode]: enabled 2014-05-16 14:45:35.232 java[8685:903] [java cocoacomponent compatibility mode]: setting timeout swt 0.100000 2014-05-16 14:45:35.546 java[8685:903] *** __nsautoreleasenopool(): object 0x100612800 of class nsconcretemaptablevalueenumerator autoreleased no pool in place - leaking 2014-05-16 14:45:35.547 java[8685:903] *** __nsautoreleasenopool(): object 0x100613f40 of class __nscfdate autoreleased no pool in place - leaking 2014-05-16 14:45:35.547 java[8685:903] *** __nsautorelease...

php - color picker issue in plug in development wordpress -

i trying add color picker in wordpress settings api plugin development. facing problem that. have code color picker. // create function color picker. add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' ); function mw_enqueue_color_picker( $hook_suffix ) { // first check $hook_suffix appropriate admin page wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'my-script-handle', plugins_url('my-script.js', __file__ ), array( 'wp-color-picker' ), false, true ); } //call in input field option <tr valign="top"> <th scope="row"><label for="cursor_color">scrollbar color</label></th> <td> <input id= "cursor_color" type="text" name="ppmscrollbar_options[cursor_color]" value="<?php echo stripslashes($settings['cursor_color']);?>" class="my-color-field"/><p class="description"...

javascript - Can't Perform action on click yes in Jquery based confirmation box -

i have template using fallr confirmation or alert boxes features. has code confirmation box, working fine not working according requirement..means i have 1 link delete row table like: <a href="<?php echo base_url(); ?>admin/del_menu/<?php echo $values->id; ?>" rel="tooltip-top" title="delete" id="confirm"> when click on showing dialog box ask 'yes' , 'cancel' it's jquery code is: $('#confirm').click(function(ev) { var clicked = function(){ $.fallr('hide'); return true; }; $.fallr('show', { buttons : { button1 : {text: 'yes', danger: true, onclick: clicked}, button2 : {text: 'cancel', onclick: function(){$.fallr('hide')}} }, content : '<p>are ...

spring - Securing a REST application in SpringBoot and accessing it from a Rest Client -

i pretty new springboot. have developed rest server wondering how perform basic authentication client , how configure spring boot server authenticate request. tutorials saw online didn't include restful client. great if can show code including both client request , server authentication process springboot rest. on client side since using jersey client need following: client c = client.create(); c.addfilter(new httpbasicauthfilter(user, password)); one server side need enable spring security , set basic authentication following (this simplest possible case). @configuration @enablewebsecurity public class rootconfig extends websecurityconfigureradapter { @override protected void registerauthentication(authenticationmanagerbuilder auth) throws exception { auth.inmemoryauthentication() .withuser("tester").password("passwd").roles("user"); } @override protected void configure(httpsecurity http) throws exception { http .aut...

php - SELECT does not selects -

this question has answer here: call undefined method mysqli_stmt::get_result 7 answers i'm tryign creat user_login system website. , got problems selection of user_info database , using mysqli , prepared statements . problem , can't output . i'm using manual @ php.net . here have got moment: <?php require_once 'php/includes/constants.php'; $connection = new mysqli(db_server, db_user, db_password, db_name)or die("error"); $phone = "0661488342"; $password = "1234"; $query = " select * userinfo phone = ? , password = ? limit 1"; $stmt = $connection->prepare($query); $stmt->bind_param('ss', $phone, $password); $stmt->execute(); $res = $stmt->get_result(); $row = $res->fetch_assoc(); echo "password = ".$row['password']; t...

math - Cryptarithmetic Multiplication Prolog -

i have grasp of idea of crypt arithmetic , addition cannot figure out how multiplication crypt arithmetic problem. it's two*six=twelve or along lines without middle additional part of multiplication problem given. couldn't find online , found constraints problem nothing leads me answers. not sure ask , thought best place. i want know how solve multiplication crypt arithmetic problem. i concluded: t w o * s x _________________ t w e l v e t \= 0 means s \= 0 t 1-6 e (o*x) mod 10 o or x cannot 0 or 1 since e has different , 0 or 1 gives same value either o or x. edit: using generate , test method solve(t,w,o,s,i,x,e,l,v) :- x = [t,w,o,s,i,x,e,l,v], digits = [0,1,2,3,4,5,6,7,8,9], assign_digits(x, digits), t > 0, s > 0, 100*t + 10*w + o * 100*s + 10*i + x =:= 100000*t + 10000*w + 1000*e + 100*l + 10*v + e, write(x). select(x, [x|r], r). select(x, [y|xs], [y|ys]):- sele...

Strange condition in Mysql query -

basically have edit someone's else code , query is: delete some_table 1 googling around didn't find similar. i can't understand condition. explain me please? as written, delete rows (because 1 true). if want delete rows, more efficient use truncate table : truncate table some_table one reason might want generate statement where 1 can add additional clauses afterwards.

python - Inheritance and customisation of class -

i define 1 class device lot of subclasses example microcontroller . device has 2 mode , "simulated" mode. i trying code device class such has if microcontroller in simulated mode when print performed should prefix string [simulated] : print "hey !!" > [simulated] hey!! i don't know how start , if it's possible overload print . you can implement logger class, , use logging. can dome object injection replace type of logger when want. example: class logger: def __init__(self, prefix): self.prefix = prefix def log(self, msg): print('[{}] {}'.format(self.prefix, msg)) class base: def set_logger(self, logger): self.logger = logger class test(base): def do_something(self): self.logger.log('hey !!') test = test() test.set_logger(logger('simulated')) test.do_something() test.set_logger(logger('very real')) test.do_something() for example: [simulate...

angularjs - Karma + Jasmine: Usage of constant like objects -

in short : put hard-coded values separate file , use them multiple test specs. in detail : i’m doing angularjs tutorial try write cleaner code. in step 5 , introduce hard-coded strings "nexus s" . put such hard-coded strings separate file, example: var testconstants = function() { this.nexus_s = 'nexus s'; }; module.exports = new testconstants(); this working fine protractor tests in following way: var constants = require('../ test-constants.js'); //… expect(…).toequal(constants.nexus_s); but not working unit tests ( require(…) not available). tried add file karma.conf still can’t reference it. how can reference file in similar fashion e2e protractor tests? or: best practice this? insert file in files list in karma first one. change following: // wrap in function not pollute global namespace (function(){ var testconstants = function() { this.nexus_s = 'nexus s'; }; // instance want export var constants =...

java - It does not add to an arrayList for some reasons -

i've got strange thing, i'm trying add arraylist not add, values , everything. please check code , brigthen me up. the class trying add: public class manualproductgui extends jdialog { private final jpanel contentpanel = new jpanel(); private jtextfield barcodefield; private jtextfield idfield; private jtextfield namefield; private jtextfield pricefield; private jtextfield quantityfield; private jtextfield infofield; basketcontainer bc = new basketcontainer(); private static final long serialversionuid = 1l; /** * launch application. */ public static void main(string[] args) { try { manualproductgui dialog = new manualproductgui(); dialog.setdefaultcloseoperation(jdialog.dispose_on_close); dialog.setvisible(true); } catch (exception e) { e.printstacktrace(); } } /** * create dialog. */ public manualproductgui() { settitle("product search"); setbounds(100, 100, 450, 300); getcontentpane().setlayou...

jquery - AJAX: can't call function on image click -

i have problem passing data post method in ajax. ajax method : $(document).ready(function(){ $("#vote").click(function(){ $.ajax({ type:'post', async: false, url: "http://localhost/psi/dokumentacija/faza5/implementacija/votes/votealg", data: { incdec: $("#vote").val(), alg: $("#algcode").val(), }, datatype: 'text', cache: false, success: function(mess) { console.log(mess); if(mess=='voted') { alert("glasali ste vec!"); } else if (mess=='error') { alert("problem sa bazom"); } else { $("#algrate").val(mess); } } }); return false; }); }); function in controllers : public function votealg() { if ($this->input->is_ajax_request()) { $this...

math - to determine if an azimuth is between two given azimuths -

azimuth angle line makes between north pole/axis , itself. can vary 0 degree 360 if rotated in circular path. lets have 2 such azimuths, alpha , beta. wish determine of azimuth ,say gamma, falls between 2 azimuths alpha , beta. can please me out simple algorithm or formula used in excel determine if line corresponding gamma between 2 lines corresponding alpha , beta. gamma can assume different values. thanks gamma between 2 lines corresponding alpha , beta when both expressions: ag = atan2(cos(a)*sin(g)-sin(a)*cos(g), cos(a)*cos(g)+sin(a)*sin(g)) gb = atan2(cos(g)*sin(b)-sin(g)*cos(b), cos(g)*cos(b)+sin(g)*sin(b)) - have same sign, - ( probably important - both values lie in range [0..pi] or [-pi..0] ), - , sum equal to ab = atan2(cos(a)*sin(b)-sin(a)*cos(b), cos(a)*cos(b)+sin(a)*sin(b)) these expressions angles between azimuths, taking account possible angle wrapping around 360

jquery - Print another page using JavaScript from a page by clicking on a button -

i have html page button allows printing of specific content following code: <div class="below_movie_left" id="printablearea"> printing contents </div> <input type="button" class="submit_button" onclick="printdiv('printablearea')" value="print" style="float:right;" /> <script> function printdiv(divname) { var printcontents = document.getelementbyid(divname).innerhtml; var originalcontents = document.body.innerhtml; document.body.innerhtml = printcontents; window.print(); document.body.innerhtml = originalcontents; } </script> well, it's printing specific content perfectly. but, want print page using button. page name finalprinting.php so want, when press print button it's should print finalprinting.php page instead of existing contents of page. you need use ajax. <input type="button" id="loadpage...

testing - How can we run windows service as 100 different instances on a single windows system? -

i have java based client application running on windows platform (installed on windows system). application run windows service on system , users interact service using web based application (enterprise). want run service 100 different instances , 1 or 2 user interact these 100 instances in simultaneously. how can run windows service 100 different instances on single windows system? there tools support kind of load testing?

php - Notice: Undefined index even when using ISSET -

this question has answer here: reference - error mean in php? 29 answers i can't figure out why receive error. after pressing add button notice disappears @ refresh. <?php session_start(); //session_destroy(); $page ='index.php'; mysql_connect('localhost','root','') or die(mysql_error()); mysql_select_db('cart') or die(mysql_error()); if (isset($_get['add'])) { $_session['cart_'.$_get['add']] +'1'; } function products() { $get = mysql_query('select id, name, description, price products quantity > 0 order id desc'); if (mysql_num_rows($get) == 0 ) { echo "there no products display"; } while ($get_row = mysql_fetch_assoc($get)) { echo '<p>'.$get_row['name...

javascript - How to call a function on the scope from a string value -

i have object containing array of strings $scope.actions=[ "add_inscription", "add_tools", "add_instruction", "remove_inscription", "remove_tools", "remove_instruction" ]; and able dynamic action calls through delegating function.. $scope.delegate = function () { var arg = arguments[0]; ( key in $scope.actions ) { if ($scope.actions[key] == arg ) { // call function has matching name } } } so in template have this <button ng-click="delegate('add_inscription')">add inscription</button> i don't know if thinking in right direction either,, point actions object pretty large , don't want write massive switch case statement have update time. is there way in angular? i have no problem doing in straight javascript var fnstring = "add_inscription"; // find object var fn = window[fnstring]; // if o...

jquery - How to stop div from loading on mobile? -

i looking away speed mobile site. one way remove giant fading banner - using css 'display none' , 'visability hidden' wont stop images loading on backend. from can tell anyway. google speed test says banner still loading. i tried jquery replacewith content of div empty, works visually. images still seam load in code background. google still reports same images loading. guess div created millisecond jquery kicks in? jquery removes after dom ready, ready means banner image loaded/is loading. if want remove it, need rewrite code little bit or can create class mobile , desktop , load image background in div, on mobile won't load image , hide div

cron - Using Zenity in a root incron job to display message to currently logged in user -

working on script auto-upload files placed in directory, , display link them logged in user. users of machine authenticated via ldap. the directory being watched incron outside of of users' directories, , symlinked /home/username/uploads directory each user. when user places file here, automatically uploads without issue. where run problems displaying file url current user. here's relevant code: from /var/spool/incron/root /home/public/uploads in_close_write /home/public/upload_files.sh > /dev/null 2>&1 lines /home/public/upload_files.sh pertaining zenity display: display="$(ck-list-sessions | grep "active = true" -a1 | tail -n 1 | cut -f2 -d"'").0" zenity --info --text="http://aniceurlhere.com/`date +%m.%d.%y`/$filename" --display=$display as mentioned, upload completes, zenity message never displayed. looking through /var/log/cron, can see job run , complete, , no errors shown there. any assistance ...

java - \n and \r seem to work everywhere. Why is line.separator more portable? -

Image
i perusing through questions, , found system.getproperty(line.separator) used in place of \n author's comment code "portable". reading through various forums, i've seen 2 groups: people there's difference between linux's , windows' interpretation of newline characters, , compensates (with no clear evidence). people there's no difference showing code , output examples, applies code example , not universally. my feeling is: it's non-standard os's, example company's industrial scanner's os example, you'll notice difference. when going see difference between \n , line.separator ? can show example, please? how did go discovering variation occurs? incorrect line endings frequent annoyance. example, windows notepad shows when writing file \n instead of \r\n (windows' line.separator): those little boxes supposed line breaks. the other way around, when \r\n used in place of \n (unix' line.separato...

Using Python to parse roman numerals using Regex -

this question has answer here: converting roman numerals integers in python 12 answers i need convert roman numeral string integer. have no clue how start, need use regex. import re def romannumeraltoint(romannum): romannum = romannum.upper() totalvalue = 0 i have series of tests should past: def test(): print("tests started.") x = "iii" "" if romannumeraltoint(x) == 3 else print(x + " - " + str(romannumeraltoint(x))) x = "iv" "" if romannumeraltoint(x) == 4 else print(x + " - " + str(romannumeraltoint(x))) x = "ix" "" if romannumeraltoint(x) == 9 else print(x + " - " + str(romannumeraltoint(x))) x = "c" "" if romannumeraltoint(x) == 100 else print(x + " - " + str(romannumeraltoint(x))) ...

mongodb - Meteor mongo shell latest? -

when run meteor mongo get: mongodb shell version: 2.4.9 but upgraded latest mongo (2.6.1) how can run meteor mongo latest mongo shell version installed (2.6.1)? meteor has own set of dependencies, including mongodb. means version used meteor depend on meteor rather system. see "updated dependencies" notes in this file more details.

asp.net mvc 4 - {"No parameterless constructor defined for type of 'System.String[]'."} while deserailsing json data -

this controller [nocache] public actionresult saveassociate(string data) { javascriptserializer json = new javascriptserializer(); list<string> mystring = json.deserialize<list<string>>(data); return content("hai"); } expression data value : [{"assetname":"8888","assetnumber":"8888","classification":null,"parentasset":null,"serialnumber":"8888","parentcompany":"jpl holdings","barcode":null,"rfidtags":null,"assetid":"dfe2ae51-f153-4a67-bd3b-0114d8a40751","notes":null,"manufacturer":null,"departmentid":null,"department":null,"supplierid":null,"supplier":null},{"assetname":"552014","assetnumber":"552014","classification":null,"parentasset":"8888",...

angularjs - How can I change my application state using ui-router from inside an interceptor? -

my config file looks this: app.config(['$httpprovider', '$locationprovider', '$sceprovider', '$state', '$stateprovider', function ( $httpprovider, $locationprovider, $sceprovider, $state, $stateprovider) { $sceprovider.enabled(false); $locationprovider.html5mode(true); $httpprovider.interceptors.push(authinterceptor); var authentication = { name: 'authentication', url: '/authentication', views: { 'root': { templateurl: function (stateparams) { return '/content/app/authentication/partials/home.html'; } } } }; $stateprovider .state(authentication) .etc etc etc here's interceptor: app.factory('authinterceptor', function ($q, $rootscope, $state) { function s...

winforms - Selecting new value from form using watin -

i have watin.core.teaxfield date = x.textfield(find.byid("whatever")) date.value=2014-06-06"....this set value question how can select value label or combo box is windows form .thanks for combobox, can select value using such as: selectlist selectlist = browser.selectlist(find.byid("some_id")); selectlist.option("some_option").select(); to label value: string value = browser.label(find.byid("some_id").text;

objective c - Append logs into file -

i want make analogue of nslog() write file. have problem writing logs file. code below doesn't append logs file. overwrite it: file * pfile; pfile = fopen ([filename utf8string],"a+"); va_list arglist; va_start(arglist, format); nsstring* formattedmessage = [[nsstring alloc] initwithformat: [nsstring stringwithformat:@"%@: %@", [date description], format] arguments:arglist]; va_end(arglist); nslog(@"%@", formattedmessage); fprintf(pfile, "%s\n", [formattedmessage utf8string]); fclose (pfile); how fix it? the problem seems '+' character after 'a' in fopen instruction. indicating want open new file in append-only mode. try taking out. http://www.tutorialspoint.com/c_standard_library/c_function_fopen.htm

c# - send information from one form to another WindowsForms -

i have problem: have forms. 1 form has datagridview , button. when click the button, creating form2, input information. , these information need add datagridview on first form. when click button "add" in form2, have error nullreferenceexception unhandled(object reference not set instance of object.). please me! form1 private string client = null; private string driver = null; private string carmodel = null; private string carkey=null; public string goodsname2 = null; public string goodsprice2 = null; public string goodscount2 = null; addwaybilgoods add_waibil_goods = null; public waybil() { initializecomponent(); base base_ = new base(share.server_address, share.login, share.password, share.database); base_.fill_combo(comboclients, "clients", "clientsname"); base_.fill_combo(combodrivers, "drivers", "driversname"); base_.fill_combo(combomodel, "c...

extjs - Changing order of tabs in Ext.tab.panel without cut-paste of code manually -

i writing code below in sencha touch 2.3. there way bring nestedlist show before formpanel (it after) without cutting , pasting code manually? each of tabpanel's component having rank or order property can set? thanks ext.create("ext.tab.panel", { fullscreen: true, tabbarposition: 'bottom', items: [ { title: 'home', iconcls: 'home', cls: 'home', ... }, { xtype: 'formpanel', .. }, { xtype: 'nestedlist', .. } ]}); you cannot @ definition time @ runtime calling tabpanel.insert(newindex, nestedlist) , newindex 1 , nestedlist reference existing nested list.

jQuery on() variable as selector issue -

i can't understand i'm doing wrong , why code works fine: $(document).on('click', '[data-slider-next]', function() { slider('next'); }); while breaks behaviour of slider: var $slider_next_btn = $('[data-slider-next]'); $(document).on('click', $slider_next_btn, function() { slider('next'); }); context: first: http://jsfiddle.net/ynts/zend2/ ; second: http://jsfiddle.net/ynts/6frsn/ . <div class="b-slider" data-slider> <div class="b-slider__arrow b-slider__arrow_l" data-slider-prev>←</div> <div class="b-slider__arrow b-slider__arrow_r" data-slider-next>→</div> <div data-slide data-content="1.1"></div> <div data-slide data-content="1.2"></div> <div data-slide data-content="1.3"></div> </div> // slider function itself. function slider( _direction ) { ...

javascript - prevent "up arrow" key reseting cursor position within textbox -

i added predictive text input fields web-app supporting. big deal, right? not really, seems if web-app doesn't -- behind times , end-users complaining. (at least that's how on here). so, question has "up" arrow key. the predictive textbox has onkeyup listener. the handler segregates key strokes , depending on character user entered. the arrow key allows user navigate in div created loaded "suggestions." have several variables tracking indexes, etc... basically, when user hits arrow change id of div id has css associated make div appear though selected. additionally grab value in div , assign textbox user able type. the problem aesthetic one. inherently text boxes learning, arrow key reset cursor position. happening before writing new value text field. so, on each arrow stroke, user seeing jumping cursor in textbox (it jump beginning , appear @ end). here's code - if (event.keycode === 38 && currentuserinput.length >...

eclipse - Suddenly, I can't run any project. Python/Eclispe [error] -

i working on code, , i've started getting error. i've tried run projects - same error. traceback (most recent call last): file "c:\python27\lib\site.py", line 549, in <module> main() file "c:\python27\lib\site.py", line 538, in main aliasmbcs() file "c:\python27\lib\site.py", line 463, in aliasmbcs import locale, codecs file "c:\python27\lib\locale.py", line 15, in <module> import encodings file "c:\python27\lib\encodings\__init__.py", line 44, in <module> _aliases = aliases.aliases attributeerror: 'module' object has no attribute 'aliases' edit: tried switch workspace , create new pydev project, cant create project because there no interpreter choice. will me? in advance!

Boost asio - async reading established number of chars from stdin -

i wanna write boost::asio app reading stdin boost::asio::streambuf. anyway function works on streambuf made stdin_fileno boost::asio::async_read_until. other ones throws errors. there possibility read 100 first character stdin boost asio function? in principle works #include <boost/asio.hpp> #include <boost/asio/posix/stream_descriptor.hpp> using namespace boost::asio; using boost::system::error_code; #include <iostream> int main() { io_service svc; posix::stream_descriptor in(svc, stdin_fileno); char buf[100]; async_read(in, buffer(buf,sizeof(buf)), [&](error_code ec, size_t br) { std::cout << std::string(buf, br) << std::flush; if (ec) std::cerr << ec.message(); }); svc.run(); } when used as cat input.txt | ./test | wc -c will output 100 expected (and echo input). can use live terminal input: ./test | wc -c when input shorter 100 bytes, ec.mess...

html5 - CSS3 picture full screen -

how can make full screen picture on website ?? try lots of methods, still can't make right. i did : width: 100%; height: 100%; text-align: center; background:url(images/top.png); -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; and well, alright make full width have insert lots of text or change height of picture... than try : width: 100%; height: 100%; text-align: center; position: absolute; background:url(images/top.png); -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; background-attachment: fixed; min-width: 100%; min-height: 100%; this method works perfect, when add second div under first one, second div on first one... so question is, how can make full screen picture on website ! want have 100% height , 100% width, , when add second div go under first one. thanks help. { position: absolute; background-image: url(image...

Python MySQL Parameterized Queries -

i having hard time using mysqldb module insert information database. need insert 6 variables table. cursor.execute (""" insert songs (songname, songartist, songalbum, songgenre, songlength, songlocation) values (var1, var2, var3, var4, var5, var6) """) can me syntax here? beware of using string interpolation sql queries, since won't escape input parameters correctly , leave application open sql injection vulnerabilities. the difference might seem trivial, in reality it's huge . incorrect (with security issues) c.execute("select * foo bar = %s , baz = %s" % (param1, param2)) correct (with escaping) c.execute("select * foo bar = %s , baz = %s", (param1, param2)) it adds confusion modifiers used bind parameters in sql statement varies between different db api implementations , mysql client library uses printf style syntax instead of more commonly accepted '?' marker (used eg. p...

r - Where is knitr cached output stored? -

in cache directory, 1 can use lazyload view environment @ end of chunk. output of chunk (that printed if document compiled) stored? use source! look @ source code here https://github.com/yihui/knitr/blob/master/r/cache.r you can see mechanism explained here (within new_cache function) # when cache=3, code output stored in .[hash], cache=true won't lose # output cachesweave does; cache=1,2, output evaluate() list cache_output = function(hash, mode = 'character') { get(sprintf('.%s', hash), envir = knit_global(), mode = mode, inherits = false) } i.e. stored object in knit_global environemnt` you can inspect these objects ls(knitr::knit_global(), = true) i.e. 3 simple chunks below ```{r, cache=true} summary(cars) ``` ```{r } ls(knitr::knit_global(), = true) ``` ```{r } get(ls(knitr::knit_global(), = true)[1], knitr::knit_global()) ``` give following output summary(cars) ## speed dist ## min. : 4.0 min. ...

ios - Limit Gesture Recognizer to Only One Specific UIView? -

i have uiview called myview on myviewcontroller . have uigesturerecognizer called swipeleft (code below) detects when user swipes left on it. the problem is: myviewcontroller recognises same gesture on whole screen , performs action. app perform mymethod when swipeleft in particular area of myviewcontroller , area being myview . uiswipegesturerecognizer *swipeleft = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(mymethod:)]; swipeleft.direction = uiswipegesturerecognizerdirectionleft; swipeleft.delaystouchesbegan = yes; [self.myview addgesturerecognizer:swipeleft]; more details: using residemenu , myviewcontroller right menu, when visible, whole view of myviewcontroller recognises swipes in directions. change recogniser in particular uiview myview . thanks! first need add swipe gesture view controllers header file. @property (strong, nonatomic) uiswipegesturerecognizer ...

java - How to send the right context to the new object -

i have public class pagefragment extends fragment create 6 pages views fills class. here pagefragment class: public class pagefragment extends fragment { static final string arg_page_number = "arg_page_number"; int pagenumber; int backcolor; public linearlayout framescontainer; executorservice ex = executors.newcachedthreadpool(); future<arraylist<elementdata>> s = ex.submit(new mythread()); public static pagefragment newinstance(int page) { pagefragment pagefragment = new pagefragment(); bundle arguments = new bundle(); arguments.putint(arg_page_number, page); pagefragment.setarguments(arguments); return pagefragment; } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); pagenumber = getarguments().getint(arg_page_number); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.table_r...

Java software design -

scenario: consider following abstract class measurementtype , subtypes acceleration , density : public abstract class measurementtype { protected string name; protected string[] units; public measurementtype() {} public measurementtype(string name) { this.name = name; } protected void setname(string name) { this.name = name; } protected string getname() { return name; } protected void setunits(string[] values) { this.units = values; } } public class acceleration extends measurementtype { private string name; public acceleration () { super(); } public acceleration(string name) { super(); } } public class density extends measurementtype { private string name; public density() { super(); } public density(string name) { super(); } } question: what need subtypes since there isn't in classes differentiates them apart enough (at least in implementations) give them right exist own entities,...

r - Passing information between threads (foreach with %dopar%) -

i'm using dosnow- package parallelizing tasks, differ in length. when 1 thread finished, want some information generated old threads passed next thread start next thread immediatly (loadbalancing in clusterapplylb) it works in singlethreaded (see makeclust( spec = 1 )) #register snow , dosnow require(dosnow) #change spec 4 or more, see problem registerdosnow(cl <- makecluster(spec=1,type="sock",outfile="")) numbersprocessed <- c() # init processed vector x <- foreach(i = 1:10,.export=numbersprocessed) %dopar% { #do working stuff cat(format(sys.time(), "%x"),": ","starting",i,"(numbers processed far:",numbersprocessed, ")\n") sys.sleep(time=i) #appends number general vector numbersprocessed <- append(numbersprocessed,i) cat(format(sys.time(), "%x"),": ","ending",i,"\n") cat("--------------------\n") } #en...

Every 3rd Iteration of PHP Loop -

when 'every 3rd iteration' mean 'every 3rd iteration... starting number 4' if every 3rd, target appropriate iterations so: <?php if ($count % 3 == 0) : ?> bear in mind i've set $count 1 beforehand but iterations need start 4th, 7th, 10th etc. does know how can acheive this? can simple if statement 1 above? unfortunately don't think for loop possible wordpress loop i'm dealing with your thoughts using modulus operator sound, need expand scope of logic surrounding it: you want every third iteration after initial 4 have passed. begin logic after first 4: if ($count > 4) then, want each 3 after that. counter includes initial 4 iterations didn't want include, remove counter , check if current iteration multiple of 3: if (($count - 4) % 3 === 0) this should give you're looking for. if ($count > 4) { if (($count - 4) % 3 === 0) { ... } } you can put 1 line: if ($count > 4 &...

label - R lattice barchart: How to write the total sum on each bar in multiple panels? -

Image
i have lattice bar chart multiple panels , add sum of each bar on top of bars (e.g. (70) on top of first bar on top left, (20) on second one, (150) on third 1 etc.). there similar question here not find way adapt code plot. unlike in example, add 'total sum' of men , women on top of each bar vertical bar. not label them separately using ltext shown here . suggestion, using ltext or other way, helpful. civ1<-c("single","single","marr","marr","single","single","marr","marr","single","single","marr","marr","single","single","marr","marr") sex<-rep(c("women","men"),8) year<-rep(c(rep(1990,4),rep(2000,4)),2) type1<-c(rep("traditional",8),rep("dual-earner",8)) earn1<-c(seq(10, 160, = 10)) df<-as.data.frame(cbind(civ1,sex,year,type1,earn1)) df$earn1<-...

ruby on rails - Is it worth testing low-level code such as scopes? -

is profitable test "core" features such scopes , sorting? have several tests test functionality similar what's below. seems me it's testing rails core features (scopes , sorting), well-tested already. i know may seem "opinion" question, i'm trying find out if knows miss if assume scopes/sorting tested , not valuable developers test. my thoughts if scopes/sorting "broken", there's nothing can if rails core code broken refuse touch core code without very, reason (makes updating later on nightmare...). i feel "safe" more tests if these tests aren't providing value, taking space , time on test suite. # user.rb model class user < activerecord::base scope :alphabetical, -> { order("upper(first_name), upper(last_name)") } end # user_spec.rb spec context "scopes" describe ".alphabetical" "sorts first_name, last_name (a z)" user_one = create(:user, first_name: ...

r - Add simulated poisson distributions to a ggplot -

Image
i have made poisson regression , visualised model: library(ggplot2) year <- 1990:2010 count <- c(29, 8, 13, 3, 20, 14, 18, 15, 10, 19, 17, 18, 24, 47, 52, 24, 25, 24, 31, 56, 48) df <- data.frame(year, count) my_glm <- glm(count ~ year, family = "poisson", data = df) my_glm$model$fitted <- predict(my_glm, type = "response") ggplot(my_glm$model) + geom_point(aes(year, count)) + geom_line(aes(year, fitted)) now want add these simulated poisson distributions plot: library(plyr) poisson_sim <- llply(my_glm$model$fitted, function(x) rpois(100, x)) the plot should (red points photoshopped): you can convert simulated values vector , use them make new data frame 1 column contains years repeated each 100 times , second column simulated values. poisson_sim <- unlist(llply(my_glm$model$fitted, function(x) rpois(100, x))) df.new<-data.frame(year=rep(year,each=100),sim=poisson_sim) then add simulated points geom_jitter() . g...

java - Reading a text file using Scanner and count every time each alphabet appear -

so have assignment array. asked use scanner read through text files , record occurrences of each alphabet , store them in table. for example: public class { char[] alphabet = "abcdefghijklmnopqrstuvwxyz".tochararray(); public void displaytable () { (int = 0; < alphabet.length; i++) { system.out.println(alphabet[i] + ": " + count); } } i don't know how construct method store occurrences of each alphabet. it supposed like: public void countoccurrences (scanner file) { //code written here } if text file has line , line : hello world the method ignore integers or symbols , output char appeared in table. d: 1 e: 1 h: 1 l: 3 o: 2 r: 1 w: 1 i can't figure out myself , appreciated! thanks, shy simply use map . read inline comments more info. map<character, integer> treemap = new treemap<character, integer>(); // initialize default value 0 characters (char = 'a'; ...

python - How to assign to repeated field? -

i using protocol buffers in python , have inside person message repeated uint64 id but when try assign person.id = [1, 32, 43432] i error assigment not allowed repeated field "id" in protocol message object how assign repeated field ? as per documentation , aren't able directly assign repeated field. in case, can call extend add of elements in list field. person.id.extend([1, 32, 43432])

How to run wget from Windows 8.1 to reboot TP Link router -

i need run following line , don't know how to. please. here code: wget -q0 --user=user --password=pass \ http://192.168.1.1/userrpm/sysreboot.htm?reboot=reboot > /dev/null os: windows 8.1 thanks. you need wget windows, can download here http://gnuwin32.sourceforge.net/packages/wget.htm open notepad , paste code, save "myscript.bat" make sure doesn't have .txt put "myscript.bat" in same folder wget.exe try it, should work

Spotfire create growth calculated column -

i totally new @ spotfire environtment. want create new calculated column growth of other column. here data : item || date || value || growth || 12/12/2014 || 102 || || 13/12/2014 || 121 || 19 b || 12/12/2014 || 141 || b || 13/12/2014 || 111 || -30 how create growth column custom expression? i sample code solve similar problem. but, still got error. first of create hierarchy named hirarki include item , date. create custom expression, there's error said "couldnt find hierachy : 'hirarki'" sum([value]) on (intersect(parent([axis.hirarki]),[axis.hirarki])) - sum([value]) on (intersect(parent([axis.hirarki]),previous([axis.hirarki]))) why spotfire couldnt find hierarchy? thank you, cheers i think formula calculates need sum([value]) on ([item],[date]) - sum([value]) on (intersect([item],previous([date])))

stored procedures - 1048 error even when value is given to the columns mysql -

i have table named staff create table `staff` ( `idstaff` int(11) not null auto_increment, `fname` varchar(45) not null, `lname` varchar(45) not null, `address` varchar(45) not null, `gender` varchar(45) not null, `bloodgroup` varchar(3) not null, `dob` date not null, `mobile_no` varchar(45) not null, `email` varchar(45) not null, `qualification` varchar(45) not null, `department` varchar(45) not null, `designation` varchar(45) not null, `joindate` date not null, `retiredate` date not null, `refname` varchar(45) not null, `mobile` varchar(45) not null, `relationship` varchar(45) not null, primary key (`idstaff`) ) engine=innodb auto_increment=1003 default charset=utf8; then stored procedure insert data delimiter $$ create definer=`root`@`localhost` procedure `insert_staffs`( in fnme varchar(45), in lnme varchar(45), in address varchar(45), in gender varchar(45), in bloodgroup varchar(3), in dateob date, in mobilenum varchar(45), in email varchar(45), in edu varchar(45), in de...