Posts

Showing posts from August, 2012

Google map app created by android studio loads no map -

need , tired of following tutorials still no results. using android studio , trying make map app. tried using map template in studio entering key bt no matter , same results, blank screen google log. google maps console shows 0 request key accces maps. you must add api key, need register application in google developers console https://developers.google.com/maps/documentation/android/start

Redirect to previous page after registration in Django -

for login , logout, use django's built-in view in django.contrib.auth.views. easy redirect user previous page because can pass 'next' parameter login/logout view. work quit fine. when want fulfill similar functionality registration, there problems. seems django doesn't have built-in registration view. i'm using createview 'model=user'. codes following: #views.py class registration(createview): template_name='accounts/registration.html' model=user #overwrite form_valid() log new user in after successful registartion def form_valid(self, form): validation=super(registration, self).form_valid(form) username=form.cleaned_data['username'] password=form.cleaned_data['password2'] user=authenticate(username=username, password=password) login(self.request, user) return validation now don't have similar 'next' parameter in built-in login/logout view. how c...

javascript - Filter list based on multiple classes u -

i'm trying .show() or .hide() li elements based on multiple classes selected out of array. here example of html i'm working with: <div class="category-list"> <ul class="light" id="category-menu"> <li id="client-x"><a class="work-item" onclick="togglecontent('client-x')">client x</a></li> <li id="client-y"><a class="work-item" onclick="togglecontent('client-y')">client y</a></li> </ul> </div> and function i'm calling: function togglecontent(id) { jquery(document).ready(function($) { var ez = document.getelementsbyclassname(id); var cats = []; var items = window.localstorage.getitem('items'); if (items === null || items.length === 0) { cats.push(id); $(".port-project").hide(); localstorage.setitem("items", json.st...

php - How to Deny access to .class file from URL but allow from CI Application folder? -

this htaccess file how deny access .class file url allow ci application folder? rewriteengine on rewritebase /ci/ rewritecond %{request_uri} ^system/.* rewriterule ^(.*)$ /index.php?/$1 [l] rewritecond %{request_uri} ^application.* rewriterule ^(.*)$ /index.php?/$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?/$1 [l]

javascript - How do I access an objects key in bracket notation? -

i can't seem figure out how access spearguns object using bracket notation. i'm trying access "heft" key. console log say's "undefined". great, thanks. var rockspearguns = { sharpshooter: {barbs: 2, weight: 10, heft: "overhand"}, pokepistol: {barbs: 4, weight: 8, heft: "shoulder"}, javelinjet: {barbs: 4, weight: 12, heft: "waist"}, firefork: {barbs: 6, weight: 8, heft: "overhand"}, "the impaler": {barbs: 1, weight: 30, heft: "chest"} }; function listguns(guns) { (var speargun in guns) { // modify log message here console.log("behold! " + speargun + ", " + this["heft"] + " heft!"); } } listguns(rockspearguns); you need reference gun property name this: var rockspearguns = { sharpshooter: {barbs: 2, weight: 10, heft: "overhand"}, pokepistol: {barbs: 4, weight: 8, heft: ...

php - file_exists, @get_headers, cURL and detecting a favicon -

after reading in various places, including http://php.net/manual/en/function.file-exists.php , have following working code detects whether given host eg. http://example.com has favicon located @ /favicon.ico $file = 'http://www.easyjet.com/favicon.ico'; $file_headers = @get_headers($file); if($file_headers[0] == 'http/1.0 200 ok') { //place favicon image on page echo "<img src ='" . $file . "'>"; } else { //place default image echo "<img src ='" . "globe.jpg" . "'>"; } while know there better, more thorough ways seek favicon file on stackoverflow, more concerned use of @get_headers . of have read suggests curl useful, or should set user agent. am going run difficulty code in cases have not foreseen? personaly think get_headers best way in case. first of all, performs head request, less load both , remote host(as remote host gives headers , server doe...

vb.net - Retrieve starting positions of the titles in the string -

