Posts

Showing posts from June, 2013

api - Laravel X-CSFR-Token mismatch with POSTMAN -

i try talk rest api built laravel. call postman rejected due token mismatch. guess need include csrf token in header. need encrypted one? when insert token still error there token mismatch. i retrieve token using: $encrypter = app('illuminate\encryption\encrypter'); $encrypted_token = $encrypter->encrypt(csrf_token()); return $encrypted_token; but supposed change on every refresh? if aren't using forms - api example - can follow steps here https://gist.github.com/ethanstenis/3cc78c1d097680ac7ef0 : essentially, add following blade or twig header <meta name="csrf-token" content="{{ csrf_token() }}"> install postman interceptor if not installed, , turn on then, in browser log site (you need authorised), , either inspect element or view source retrieve token in postman, set get/post etc needed, , in header create new pair x-csrf-token tokenvaluetobeinserted235kwgeioiulgsk some people recommend turn...

email - Modify background color of MailItem in Outlook 2013 Inbox -

is there way modify background color in outlook inbox listing of e-mails ( mailitem instances) programmatically? i'd create add-in allow me color-code emails according rules. i've went through mailitem properties in documentation , wasn't able find display-format related. the mailitem class doesn't provide that. instead, need customize view in outlook. you can use currentview property of folder or explorer class view object representing current view. obtain view object view of current explorer, use explorer.currentview instead of currentview property of current folder object returned explorer.currentfolder. the view object allows create customizable views allow better sort, group , view data of different types. there variety of different view types provide flexibility needed create , maintain important data. the table view type (oltableview) allows view data in simple field-based table. the calendar view type (olcalendarview) allows view data i...

c# - Multiple socket connection -

i have 6 devices, price checkers. have project client in supermarket scan product on device , return price of product. have managed connect 1 device, bar code , send data. can not seem connect multiple socket connection. code when receive , send data: connecting device: private void connect1(string adip, int porta) { try { ipendpoint ip = new ipendpoint(ipaddress.parse(adip), porta); connect1 = new socket(addressfamily.internetwork, sockettype.stream, protocoltype.tcp); connect1.connect(ip); } catch (system.net.sockets.socketexception se) { messagebox.show(se.message); } } getting barcode: private void getbarcode() { byte[] data = new byte[1024]; int receiveddatalength = lidhje.receive(data); numbercodebar = encoding.ascii.getstring(data, 0, receiveddatalength); } sending...

c - is it possible compare a 16-bit value with a 8-bit compare match ISR -