Image
i have line of 7 different titles can consist of 1 or 2 words @ least 3 or 4 spaces between title. " company name contact name address city state zip phone" i need retrieve position in line each title begins. use indexof: pos1 = line.indexof("company", system.stringcomparison.invariantcultureignorecase) this method works fine not efficient retrieving positions since line comes text documents , there great variability, example might have this: " c0mpany name c0ntact name address ncity st)te zip phone" so wording not exact. know there 7 columns. best way retrieve 7 beginning positions of columns programmatically? this works quite well dim s string dim v object dim tok object s = " c0mpany name c0ntact name address ncity st)te zip phone" v = split(s, " ") each tok in v if len(trim(t...

python - Is there a way to change the filemode for a logger object that is not configured using basicConfig? -

if create logger object using logger = logging.getlogger("name") unable change filemode append('a') write ('w'). can if use root logger basicconfig, lot of system debug messages being logged when want own messages beginning @ debug level. i hoping either (1) change filemode own logger object 'w' or (2) add filter root logger. possible filter out these debug messages root logger? def create_log(): # create logger "sample app" # create logger "sample app" logger = logging.getlogger('automated_testing') logger.setlevel(logging.debug) # create file handler logs debug messages fh = logging.filehandler('results.log') fh.setlevel(logging.debug) # create console handler higher log level ch = logging.streamhandler(stream=sys.stdout) ch.setlevel(logging.debug) # create formatter , add handlers formatter = logging.formatter('[%(asctime)s] %(levelname)8s --- %(mes...

excel - Need all files created in a folder at 644 permission automatically -

in site, generating reports (custom code) in excel format. happens creates excel file @ location , user supposed download there through link. the problem file being created permission of 600 means user unable download it. there way can have 644 (or higher) permission? i read can place htaccess file in folder excel file being created. htaccess file ensure file created in folder have read access. don't know write in htaccess file. many thanks. you need use acls's set default permissions. system has have feature installed. can use man acl more info. say have reports directory. set default permissions. setfacl -d -m g::rwx /reports setfacl -d -m o::rx /reports this set permissions on group , other. can verify getfacl /reports you can read more on answer. https://unix.stackexchange.com/questions/1314/how-to-set-default-file-permissions-for-all-folders-files-in-a-directory and here http://www.linuxquestions.org/questions/linux-desktop-74/applying-d...

linux - Bash script not producing desired result -

i running cron-ed bash script extract cache hits , bytes served per ip address. script (proxyusage.bash) has 2 parts: (uniqueip.awk) find unique ips , create bash script add hits , bytes run hits , bytes per ip proxyusage.bash #!/usr/bin/env bash sudo gawk -f /home/maxg/scripts/uniqueip.awk /var/log/squid3/access.log.1 > /home/maxg/scripts/pxyusage.bash source /home/maxg/scripts/pxyusage.bash uniqueip.awk { arrips[$3]++; } end { (n in arrips) { m++; # count arrips elements #print "array elements: " m; arraddr[i++] = n; # fill arraddr ips #print " " n; } asort(arraddr); # sort array values (i = 1; <= m; i++) { # write 1 command line per ip address #printf("#!/usr/bin/env bash\n"); printf("sudo gawk -f /home/maxg/scripts/proxyusage.awk -v v_var=%s /var/log/squid3/access.log.1 >> /home/maxg/scripts/pxyusage.txt\...

concatenation - Python False Concatenate Error? -

i can't seem find mistake. i'm trying write simple program encrypts messages using caesar shift method. however, i'm getting funky error. program follows: alphabet = {"a":0,"b":1,"c":2,"d":3,"e":4,"f":5,"g":6,"h":7,"i":8,"j":9,"k":10,"l":11,"m":12,"n":13,"o":14,"p":15,"q":16,"r":17,"s":18,"t":19,"u":20,"v":21,"w":22,"x":23,"y":24,"z":25} alpha2 = dict (zip(alphabet.values(),alphabet.keys())) def key(n): code = alphabet in code: code[i] = (code[i] + n) % 26 in code: code[i] = alpha2[code[i]] return code def encode(x,n): my_key = key(n) message = [] in x: message.append(my_key[i]) print key(13) print encode("message",13) i find absurd, beca...

Open Graph Object Debugger does not match Facebook Share from site -

i implementing facebook share button in angularjs app , after doing necessary stuff meta tags updated , read facebook's crawler, seeing mismatch between facebook's debugger tool , share dialog shows. if run debugger on link, successful scrape pulls of meta tag content , shows share dialog should like. if click on preview see actual share dialog, different result if not reading meta tag content. same goes share button on actual website. any thoughts? this might issue protocol inconsistancy. check you're not using http:// on debugger, vs https:// on actual site, , vice versa. ensure of og tags have correct protocol set, , protocol not omitted.

javascript - Remove specific lines on button click -

if have following: <div id="test1"></div> <div id="test2"></div> <div id="test3"></div> <div id="test4"></div> <input type="submit" value="submit" /> how make (div test1 , test3) removed upon clicking on submit button? try this: var button = document.queryselector('input[type="submit"]'); button.onclick = function(event) { event.preventdefault(); var ids = ['test1','test3']; var count = ids.length; while(count--) { document.getelementbyid(ids[count]).remove(); } }; <div id="test1">test1</div> <div id="test2">test2</div> <div id="test3">test3</div> <div id="test4">test4</div> <input type="submit" value="submit" />

three.js - After setting preserveDrawingBuffer:true, canvas is only rendered after renderer resize -

i added preservedrawingbuffer:true webglrenderer creation able generate screenshots via todataurl(). however, canvas stays white until resize window (and hence renderer) manually, afterwards rendering works fine. i'm creating webglrenderer following options: renderer = new three.webglrenderer({ preservedrawingbuffer: true, antialias: true }); if antialias or preservedrawingbufffer left out, scene rendered immediately. a stripped down example using three.js v68 accessible via https://jsfiddle.net/ytdoo72k/8/ firefox v36 shows behaviour described above, chrome v41 seems work. https://jsfiddle.net/ytdoo72k/9/ uses r71 , shows strange white rectangles.

javascript - Using POST and GET to Exchange Data Through Endpoints -

i'm attempting build web app using spotify's web api however, find tutorial lacking. way works data requested using post , functionality , sent using json. seems easy enough, want information artist? call https://api.spotify.com/v1/artists/0oduwj0sbjdrqhygguxecf , nice json document information requested artist. the problem don't know how make call. jquery has , post methods both "data" parameters i'm not sure on syntax necessary, when comes exchanging authorization code access token. if visit spotify's authorization guide , scroll step 4 of authorization code flow can see need make post call https://accounts.spotify.com/api/token . call must have 3 request body parameters , 1 header parameter , upon succession json file appropriate data in response body. my question how make post , calls have body parameters , header parameters , how extract json data response body after successful call? as can see code examples & libraries , jsfi...

icon.rc and icon.ic error in qt :-1: error: error: icon.rc: No such file or directory -

i'm getting following errors when trying compile :-1: error: error: icon.rc: no such file or directory :-1: error: fatal error: no input files in icon.rc file: idi_icon1 icon discardable "icon.ico" the code compiles fine on other computers, when trying compile on computer error

matlab - Displaying Milliseconds of the current time -

i trying display milliseconds of current time on screen couldn't it. managed show seconds .. help?? my code: datestr(now, 'hh:mm:ss') from second-to-last row of format out table , need fff identifier: >> datestr(now, 'hh:mm:ss:fff') ans = 19:35:59:476

Haxe for enterprise application development -

is there available haxe suitable real-life enterprise application development? (i.e. professional high level ui component framework.) just note - know love our tools of choice, please try keep objective.. don't recommend haxe without thinking whether it's effective tool business requirements. on 1 hand, jason suggested in comment, there missing haxe-based native ui framework. on other hand, don't need haxe-based ui framework, using ui framework available target platform enough. unlike building library, better target independent, building "real-life enterprise application" requires targeting specific platform. since ui highly dependent on target platform, means should use target-specific ui framework. example, best ui solutions web app jquery, reactjs, angularjs etc., can used in haxe ( jqueryextern , react.hx , angular.haxe ). flash/java/c#, can use "native" libs -swf-lib path/to/lib.swc , -java-lib path/to/lib.jar , , -net-lib path/to/l...

How do I display the name of a deleted element in Ruby on Rails? -

i have simple rails application create objects (such posts). far can edit , delete them, 1 one, want have <%= notice %> echoing name of deleted object after confirming deletion. possible? if so, how? this extremely common task in rails, , idiomatic solution forward data deleted record subsequent request via the flash array. your controller's destroy action should this: def destroy @post = post.find(params[:id]) @post.destroy redirect_to posts_path, notice: "#{@post.name} deleted" end in index action, you'll able access flash[:notice] string generated in previous action.

c - openMP and how to check cache behavior parallelism -

i using openmp parallelize loops in code in order optimize it i hear openmp shows or bad cache behavior how see these cache interactions arrange cache behavior openmp omp pragma loop program? openmp cannot used information cache usage of program. depending on platform there tools give insights cache behavior. on linux systems can use perf . perf stat -e cache-references,cache-misses <your-exe> outputs statistics cache-misses. there lot more events can used (see here further details). common events collected if run: perf stat <your-exe> another tool can used windows intel® performance counter monitor . although works intel cpus can collect additional information occupied memory bandwidth (on supported models). however, tools can measure cache usage of program, did not improve it. have manually optimize code , recheck if cache misses have been reduced.

Sorting Perl with Class::DBI -

you have following table called pets: name age pet ------------------------ carol 25 null stean 23 cat mel 24 dog rich 24 rabbit in mysql database on server mydbserver user of 'user' password of 'password'. do following: 1) create class::dbi connection database above credentials ( dbi.pm ). 2) create class table pets ( pet.pm ) 3) create program prints names of people in pets table , kind (if ) of pet he/she has sorted name age. here code wrote..... #!/usr/bin/perl package pet::dbi; use dbi; use strict; use base 'class::dbi'; pet::dbi->set_db('main','dbi:mysql:dname', 'user', 'password') or die $dbi::errstr "\n"; 1; package pet::pets; use base 'pet::dbi'; use strict; use warning; pet::pets->table('pets'); pet::pets->columns(all => qw/name age pet/); 1; use pet::pets; @pets = pet::pets->retrieve_all; (sort {$a->na...

c# - Entity Framework foreign key InvalidOperationException -

is there way somehow output more details/information when invalidoperationexception 1 happens during savechanges() call? the operation failed: relationship not changed because 1 or more of foreign-key properties non-nullable. when change made relationship, related foreign-key property set null value. if foreign-key not support null values, new relationship must defined, foreign-key property must assigned non-null value, or unrelated object must deleted. i not removing db questions similar 1 didn't me. message quite self-explanatory, true, can't see mistake in code , helpful if exception gave more information property , foreign key in question. edit - have checked innerexception , it's empty. for example, if have next structure: public class client { public int clientid { get; set; } public string name { get; set; } public int clienttypeid { get; set; } public clienttype clienttype { get; set; } } public cla...

mysql - Rails App Deploying to Heroku Application Error -

Image
i'm migrating app heroku , using mysql cleardb addon. however, upon deploying , attempting view app, leads page: and log (my apologies length): 2015-03-17t02:25:14.688899+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:199:in `app' 2015-03-17t02:25:14.688917+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/server.rb:75:in `start' 2015-03-17t02:25:14.688914+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands/server.rb:48:in `app' 2015-03-17t02:25:14.688915+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app' 2015-03-17t02:25:14.688918+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands.rb:76:in `block in <top (required)>' 2015-03-17t02:25:14.688921+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/railties-4.0.1/lib/rails/commands.rb:71...

regex - How do I redirect all requests for .html files to directories with respective names? -

first question grace appreciated! have site use have tens of thousands of .html files index.html files inside directories. example, file1.html has become /file1/ ( /file1/index.html ). don't want spend inodes on individual files this, hoping it'd possible in htaccess file. suppose it'd have test existence of directory isn't possible right? add .htaccess in web root / directory rewriteengine on rewritecond %{document_root}/$1 -d # dir exists? rewriterule ^(.*)\.html$ /$1/ [r=301,l]

java - How to separate each digit in a number? -

i working on homework assignments making program allows user enter in low , high value range , program suppose find numbers sum of cubed digits (ie 153 = 1^3 + 5^3 + 3^3) , loop has used. i'm stuck on figuring out how go this, need separate each digit of number take each digit cube it, add them check see if equals value if not repeat that's far have gotten planning wise appreciated. /* * problem #17 on page 367 * program description - finding numbers equal sum of cubed numbers * author: jonathan wilson * date: 2/24/2015 * filename: cube.java */ //import statements import java.util.*; //for scanner class // class beginning class cube { public static void main(string[] args ) { //declare variables area int low; int high; int value; scanner scan = new scanner (system.in); //program beginning messages user here system.out.println("welcome special number program!"); syst...

PHPExcel not working php 5.2 AppServ -

i using php 5.2.6 in appserv on windows machine , phpexcel not seem work , produces no errors. have error_reporting set e_all. on linux machine using php 5.6 , using vagrant/homestead same code works fine. here code: http://pastebin.com/6djc8gap i added echos see dies, , seems die on line 9. had thought maybe issue php 5.2 , :: referencing, tried using call_user_func, works on php 5.6 not work on php 5.2 http://php.net/manual/en/function.call-user-func.php <?php namespace foobar; class foo { static public function test() { print "hello world!\n"; } } call_user_func(__namespace__ .'\foo::test'); // of php 5.3.0 call_user_func(array(__namespace__ .'\foo', 'test')); // of php 5.3.0 ?> per page: quote: in php v5.2, /can/ use call_user_func(array($this, 'parent::some_function')). if don't have custom __autoload() function, go. if have custom __autoload(), need make `parent' aware. like...