Image
i trying make servo controller have higher resolution attiny85 8-bit timer/counter. far have managed 2000 positions on servo (1µs/step) within time frame of 21'000 µs. have managed move 5 servos sequential , different speed, want move them synchronous. my biggest problem don't how should make happen! have looked around on other servo codes including servo8bit library , tried find way. seems of examples uses compare match isr move servos "at same time", problem have 16-bit integer want compare. is there way magic can use 8-bit compare match isr 16-bit integer? or of have other suggestions on how can move servos synchronous without using compare match isr? i hope questions make sense! since don't have code show yet (only flawed attempts without compar match isr makes no sense) post link tinyservo code if helps. edit 1: here part of code mentioned , didn't post first time: void servomove(void) { uint16_t nextpulse = hpulse[0]; timersetup (...

linux - Execute a shell file from anywhere -

i can open arduino , android studio ide irrespective of current path these commands ~/arduino/./arduino ~/android/./studio i've created aliases both of them on .bashrc file , working fine. i want know if there more efficient way of solving kind of problems? ~ represents home directory in system. why can open programs anywhere. but, if login user, won't work ~ represent user's home directory. if want can replace ~ /home/<yourusername> (the absolute path home directory) or /root depending upon installation settings.

unit testing - Wallaby js in Visual Studio : tests in different folder -

i using wallaby.js jasmine fe unit tests. separate tests productive code in such way, create 2 projects - , a_test. productive code in , test code in a_test. the problem wallaby is, can not make work such configuration since seems not support relative '../../' notation. my example json configuration: { "files": [ "../../a/src/*.js" <--- part doesn't work ], "tests": [ "test/*spec.js" ], "testframework": "jasmine@2.2.1" } (it seems wallabys fault since test in jasmine works fine ../ paths, full path doesn't work) do know if possible support such structure? thanks! i added wallaby.json file visual studio solution items. physically placed outside folders of 2 projects. 1 called ckm , other called ckmclientunittest. the following wallby.json resulted in running javascript test separate project, including sut javascript's main project. jquery included in te...

c# - Windows 8.1 Store app Open Xml file in storageFolder -

i creating notes modern ui app in c# , store user's note in xml file. problem can't open xml file. storagefolder storagefolder = windows.storage.applicationdata.current.localfolder; storagefile file = await storagefolder.getfileasync("mynotes.xml"); if (file != null) { xmldocument myfile; myfile = await xmldocument.loadfromfileasync(file); //it crashes here ! } after running above code app crashes , visual studio opens app.g.i.cs file , shows me global::system.diagnostics.debugger.break(); file exists here code use create it storagefolder storagefolder = windows.storage.applicationdata.current.localfolder; storagefile file = await storagefolder.createfileasync("mynotes.xml"); thank in advance.

How to trigger something within a resize event with a jQuery plugin -

i'm trying further jquery learning making tiny little basic plugin inject html, apply css element (can changed via passing options call) , displaying screen width , height on resize. there still elements such css don't work me yet. 1 thing don't know @ moment how can pass in event listener resize within plugin? my plugin far: $.fn.windowsize = function( options ) { // outline settings var settings = $.extend({ color: "#000000", backgroundcolor: "yellow", position: "fixed", top: 0, left: 0 }, options ); // screen sizing vars var the_width = $(window).width(); var the_height = $(window).height(); // measure html var measure = '<div id="measurements">' + '<span>width:</span><span id="width">risize find out</span>' + '<span>height:</span><span id="height"...

python - sklearn LDA unique labels issue -

i have code used run uses lda (linear discriminant analysis) class sklearn.lda module. gives error below. lately updated sklearn package, think might caused that. however, still not understand problem is. tell me wrong putting 1 , -1 labels? far understand problem related labeling. traceback (most recent call last): file "<ipython-input-94-9935ca0189ad>", line 1, in <module> lda.fit([atom.coords atom in nm_1.atoms], nm_1.correlations[1][0]) file "c:\anaconda\lib\site-packages\sklearn\lda.py", line 415, in fit self.classes_ = unique_labels(y) file "c:\anaconda\lib\site-packages\sklearn\utils\multiclass.py", line 106, in unique_labels raise valueerror("unknown label type: %r" % ys) valueerror: unknown label type: array([ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1....

c# - List available network printers (non-installed as well) -

this question has answer here: is there .net way enumerate available network printers? 5 answers meaning able enum printers (network , local) if installed on pc however want able list not installed , can seen using (windows built-in) add printer dialog. is possible couldn't find useful browsing various forums/boards including stackexchange. meaning tried built-in .net classes , wmi ( select * win32_printer ) list installed printers. thank in advance edit: please notice suggested answer not address non-installed printers rather installed ones. able list those. thx i not believe there in .net can this, need make native call. here msdn page how enumerate network resources, need p/invoke wnetenumresource function netresource objects back. you looking objects have dwtype of resourcetype_print , when find them check lpremotename name of printe...

ruby - Rails App hosted in heroku, with Cloudfront, giving net::ERR_INVALID_CHUNKED_ENCODING -

when try serve gzipped assets, i'm getting net::err_invalid_chunked_encoding randomly in assets. i'm using rack zippy gem, i've tried use rack deflate , gives same error. cloudfront pointing heroku. more info , relevant source codes: $ rake middleware use honeybadger::rack::userinformer use honeybadger::rack::userfeedback use honeybadger::rack::errornotifier use rack::sendfile use rack::zippy::assetserver use rack::lock use #<activesupport::cache::strategy::localcache::middleware:0x00000008358600> (...) config.ru # file used rack-based servers start application. require ::file.expand_path('../config/environment', __file__) use rack::chunked use rack::deflater run soprojetos::application initializer rack_zippy.ru rails.application.config.middleware.swap(actiondispatch::static, rack::zippy::assetserver) rack::zippy.configure |config| config.static_extensions << 'xml' end envir...

swift - What's the difference between a UIStackView And A UICollectionView in Xcode 7? -

what's difference between uihorizontalstackview , collection view(also vertical stackview)? can't collectionview horizontal , vertical? why people use both? what uistackview collection view can't? uicollectionview grid, uistackview 1 dimension: vertical or horizontal. uicollectionview uitableview, supports more single-column layouts. collection views provide same general function table views except collection view able support more single-column layouts. collection views support customizable layouts can used implement multi-column grids, tiled layouts, circular layouts, , many more. can change layout of collection view dynamically if want. vs the uistackview class provides streamlined interface laying out collection of views in either column or row me, stackview, benefit "autolayout" feature, example: put 4 views in stack, component decide how views presented on screen, depending on size.

c++ - Is it safe to cast a IDispatch* into an IUnknown*, without using QueryInterface, for interprocess COM objects? -

when dealing interprocess com objects, safe cast idispatch* iunknown* , without using queryinterface ? here our idispatch object comes other process otherprocess.exe . , colleague of mine says should call queryinterface on idispatch iunknown . currently i'm doing: void ccomthrowdispatch::checkcomavailabilty() const { iunknown * piunknown = m_spdispatchdriver.p; // line above problem ? // m_spdispatchdriver atl ccomdispatchdriver // handles object instanciated in process. // m_spdispatchdriver.p of type idispatch* if (piunknown == nullptr) return; bool bcomobjectreachable = ::coishandlerconnected(piunknown) == true; if (bcomobjectreachable == false) { throw myexception; } } my problem suggestion: dealing cases (access violations) when otherprocess.exe has crashed or has been killed. seems calling functions invoke on idispatch encapsulates objects no longer exisiting otherprocess.exe provokes these access viola...

javascript - Jquery animate opacity and margin on other element -

i have link when clicked, has show 2 other links. when click link, nothing happends. nothing. i have loaded in jquery before have script. this jquery script: $("#imd").toggle(function(){ $("#anw").animate({opacity:1},200); $("#3d").animate({margintop:75}, 200); },function(){ $("#anw").animate({opacity:0},200); $("#3d").animate({margintop:0}, 200); }); this css: #anw { width: 50%; background-color: #0f0; opacity: 0; } and html markup <div class="mid"> <h1><a href="#anw" id="imd">interactive media design</a></h1> <div id="anw"><br><a class="left" href="website.html">apps</a><a class="right" href="website.html">websites</a></div> <hr> <h1 id="3d"><a href="#">3d modelling</h1> ...

php - wordpress wp_enqueque not working -

i have simple question. function.php enqueque code: /** *enqueue styles. */ function circle_scripts() { //load css wp_enqueue_style( 'font-body', 'http://fonts.googleapis.com/css?family=michroma' ); wp_register_style( 'bootstrap-style', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '1.0', 'all' ); wp_enqueue_style( 'bootstrap-style' ); wp_register_style( 'animate', get_template_directory_uri() . '/css/animate.css', array(), '1.0', 'all' ); wp_enqueue_style( 'animate' ); wp_register_style( 'mycss', get_stylesheet_uri() ); wp_enqueue_style( 'mycss' ); //load js wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', get_template_directory_uri() . '/js/jquery-1.11.3.min.js', array(), '1.0.0', true ); wp_enqueue_script( 'jquery' ); wp_register_scri...

parameter passing - PHP - urlencoded() ampersand in url perceived as actual ampersand -

there dummy example php application shows causes me problems. <?php echo ((isset($_get['p'])) ? print_r($_get) : "<a href='http://example.com/a.php?p=" . urlencode('one & two') . "'>one & two</a>"); ?> if visit page without p parameter page output: http://example.com/one+%26+two , that's fine, if visit link, script return: array ( [p] => 1 [two] => ) and that's wrong. in real application, in url submitted 30 char long alphanumeric string contains special letters(swedish). edit: in real application use url rewrite: <ifmodule mod_rewrite.c> rewriteengine on rewriterule ^(.*)$ ../example.php?s=$1 [l,qsa] </ifmodule> can cause? - confirmed. issue. see answer below. you need send url using % escape ampersand. try 'one %26 two' <?php echo ((isset($_get['p'])) ? print_r($_get) : "<a href='http://exam...

php - All files and folders are not being listed in the imce file browser in Drupal 7 -

i using aws s3 bucket upload files, problem files , folders not being listed in file browser. in s3 bucket there 10000 files 1001 files being listed in file browser. what have done already: 1) set proper file , folder permission on aws 2) increase max_execution_time in php.ini more 5 mins please suggest next issue. there pagination module imce file listing. regards,.

html - Jquery panel + scroll from top detection? -

i testing type of panel jquery : http://codyhouse.co/gem/css-slide-in-panel/ but when want detect scroll top make appear div : no way :( a means detect scroll top inside panel? use kind of thing without result http://jsfiddle.net/apaul34208/zykar/3/ $(document).scroll(function () { var y = $(this).scrolltop(); if (y > 500) { $('.cache').fadein(); } else { $('.cache').fadeout(); } }); best regards, is looking for? http://jsfiddle.net/zykar/2327/ html <div class="topmenu"></div> css body { height:1600px; } .topmenu { display: none; position: fixed; top: 0; width: 100%; height: 60px; border-bottom: 1px solid #000; background: red; z-index: 1; } javascript $(document).scroll(function () { var y = $(this).scrolltop(); if (y > 1) { $('.topmenu').fadein(); } else { $('.topmenu').fadeout(); } }); ...

C++/CLI/C# Map generic types to template types -

when writing cli code interface between c++ , c#, have convert types in function calls can used in c# or c++. example, std::string doesn't exist in c#, have convert string^ , vice versa. now want wrap c++ class exposes templated function c# via interface should expose similar generic method. wrote cli ref class implements c# interface , holds pointer instance of c++ class: // c# public interface isomeclass { void somemethod<t>(t param); } //cli public ref class : isomeclass { public: generic<typename t> virtual void somemethod(t param) { _nativeptr->nativemethod<t>(param); // :( } // implementation details... }; // c++ class somenativeclass { public: template<typename t> void nativemethod(t&& nativeparam) { /*bla*/ } }; in specific case (using visual studio 2013), makes compiler crash. though don't think supposed crash, can guess not supposed work, after can't pass c# types directly c++ funct...

spring - Mongo @DBRef unique -

my application uses spring boot / jpa / mongodb. i map domain classes mongodb using org.springframework.data.mongodb.core.mapping.document; org.springframework.data.mongodb.core.index.indexed; org.springframework.data.mongodb.core.mapping.dbref; all except when trying make dbref unique : @dbref @indexed(unique = true) private user owner; i have tried different combinations of @dbref, @indexed (unique=true) , cannot make dbref unique. can make other field-types unique, such 'name' in following example @indexed(unique = true) @size(min = 2, max = 100) @column(length = 100) private string name; but cannot find how make dbref field unique. i'm coming morphia side of mapping, i'd try this: @compoundindexes({ @compoundindex(name = "owner", def = "{'owner.id' : 1}", unique = true) })

Catching SIGINT with conditional exit in Python -

i want catch sigint signal in python script. however, script should terminate if user enters correct password after sending sigint. can done in python? sample code illustrate problem: import signal def signal_handler(signal, frame): password = raw_input("enter password: ") if password != "secret": print("wrong password!") # todo don't let process end else: print("password correct. exiting now.") signal.signal(signal.sigint, signal_handler) edit: changed variable 'pass' 'password', suggested in comments below. you can capture sigint , dispatch call off function. e.g. import signal import sys import time def confirm_password(signal, frame, secret="shhh"): password = raw_input("enter password: ") if password == secret: sys.exit(0) else: print("password incorrect. refusing exit.") while true: signal.signal(signal.sig...

Laravel No query results for model -

hello i've been using laravel 5 3 days , i'm having problem. testing edit page , getting error no query results model . sample link http://localhost:8000/profile/sorxrob/edit . sorxrob there username. route: route::bind('user', function($user) { return app\user::where('username', $user)->first(); }); route::get('profile/{user}', 'consultaprofilecontroller@viewprofile'); route::get('profile/{user}/edit', 'consultaprofilecontroller@edit'); and in consultaprofilecontroller here public function: public function edit($id) { $account = user::findorfail($id); return view('consulta.edit', compact('account')); } whenever try http://localhost:8000/profile/sorxrob/edit gives me error no query results model when change route route::get('profile/{id}/edit', 'consultaprofilecontroller@edit'); works url should http://localhost:8000/profile/6/edit 6 id of sorxob. want username use...

java input/ output file problems -

the aim here method create file if not exist if exists : open , modify it... errors createnewfile() not member of class, exist() not member of class..i imported java.io.* post snippet..i hightlight problems comments quicker help... public void writecoordtofile () throws ioexception { file file = new file("fermipresentcoord.txt"); // boolean yes = createnewfile("fermipresentcoord.txt") throws ioexception; error when try //boolean yes = exists("fermipresentcoord.txt"); error exists not member of file // creates file file.createnewfile(); // creates filewriter object filewriter writer = new filewriter(file); // writes content file writer.write(pos_let); writer.write(pos_num); writer.flush(); writer.close(); } you need give file object, createnewfile() method of file class. function's of class can accessed using file's object(file).methodname(...

Resharper method call "At end of line" formatting style -

resharper has lot of formatting settings, didn't manage find method call parentheses layout options. the goal preserve kind of formatting: callfoomethod( parameter1, parameter2, parameter3 ); but after putting semicolon or calling cleanup i'm getting this: callfoomethod( parameter1, parameter2, parameter3 ); does know way solve this? maybe there way intervene in formatting process resharper's api extensions?

regex - Setting regular expression to validate URL format in Adobe CQ5 -

i want validate url inside textfield using adobe cq5, set properties regex , regextext usual, reason not working: <facebook jcr:primarytype="cq:widget" emptytext="http://www.facebook.com/account-name" fielddescription="set facebook url" fieldlabel="facebook" name="./facebookurl" regex="/^(http://www.|https://www.|http://|https://)[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$/" regextext="invalid url format" xtype="textfield"/> so when type inside component can see error message @ console: uncaught typeerror: this.regex.test not function to more accurate error comes line: if (this.regex && !this.regex.test(value)) { i tried several regular expressions , no...

css - set height of div(s) at fullscreen with a scrollbar in the div and a header -

i trying put quick viewer data. need 3 cells... header, , 2 columns (i'm using bootstrap). i'd 2 columns scroll independently of each other. i'll populating left column vertical data , when item selected, i'll use populate right column more vertical data... i won't know height of header either. i'm working right now: html, body { height: 100%; } .full-height {height: 100%;} and <div class='container-fluid full-height'> <div class='row'> <div class='col-md-12' id='headercontent'> </div> </div> <div class='row full-height'> <div class='col-md-6 full-height' id='events'></div> <div class='col-md-6 full-height' id='archive'></div> </div> </div> this closest i've been able far. when this, columns 100% of height of container (not taking header in accoun...

Polymer 1.0 notifyPath for array element -

simple example: <template is="dom-repeat" items="{{items}}"> <template is="dom-repeat" items="{{item.subitems}}"> <span>{{item}}</span> </template> <span on-tap="add">add</span> </template> attached: function () { this.items = [ { subitems:[] }, { subitems:[] } ] }, add: function (e) { e.model.item.subitems.push("test"); } this not refresh dom-repeat {{item.subitems}}. how can notify polymer of change? from docs mutations items array (push, pop, splice, shift, unshift) must performed using methods provided on polymer elements, such changes observable elements bound same array in tree. example: this.push('employees', { first: 'jack', last: 'aubrey' });

Python numpy: reshape list into repeating 2D array -

i'm new python , have question numpy.reshape. have 2 lists of values this: x = [0,1,2,3] y = [4,5,6,7] and want them in separate 2d arrays, each item repeated length of original lists, this: xx = [[0,0,0,0] [1,1,1,1] [2,2,2,2] [3,3,3,3]] yy = [[4,5,6,7] [4,5,6,7] [4,5,6,7] [4,5,6,7]] is there way numpy.reshape, or there better method use? appreciate detailed explanation. thanks! numpy.meshgrid you. n.b. requested output, looks want ij indexing, not default xy from numpy import meshgrid x = [0,1,2,3] y = [4,5,6,7] xx,yy=meshgrid(x,y,indexing='ij') print xx >>> [[0 0 0 0] [1 1 1 1] [2 2 2 2] [3 3 3 3]] print yy >>> [[4 5 6 7] [4 5 6 7] [4 5 6 7] [4 5 6 7]] for reference, here's xy indexing xx,yy=meshgrid(x,y,indexing='xy') print xx >>> [[0 1 2 3] [0 1 2 3] [0 1 2 3] [0 1 2 3]] print yy >>> [[4 4 4 4] [5 5 5 5]...

jquery - Javascript Masonry not working with created elements -

i have created page uses script create divs images inside of them , append image source using code. page intended update user's account uploaded images , display them. have followed many of tutorial guides , lead me of images being in 1 column , overlapping. pretty used code : http://codepen.io/desandro/pen/bdgrzg , doesn't work. can direct me in right direction did wrong? html code <div class="tab-content" id="photos"> <div class="grid-sizer"></div> <div class="grid"></div> </div> js code $(document).ready(function () { allimgs = document.getelementbyid("photos").getelementsbytagname("img"); //create elements each image for(i = 0; i<photoarr.length;i++) { if(i%3==0) { div = document.createelement("div"); div.classname = "entries row grid"; document.getelementsbyclassname(...

antlr - ANTLR4 - Access token group in a sequence using context -

i have grammar includes rule: expr: unaryexpr '(' (stat | expr | constant) ')' #labelunaryexpr | binaryexpr '(' (stat | expr | constant) ',' (stat | expr | constant) ')' #labelbinaryexpr | multipleexpr '(' (stat | expr | constant) (',' (stat | expr | constant))+ ')' #labelmultipleexpr ; for expr , can access value of unaryexpr calling ctx.unarystat() . how can access (stat | expr | constant) similarly? there solution doesn't require modifying grammar adding rule group? since you've labelled alternatives, can access (stat | expr | constant) in respective listener/visitor method: @override public void enterlabelunaryexpr(@notnull exprparser.labelunaryexprcontext ctx) { // 1 of these return other null system.out.println(ctx.stat()); system.out.println(ctx.expr()); system.out.println(ctx.constant()); }

javascript - Intercept all calls to jQuery -

i intercept calls $ , jquery functions. jquery() , $() , $.fn etc etc otherwise need work unimpeded. how can this? it appear after. (function(){ var oldjq = window.jquery; window.jquery = function(){ window.jquery.anthony.calls++; return oldjq.apply(null, arguments); }; window.jquery.anthony = { calls: 0 }; (var prop in oldjq) if (oldjq.hasownproperty(prop)) window.jquery[prop] = oldjq[prop]; window.jquery.prototype = oldjq.prototype; window.$ = window.jquery; })(); note not intercept functions called on jquery objects.

Inconsistency in HMAC signature generation in Python 3? -

running create_api_signature() method in python terminal return same value, while return different values when run in test. import hashlib import hmac import json import unittest def create_api_signature(_method, _url, _body, _timestamp, _secret_key): unicode_signature = _method.upper() + _url + json.dumps(_body) + str(_timestamp) s = hmac.new(_secret_key.encode(), unicode_signature.encode(), hashlib.sha256).hexdigest() return s class mytestcase(unittest.testcase): def test_create_signature(self): method = 'post' url = 'https://api.alpha.example.com/v1/tiers' body = { "mail": "test@gmail.com", "mot_de_passe": "mycomplexpassword", } timestamp = 1433948791 secret_key = 'secret_key' signature = create_api_signature(method, url, body, timestamp, secret_key) expected_signature = '136b629ac9744258cf558c2d541...

javascript - Single page app viewport mobile using Foundation -

i using foundation responsive website , have problem mobile devices not scaling viewport when load page via our ng-include. loads new content page , width of page breaks , requires horizontal scrolling. this doesn't happen in devices such galaxy note 3/4, happen in devices identical resolutions, such iphone 6 plus. have viewport attribute , scaling set: <meta name="viewport" content="width=device-width, initial-scale=1, target-densitydpi=device-dpi;"> any figuring out why doesn't scale when load new dynamic content single page application appreciated. i'm not sure if it's related (just thought of it), use document equalizer reflow often: $(document).foundation('equalizer','reflow'); i needed add min , max scale. although didn't test it, imagine needed add max scale, content flowing off screen. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, max...

twitter bootstrap - Chrome print to PDF with background colors -

Image
i have page based on bootstrap flat ui css , i'd print (save pdf). but can't print color of headlines , color of progress bar. saw tutorials there, didn't work. here live demo. you have enable option include background graphics. please see below

java - Sane pattern for immutable pojos and single field changes -

usually i'd love pojos immutable (well, contain final fields java understands immutability). current project, constant pattern need change single field pojo. working immutable pojo's in scenario seems cumbersome. how go having pojo's bunch of fields , each field should able "please give me copy of pojo 1 field changed"? big plus here can use composable functions. "start immutable pojo, push through bunch of unaryoperators , give me new immutable pojo". yes, that's common pattern - bunch of methods with prefix. each with* method "changes" single field, can have: person jon = new person("jon", "skeet"); person holly = jon.withfirstname("holly"); // holly skeet you can chain calls together, too: person fred = jon.withage(...).withfirstname("fred").withjob(...); note if end changing k fields in pojo n fields, you'll create k objects , need k * n assignments. the implement...

apache - Specify PHP ini file per vhost, with FastCGI/PHP-fpm configuration -

okay, going crazy trying figure out. (i have read hundreds of questions/answers, , google articles, none have answered it) i have changed using mod_php using php through fastcgi , fpm, using method described in this question , purely because under impression 'easy' specify php.ini files individual vhosts using set-up. what i'm pulling hair out over, how can specify custom php ini file each vhost uses? luckily, it's on test rig far ... hoping same on production server if can ever figure out i thought may as-well post whole process took configure fpm pools, @christianm mentioned, because i've not yet found full explanation on how it. the first part of copy of askubuntu post: https://askubuntu.com/questions/378734/how-to-configure-apache-to-run-php-as-fastcgi-on-ubuntu-12-04-via-terminal/527227#comment905702_527227 the last part how configure pools, , vhost use relevent pool settings here goes: install apache mpm worker (explanation of prefo...

c - Error running this fork code in my eclipse, and also have some concept confusion around this code -

so simple c code on fork professor gave us, i'm trying output code, when tried run in eclipse following error: info: internal builder used build gcc -o0 -g3 -wall -c -fmessage-length=0 -o forkdemo1.o "..\\forkdemo1.c" ..\forkdemo1.c: in function 'main': ..\forkdemo1.c:18:1: warning: implicit declaration of function 'fork' [-wimplicit-function-declaration] if( (pid = fork()) = -1) { ^ ..\forkdemo1.c:18:20: error: lvalue required left operand of assignment if( (pid = fork()) = -1) { but basic confusion around code is: pid_t pid's value? 11 or 10, creating child parent? #include <unistd.h> #include <stdio.h> #include <stdlib.h> int global = 10; int main(int argc, char* argv[]) { int local = 0; pid_t pid; printf("parent process: (before fork())"); printf(" local = %d, global = %d \n", local, global); if( (pid = fork()) = -1) { perror("fork"); exit(1); } else if (0 == pid) { /* child exe...

javascript - jquery .length- error says not valid property -

this question has answer here: why jquery or dom method such getelementbyid not find element? 6 answers i'm trying see if there elements inside 1 div, , also, if there more 1 element in div. if so, want things happen. i've gotten errors running script (not valid property) , more of js script doesn't executed if it's below this. so, other moving script down js page, options? logic seems fine, error bothers me. var firstdiv = $('.firstdiv'); var seconddiv = $('.seconddiv'); if( (seconddiv).html().length > 0 || $(firstdiv).html().length > 1 ){ make stuff happen } as minusfour mentioned, make sure selectors correct. if jquery object empty, html() method return null . there no length property on null . you can see how many elements jquery object wraps using length property: $('.seconddiv').length // shoul...

ios - UITableView - Check if Cell checkmark -

in uitableview, user can check or not check cell. how can figure out, witch checked , save in array? with following code, can check cell: -(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath{ uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; if ([cell accessorytype] == uitableviewcellaccessorynone) { [cell setaccessorytype:uitableviewcellaccessorycheckmark]; } else { [cell setaccessorytype:uitableviewcellaccessorynone]; } [tableview deselectrowatindexpath:indexpath animated:no]; } don't check checkmark accessory view of cells. cells being reused , mess logic. instead, keep mutable set of objects being presented cells 'selected' aka checked. when user taps cell can toggle membership of presented object in mutable set , update checkmark appropriately.

praw - possible to get subscription information for subreddits/users of Reddit? -

i see either list of subscribers given subreddit or list of subreddits individual user subscribes to. either of these bits of information available? in praw docs see my_reddits() seems mean can retrieve subscription list logged in user. i see in reddit api docs: https://www.reddit.com/dev/api#get_subreddits_mine_subscriber seems assume you're looking @ own/logged-in account? sorry post have not been able find in reddit api docs or praw docs. i'd appreciate relevant links or advice. you have have account information (username/password) in order see information. reddit api not provide way access information otherwise. had friend worked on project used type of information , needed passwords users.

voltrb - Is there a way to access each user account in Volt? -

is there way access each user account in volt? need able click on user._name , account see details... how access account of each user.? yes, users part of store.users collection, can access them , query them collection. store.users.all.each |user| puts user.name end

upload files to Dropbox from iOS app with Swift -

i have completed tutorial( https://blogs.dropbox.com/developers/2014/09/swift-apps-with-dropbox/ ) , linked ios app dropbox. however, want upload file app dropbox. tutorials out there have code in objective c, including main 1 dropbox ( https://www.dropbox.com/developers/core/start/ios ). does know how swift? thanks! it works. let textcontent = "hello swift upload" let textdata:nsdata? = textcontent.datausingencoding(nsutf8stringencoding) var client:dropboxclient? = dropbox.authorizedclient if let cli = client { cli.files.upload(path: "/swift-upload.txt", mode: files.writemode.add, autorename: false, clientmodified: nil, mute: false, body: textdata!) }

java - How to generate a hashcode from object with two list containing the same type of objects -

let's have class (the equal method exists): public class someclassa { private int a; private int b; @override public int hashcode() { final int prime = 31; int result = 1; result = prime * result + a; result = prime * result + b; return result; } } and class: public class someclassb { list<someclassa> firstlist; list<someclassa> secondlist; how construct hashcode 2 objects seen equals if have same objects in firstlist , same objects in secondlist. //hank public int hashcode() { final int prime = 31; int result = 1; result = prime * result + firstlist.hashcode(); result = prime * result + secondlist.hashcode(); return result; }

regex - htaccess browser language redirection -

rewritecond %{http:accept-language} ^(en|de)$ [nc] rewritecond %{http_host} !^%1.domain.dev$ [nc] rewriterule .* http://%1.domain.dev [r,l] this code causes redirection loop error. i've debug second condition, should prevent this, , both host , right side seems identical. 20th version or so, run out of ideas.

Show PHP object data inside javascript -

i know there have been many questions far asking php , js working together...i went through them, cannot find elegant solution use case. what have following php code in webpage fetches product info , shows it: <?php $p= new product($prodid); $p->getproductinfo(); //now show product info... echo "<div>product name: ".$p['productname']."</div>"; echo "<div>product rating: ".$p['productrating']."</div>"; //etc... ?> now have been asked instead of showing data directly in page, should show when button clicked. , should show inside bootbox modal dialog box so did: <span id='prod-details'> view product details </span> <input type='hidden' id ='prod-id' value='<?php echo $p['productid'];?>'> and in jquery file have: $('#prod-details').click(function( var prodid = $('#prod-id').val(); produc...

ansible playbook execute in this order: task, role, task, role, task -

forgive newbie question, execute 3 tasks , use 2 roles in playbook, in order: task role task role task this have far (task, role, task): --- - name: task role task hosts: 127.0.0.1 connection: local gather_facts: false pre_tasks: - name: task first foo: roles: - role: role second foo: post_tasks: - name: task third foo: is possible or should changing tasks roles? i recommend create roles post , pre tasks ansible. your site.yml must this: --- - hosts: localhost remote_user: "{{remote_user}}" sudo: yes gather_facts: false roles: - pre - main_role - post in roles folder must have 3 roles, pre, post , main_role.

select2 Font-Awesome + text in TemplateResult not working properly -

i attempting use templateresult format select2 choices include fontawesome icon in front of select text unfortunately not working, though followed documentation. font awesome icons display, text somehow lost in translation function formatfa(icon) { if (!icon.id) { return icon.text; } var $icon = $( '<i class="fa fa-circle" style="color:green"></i> ' + icon.text + ' ' ); return $icon; }; $('#gyr_ind').select2({ templateresult: formatfa }); here js fiddle of code see i'm talking in action http://jsfiddle.net/46f9c7jy/ icon.text outside <i> tag declaration $('<i></i>my-text'); not write text inside tag. something should work var $icon = $('<i class="fa fa-circle"></i>') .css({ 'color': icon.text }) .text(icon.text); here demo http://jsfiddle.net/dhirajbodicherla/46f9c7jy/3/ if text has outside ...

javascript - Using onbeforeunload to create a custom confirmation warning? -

i'm trying create custom alert function website. checks if there in form fields, , if there is, should display confirmation message if you're trying navigate away. (excluding submit , cancel button.) i have code check data, , navigation excluding buttons: var leave_page_confirm = true; function save_data_check() { var msg; if (leave_page_confirm === true) { $('.input-right').each(function() { if (this.value) { leave_page_alert(); } }); } } window.onbeforeunload = save_data_check; buttons want exclude being seen navigating away page contain: onclick="leave_page_confirm=false;" the leave_page_alert function defined this: var leave_page_alert...

tortoisesvn - How to correctly set an external path on SVN? -

Image
i'm trying set external path on svn. here in svn: right click on folder want external select "show properties" new -> externals in "externals", click new at local path, tried setting path wanted, whatever set, when update files, adds path wrote folder added external. example folder on svn "externals". if set local path ^/trunk/external , when i'll commit tries fetch files (all long path before)/externals/^/trunk/externals . how tell local path current directory? if set nothing, complains, if set ./ complains... for url fetch files from, works when set file, not folder? note: used this site unfortunately, part have trouble says: to add new external, click new... , fill in required information in shown dialog. i read tips afters don't help... if has concrete example lot. this dialog tortoisesvn you're having difficulties with: here, local path refers file or folder relative folder has externals prope...

extjs - Sencha Cmd 5: app build bundle is missing Ext.application function -

i using sencha command 5.1.3.61 (though i've tried other 5.1 versions). when run sencha app build testing, resulting app.js bundle missing required code ext - ext.application not defined. i created empty project compare , 1 generates app.js fine, project missing large chunk of included in ext-all-rtl-debug.js following key sections app.json: "js": [ { "path": "${ext.dir}/build/ext-all-rtl-debug.js" }, { "path": "app.js", "bundle": true }, { "path": "direct/api-debug.js", "remote": true } ], "output": { "base": "${workspace.build.dir}/${build.environment}/${app.name}", "page": { "path": "../../../index.html", "enable": false }, "microloader": { "path": "microloader.js", "embed": true, ...

jquery - Fetching query string parameters passed in a javascript file -

i have used this tutorial create js based widget. 1 thing need pass query string parameters in js file. tried document.location.href gave url of page widget placed(which quite obvious) code given below: <script src="http://example.com/widget.js?id=2" type="text/javascript"></script> <div id="widget"></div> i need fetch id=2 can pass further. thanks if give script id can write: <script src="http://example.com/widget.js?id=2" id="myscript" type="text/javascript"></script> <div id="widget"></div> <script> var myscript = document.getelementbyid('myscript'); var src= myscript.getattribute('src'); //get id src based on parameter using regular expression </script>

python 3.x - Find and delete list elements if matching a string -

i have list of strings stringlist = ["elementone" , "elementtwo" , "elementthree"] , search elements contain "two" string , delete list list become stringlist = ["elementone" , "elementthree"] i managed print them don't know how delete list using del because don't know index or using stringlist.remove("elementtwo") because don't know exact string of element containing "two" my code far: for x in stringlist: if "two" in x: print(x) normally when perform list comprehension, build new list , assign same name old list. though desired result, not remove old list in place. to make sure reference remains same, must use this: >>> stringlist[:] = [x x in stringlist if "two" not in x] >>> stringlist ['elementone', 'elementthree'] advantages: since assigning list slice, it replace contents same python li...

Dynamic XML parsing, data storage, and forms in c# -

so developing application want able dynamically parse xml file, grab attributes , populate form created based on elements present in xml file. values can edited, , written xml file opened. i've been able parse, save values database , populate forms, , write original xml file via hard coding, , think have idea dynamic "database" structure (a dictionary key node's name, , value dictionary if wanna store node's child node information, or string if i'm in furthest nested child node of element). i'm stuck on how grab information need , how store in "database" structure i've come with. i've done research , have seen people use "dynamic" object , linq. i've seen seems involve knowing path names they've needed before run time. ideas on how should going parsing file , grabbing data, first off? think if can figured out, rest should kind of fall place. say have xml <users> <user1 age="43">john do...

android - java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0 -

exception parcel java.lang.securityexception: permission denial: get/set setting user asks run user -2 calling user 0; requires android.permission.interact_across_users_full i see coders getting in situations, haven't seen addressed 'google play activity' module in hello world new project setup android studio, i'm pretty forced use last computer eclipse fried. 'blank activity' works on phone device , emulator 'blank activity' hello world new activity setup, not 'google play activity' hello world new activity setup. i've tried , without various option boxes checked, 'enable google play services'. have added both uses-permission android:name="android.permission.interact_across_users_full" uses-permission android:name="android.permission.write_external_storage" with no change result. application appears load, crashes 'unfortunately, application has stopped'. turns out google for...

angularjs - Update bounds in Angular-Google-Maps -

i trying use bounds of map limit markers refreshed. however, bounds never update in $scope or variable after map clicked , dragged. have done lot of googling wasn't able find angular-google-maps (not google map api v3). know how update bounds in angular-google-maps? this recent attempt: $scope.$watch('maps.bounds.northeast', function(newvalue, oldvalue) { if (newvalue !== oldvalue) { $scope.map.bounds.northeast = map.bounds.northeast; $scope.$apply(); } }); when this, map not show up. when try checking newvalue , oldvalue , having alert box popup if different, pops when pages loads that's it.

c# - Entity Framework DBContext.Entry() is very slow -

Image
i trying data out of database. using .entry slow, on 65% of time spent right there. have ideas how optimize query? want data read only. sorry adding code image, not let me post question when formatted using code sample button. your query definitively far being optimized. try instead: seismic2dsurvey.endsandbends = winpicsdbcontext.locations .where(t => t.surveyid = seismic2dsurvey.id && (t.isbend || (t.isend.hasvalue && t.isend.value))).orderby(t => t.tracenumber).tolist(); seismic2dsurvey.tracecount = locations.count(); seismic2dsurvey.surveylocations = null;

java - Static util class with Spring, unsure if I should make it a SpringBean, design concerns -

quick high level concept of design.. cli tool create aws ebs snapshots cli tool calls java class com.util.snapshotutil com.util.snapshot calls aws interfacing class com.aws.awsadapter example usage command line.. cli-tool create-snapshot.. calls java class calling below method snapshotutil.createsnapshot() // statically call awsadapter.createsnapshot(); currently static , outside of spring. now wondering if awsadapter should not static, , loaded spring, mean snapshotutil need create adapter through applicationcontext, believe, supplying xml adapter bean info. originally thought since simple util deal ebs snapshots, ignore spring, awsadapter potentially used other means, however, not sure if being static pro or con. the adapter designed deal ebs snapshot, either creating / deleting / viewing snapshots using amazonec2client instance. if spring managed class wanted use adapter, question if matters if loads adapter through spring or statically call it. edit in response...

Python use 2 lists in 1 loop -

i have below code has list r3000 , list of links save html. is possible save files different names using separate list? for example, r3000 include link (' http://research.investors.com/quotes/nyse-agilent-technologies-inc-a.htm?fromsearch=1 ') have list called r3000sym ['a','','',...] . file saved a.html . import time import urllib2 urllib2 import urlopen r3000 = ['http://research.investors.com/quotes/nyse-agilent-technologies-inc-a.htm?fromsearch=1', 'http://research.investors.com/quotes/nyse-alcoa-inc-aa.htm?fromsearch=1', 'http://research.investors.com/quotes/nasdaq-american-airlines-group-aal.htm?fromsearch=1', 'http://research.investors.com/quotes/amex-altisource-asset-mgmt-aamc.htm?fromsearch=1', 'http://research.investors.com/quotes/nyse-aarons-inc-aan.htm?fromsearch=1', 'http://research.investors.com/quotes/nasdaq-applied-optoelectronics-aaoi.htm...