android - Call non parent activity's method from fragment -

i have 1 login activity in login using google. after login moving main screen. has navigation drawer. list of fragments, want sign out google using 1 of fragment. how can achieve this. below code: loginactivity.java @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_login); // session manager session = new sessionmanager(getapplicationcontext()); initui(); setuplisteners(); } protected void onstart() { super.onstart(); } protected void onstop() { super.onstop(); if (myapplication.mgoogleapiclient.isconnected()) { myapplication.mgoogleapiclient.disconnect(); } } private void initui(){ llgoogle = (linearlayout)findviewbyid(r.id.activity_login_llsignin_google); } private void setuplisteners(){ llgoogle.setonclicklistener(new onclicklistener() { @ov...

jquery - d3 bar chart not rendering inside a partial view -

i trying render bar chart inside partial view in asp.net mvc application. when put code in html , put in project(not in view or folder, in root folder) , run html in browser, works fine. put html code in partial view , try render it, not render. following code <script type="text/javascript" src="~/scripts/jquery-1.11.2.js"></script> <style> .bar { fill: steelblue; } .bar:hover { fill: brown; } .axis { font: 10px sans-serif; } .axis path, .axis line { fill: none; stroke: #000; shape-rendering: crispedges; } .x.axis path { display: none; } </style> <body> <script src="~/scripts/d3.js"></script> <script> var margin = { top: 20, right: 20, bottom: 30, left: 40 }, width = 960 - margin.left - margin.right, height = 500 - margin.to...

nsdate - Converting ISO8601 Date Format to local time (iOS) -

so there section on web application users can enter events , web service sends events mobile app in following format: "yyyy-mm-dd't'hh:mm:sszzzzz" i'm having issues trying convert string date can time event (formatted in correct timezone well), example here's 1 comes on "2015-03-20t20:00:00-07:00", when pull time should 1pm pacific time. instead either 8pm or 3am (depending on whether add utc abbreviation date formatter). here's have far, know i'm missing here & maybe there's date formatter needs used far can't figure out i'm going wrong. nsstring *datepattern = @"yyyy-mm-dd't'hh:mm:sszzzzz"; nsdateformatter *dateformatter = [nsdateformatter new]; [dateformatter setdateformat:datepattern]; nsstring *sstring = [valuedict valueforkey:@"start_date"]; nsdate *startdate = [dateformatter datefromstring:sstring]; nsdateformatter *timeformatter = [nsdateformatter new]; [timeformatter setdateform...

module - Reorder cms links in the left column -

Image
i have prestashop site includes few cms pages. have added these pages left column in cms block bo->modules->cms block ->configure->left column i want rearrange cms page links in part. know how can it. i checked prestashop forums , answers related footer links not leftcolumns links following cms block link go office -> cms ->positions . click on positions , down arrow key , re arrange cms pages. solution works me.

node.js vs java - compute intensive computation -

i'm evaluating backend architecture api, taking deeper looks node.js , j2ee application server corresponding j2ee war files. api have compute quite cpu-intensive tasks - more specific training of neural networks. have experience such setup concerning performance and/or packages 1 should use machine learning? there other api technologies should consider - example java micro services? thanks lot in advance, philipp i'd recommend @ least 2 micro services. 1 accepting api requests. other(s) computation. can choose languages these two. for example: a node.js api service - receives http restful requests. service calls second service using transactional rpc protocol dnode . a stateless c++/java/go service - receives computation tasks via dnode rpc, performs calculations, , returns result back. as result, you'll have offloaded frontend service. not lag on high load. second service written using cpu optimized library/language. moreover, can scale second servi...

java - Stopping wicket hyperlink refreshing page -

had redo snippet.i hope it's visible now. new code when select block, change backgroundcolor of td. nee not change color of 1 clicked. here go again. .active{background-color:red;} <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/tr/rec-html40"> <head> <meta http-equiv="content-type" content="text/html; charset=us-ascii"> <meta name=generator content="microsoft word 12 (filtered medium)"> <link rel="stylesheet" href="fnbstyle.css" type="text/css" media="screen" title="stylesheet" /> <!--[if !mso]><style>v\:* {behavior:url(#default#vml);} o\:* {behavior:url(#default#vml);} w\:* {behavior:url(#default#vml);...