Posts

Showing posts from August, 2013

uitableview - TableView extension swift 2 image hidden -

i using swift 2 xcode 7.2 in extension. rendering uitableview cells have image , label in problem image hidden ! idn't know why! can me please override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) uitableviewcell cell.textlabel!.textcolor = uicolor.whitecolor() let query = pfquery(classname:"recipe") query.orderbydescending("createdat") query.findobjectsinbackgroundwithblock { (objects: [pfobject]?, error: nserror?) -> void in if error == nil { print("success retrieved \(objects!.count) scores.") if let objects = objects { object in objects { let a:string = object.objectforkey("title") as! string self.contentstring.append(a) }

version control - Cleaning up after a conflicted git merge? -

i had small conflict in .h header file in project i'm working on. project tracked in git. fortunately, conflict simple solve. used git mergetool and chose default ( opendiff ) seemed filemerge on mac. made appropriate changes, saved file, , closed. git asked me if merge successful, said yes: was merge successful? [y/n] y but now, have: > git st # on branch develop # changes committed: # modified: myheader.h # # untracked files: # (use "git add <file>..." include in committed) # # myheader.h.backup.52920.h # myheader.h.base.52920.h # myheader.h.local.52920.h # myheader.h.remote.52920.h # myheader.h.orig which of junk conflict files created filemerge, , git? and more importantly: how remove them? you can delete them other file. example: rm myheader.h.orig alternatively, if there no other untracked files, after commit with git commit -a you may clean repository with git clean -n git clean -f git clean -n

arrays - println turning up as empty string in go -

so wrote small go program, gives instructions turing machine, , prints selected cells it: package main import "fmt" import s "strings" func main() { fmt.println(processturing("> > > + + + . .")); } func processturing(arguments string) string{ result := "" dial := 0 cells := make([]int, 30000) commands := splitstr(arguments, " ") := 0;i<len(commands);i++ { switch commands[i] { case ">": dial += 1 case "<": dial -= 1 case "+": cells[dial] += 1 case "-": cells[dial] -= 1 case ".": result += string(cells[dial]) + " " } } return result } //splits strings delimeter func splitstr(input, delim string) []string{ return s.split(input, delim) } problem is, when run, console doesn't display anything. disp

mongodb - Pymongo importing succeeded but not showing in the collection -

i tried importing json file succeeded mongoimport --db dbwhy --collection dbcol --jsonarray consumer_complaint.json 2016-01-15t19:00:42.277-0600 connected to: localhost 2016-01-15t19:00:42.320-0600 imported 34 documents but when tried viewing it, not there from pymongo import mongoclient client = mongoclient('localhost',27017) db = client['dbwhy'] coll = db['dbcol'] curs = db.coll.find() in curs: print(i) it not show anything the problem here: db.coll.find() this find documents inside coll collection , your collection named dbcol . instead, use coll variable you've defined: from pymongo import mongoclient client = mongoclient('localhost',27017) db = client['dbwhy'] coll = db['dbcol'] curs = coll.find() # fix here in curs: print(i)

Notepad++ Regex Replace Capture Groups With Numbers -

so have numbers i'm trying replace in notepad++ , have tweak both positive values , negative ones, search looks this: v (.{0,1})13.500000 and replace: v $1 10.500000 except don't want space there between capture group reference , other digits, if leave space out, places nothing (no capture group #110). how "escape" capture group separate character-literals without inserting unwanted character? i 2 replacements, figured must possible, although can't figure out how search it. sample source text: v 13.000000 19.0000000 8.000000 v 13.000000 19.0000000 9.000000 v -13.000000 19.0000000 9.000000 v -13.000000 19.0000000 8.000000 desired result: v 10.000000 19.0000000 8.000000 v 10.000000 19.0000000 9.000000 v -10.000000 19.0000000 9.000000 v -10.000000 19.0000000 8.000000 try replacement: v ${1}10.500000

Python CSV reader return Row as list -

im trying parse csv using python , able index items in row can accessed using row[0] , row[1] , on. so far code: def get_bitstats(): url = 'http://bitcoincharts.com/t/trades.csv?symbol=mtgoxusd' data = urllib.urlopen(url).read() dictreader = csv.dictreader(data) obj = bitdata() row in dictreader: obj.datetime = datetime.datetime.fromtimestamp(int(row['0'])/1000000) q = db.query(bitdata).filter('datetime', obj.datetime) if q != none: raise valueerror(obj.datetime + 'is in database') else: obj.price = row['1'] obj.amount = row['2'] obj.put() this returns keyerror: '0' , have no idea how set up. did input interactive shell , when running for row in dictreader: print row i output: {'1': '3'} {'1': '6'} {'1': '2'} {'1': '6'} {'1': '9'}

swift - MapView over UITableViewCell -

i'm trying have mapview cover entire uitableviewcell , disable user activity on mapview, still have cell clickable. however, mapview (even though sent subview back) intercepting user clicks , causing didselectrow method never called. you can try way below: you add view above mapview , set background color clearcolor . think resolve problem.

SSL Not Working On NodeBB Forum Apache2 -

i have signed ssl certificate on site, , nodebb isn't working it. i'm using apache2 , certificate work. have use mod_proxy make forum run @ subdirectory instead of port :4567 work? suggestions welcome. thanks. here config { "url": " http://website.com:4567 ", "secret": "secret", "database": "mongo", "mongo": { "host": "127.0.0.1", "port": "27017", "username": "xxxxx", "password": "xxxxx", "database": "xxxxx" } } get ssl certificate, got mine here https://letsencrypt.org/ then put nodebb on port 443 , use apache mod_proxy remove port. ssl works.

draw 43 xy scatter drawing using vba in excel -

i need draw 43 x/y scatter drawing using vba in excel developed code 1 drawing , not sure how can apply draw remaining 42 drawing mean don't want change range of data manually need put in loop or this. code sub draw() activesheet.shapes.addchart2(240, xlxyscattersmoothnomarkers).select activechart.seriescollection.newseries activechart.fullseriescollection(1).name = "=""hbes""" activechart.fullseriescollection(1).xvalues = "=en!$g$253:$g$278" activechart.fullseriescollection(1).values = "=en!$h$253:$h$278" activechart.seriescollection.newseries activechart.fullseriescollection(2).name = "=""nhbes""" activechart.fullseriescollection(2).xvalues = "=en!$g$253:$g$278" activechart.fullseriescollection(2).values = "='en1'!$g$253:$g$278" activechart.seriescollection.newseries activechart.fullseriescollection(3).name = "="&

Hex editing Java bytecode throwing ClassFormatError -

while researching java, bytecode editing in particular, stumbled across this tutorial , guides through steps of editing compiled java .class files hex editor. intrigued, gave go. i made sure typed in correctly, checked , double-checked, replaced right bytes in hex editor, etc. everything's ok. the first thing noticed hex dump different his, however, expected this, different java versions yield different results. after inputting correct bytes (replacing hacking java bytecode! l33t hax0r bro , , 3 occurrences of 00 16 00 0e ), saved file, , ran it. however, instead of getting output of l33t hax0r bro , writer of tutorial did, got rather ugly error: error: jni error has occurred, please check installation , try again exception in thread "main" java.lang.classformaterror: unknown constant tag 116 in class file user @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:760) @ java.security.secureclas

html - Making Bootstrap's navbar appearing in different position on desktop/mobile -

i want make bootstrap's navbar appear @ top on desktop view , @ bottom on mobile view. possible? how can it? there actual html top navbar: <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"><span class="fa fa-cloud-upload fa-fw"></span>&nbsp; gitup</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

asp.net mvc - mvc forms authentication landing page -

i have mvc website uses forms authentication. attempting add default landing page site ( landing.html ) each user hitting http://mywebsite.com example redirected to. i tried setting default document in web.config, redirected account/login page. i not want change login url because make user's session has expired go landing page, not want. any appreciated. thanks update "default" route. mvc projects have following route defined in routeconfig class , called in global.asax during application startup. public class routeconfig { public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); } } just replace "home" , &q

python - Importing Views -

my app layout my_app __init__.py my_app __init__.py startup create_app.py create_users.py common_settings.py core models.py views.py inner __init__.py from flask import flask flask_script import manager flask_sqlalchemy import sqlalchemy app = flask(__name__) # wsgi compliant web application object db = sqlalchemy(app) # setup flask-sqlalchemy manager = manager(app) # setup flask-script my_app.startup.create_app import create_app create_app() create_app.py from native_linguist_server import app, db @app.before_first_request def initialize_app_on_first_request(): """ create users , roles tables on first http request """ .create_users import create_users create_users() def create_app(extra_config_settings={}): app.config.from_envvar('env_settings_file') # load blueprints manage

Segmentation fault: 11 ? C++ -

can tell why generate segmentation error? problem seems occur when operator[] called , when don't call it, goes fine. operator[] supposed return reference element index i.. great.. //dynamic_array.cpp file #include <iostream> #include "dynamic_array.h" using namespace std; dynamic_array::dynamic_array() { int *array; array=new int[4]; array[0]=3; size = 4; allocated_size = 5; } dynamic_array::~dynamic_array() { delete [] array; } int dynamic_array::get_size(void) const { return size; } int dynamic_array::get_allocated_size(void) const { return allocated_size; } int& dynamic_array::operator[](unsigned int i) { return array[i]; } //test.cpp file #include <iostream> #include <stdlib.h> #include "dynamic_array.h" using namespace std; int main() { dynamic_array a; cout << a[0]; } //dynamic_array.h file using namespace std; class dyna

Twilio with Laravel - Error: XML declaration allowed only at the start of the document -

i'm getting following error when trying access 1 of routes on twilio using laravel. error on line 2 @ column 6: xml declaration allowed @ start of document the cause seems there empty 1st line in xml document rendered library because i've tested on different installation , didn't have same error. however, not know how go removing it. i've looked elsewhere online , the've suggested removing spaces preceding php tag, i've tried, hasn't worked. how remove first line in xml file generated? route::get('/outbound', function() { $saymessage = "hello"; $twiml = new services_twilio_twiml(); $twiml->say($saymessage, array( 'voice' => 'alice', 'language' => 'en-gb' )); $twiml->gather(array( 'action' => '/goodbye', 'method' => 'get', )); $response = response::make($twiml, 200);

api - iOS - Re-Attempt Failed NSURLRequests In NSURLSession -

in app, 2-4 api calls server can happening @ same time (asynchronously) within api class's nsurlsession . in order make api requests server, must supply authentication token in httpheaderfield of each nsurlrequest . token valid 1 day, , if becomes invalid after 1 day, need refresh token. i in following code in api class: /*! * @brief sends request nshttpurlresponse. method private. * @param request request send. * @param success block called if request successful. * @param error block called if request fails. */ -(void)sendtask:(nsurlrequest*)request successcallback:(void (^)(nsdictionary*))success errorcallback:(void (^)(nsstring*))errorcallback { nsurlsessiondatatask *task = [self.session datataskwithrequest:request completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) { [self parseresponse:response data:data fromrequest:request successcallback:success errorcallback:^(nsstring *error) { //if auth token expired

signal processing - Optimal value of sampling frequency for guitar notes detection -

i running fft algorithm detect music note played on guitar. the frequencies interested in range 65.41hz (c2) 1864.7hz (a#6). if set sampling frequency of input 16khz, output of fft yield n points 0hz 16khz linearly. input interested in first n/8 points approximately. other n*7/8 points of no use me. decreasing resolution. from nyquist's theory ( https://en.wikipedia.org/wiki/nyquist_frequency ), sampling frequency needed twice maximum frequency 1 desires. in case, 4khz. is 4khz ideal sampling frequency guitar tuning app? intuitively, 1 feel better sampling frequency give more accurate results. however, in case, seems having lesser sampling frequency better improving resolution. regards. you confusing pitch of guitar note spectral frequency. guitar generates lots of overtones , harmonics @ higher frequency pitch of played note. higher harmonics , overtones, more possibly weak fundamental frequency in cases, human ear hears , interprets lower perceived pitch

javascript - Dynamically generate table in form using Ajax with symfony -

i working symfony project . want generate table in form when select option in form. this task. there name options in form ( eg. john , mia , lia .. etc) when select "john" . want display detail "john" using table. table should locate in form . there example in link http://www.w3schools.com/php/php_ajax_database.asp but want using symfony. what best way this. please mention example. using javascript , jquery or ajax symfony the symfony keyword misleading here because generate table client javascript code. in javascript initiate ajax call post request php/symfony application. 1 returns json array of objects, , ajax complete/done method create table using jquery example. here example: <html> <head> <script src="https://code.jquery.com/jquery-2.2.0.js"></script> <script> $(document).ready (function () { }) ; function go () { $.post ('/index.php/api/mycall',

python - How can I handle huge matrices? -

i performing topic detection supervised learning. however, matrices huge in size ( 202180 x 15000 ) , unable fit them models want. of matrix consists of zeros. logistic regression works. there way in can continue working same matrix enable them work models want? can create matrices in different way? here code: import numpy np import subprocess sklearn.linear_model import sgdclassifier sklearn.linear_model import logisticregression sklearn import metrics def run(command): output = subprocess.check_output(command, shell=true) return output load vocabulary f = open('/users/win/documents/wholedata/rightvo.txt','r') vocab_temp = f.read().split() f.close() col = len(vocab_temp) print("training column size:") print(col) create train matrix row = run('cat '+'/users/win/documents/wholedata/x_tr.txt'+" | wc -l").split()[0] print("training row size:") print(row) matrix_tmp = np.zeros((int(

ssis - Fetch image from non direct HTML link -

we have couple ssis jobs nicely fetch images , various expected graphics on websites. can't figure out how fetch image following site (sample). http://tess2.uspto.gov/imageagent/imageagentproxy?getimage=77666637 any thoughts on ssis techniques? i'm hoping don't have screenscrape or that... you can use script task fetch image. following article gives sample code can adjust save image file instead of text file. here link : http://www.sqlis.com/sqlis/post/downloading-a-file-over-http-the-ssis-way.aspx

ruby - The best way to browse rubygems documents on console -

it easy find rubygems documents on web, want read them on console. ri not enough me, because have know name of class or method before reading ri. @ time, however, don't know other package name! so need fastest way find synopsys of rubygems, perldoc. is there way? if using bundler can do: $ bundle open gemname which open gem in $editor allowing check out readme.rdoc (or whatever author using root documentation) not mention of source code. helpful when debugging too!

Stuck at SSH while post-commit on SVN -

i'm trying setup svn export files existing server. because company server live , huge has been operating several years, cannot wipe whole webserver , svn update server files big , content custom file. what want commit on server , scp latest committed file server b, file in web server direction. have attempt following below fail, better way recommend me? i'm not on doing configuration. here i'm attempt on post-commit: repository="file:///var/www/html/svn/testrepo/" revision_from=$2 target_directory="/home/svn/" expr $((revision_from--)) rm -r -f $target_directory line in `svn diff --summarize -r $revision_from:head $repository | grep "^[am]"` if [ $line != "a" ] && [ $line != "am" ] && [ $line != "m" ]; filename=`echo "$line" |sed "s|$repository||g"` # don't export if it's directory we've created if [ ! -d

levenshtein distance - How to calculate equal hash for similar strings? -

i create antiplagiat. use shingle method. example, have following shingles: i go cinema i go cinema1 i go th cinema is there method of calculating equal hash these lines? i know of existence of levenshtein distance. however, not know should take source word. maybe there better way consider levenshtein distance. the problem hashing that, logically, you'll run 2 strings differ single character hash different values. small proof: consider possible strings. assume of these hash @ least 2 different values. take 2 strings , b hash different values. can go b changing 1 character @ time. @ point hash change. @ point hash different single character change. some options can think of: hash multiple parts of string , check each of these hashes. won't work since single character omission cause significant difference in hash values. check range of hashes. hash 1 dimensional, string similarity not, won't work either. all in all, hashing not way go.

unix - Delete Special Word Using sed -

i use sed remove occurances of line if , if this <ab></ab> if line, not want delete it <ab>keyword</ab> my attempt that's not working: sed '/<ab></ab>/d' thanks insight. i'm not sure what's wrong should not have escape anything? i'm using shell script named temp execute this. command this: cat foobar.html | ./temp this temp shell script: #!/bin/sh sed -e '/td/!d' | sed '/<ab></ab>/d' it looks have couple of problems here. first / in close-tag. sed uses delimit different parts of command. fortunately, have escape \ . try: sed '/<ab><\/ab>/d' here's example on machine: $ cat test <ab></ab> <ab></ab> <ab>test</ab> $ sed '/<ab><\/ab>/d' test <ab>test</ab> $ the other problem i'm not sure purpose of sed -e '/td/!d' is. in it's default operating mode, d

java - Jython - how can I merge two LeafElements in a DefaultStyledDocument? -

i'm trying "normalise" defaultstyleddocument subclass, in sense have org.w3c.dom.node.normalize() : is, merge adjoining text "leaves". in case of defaultstyleddocument these leaves identified merging if 2 adjacent ones have same attributes (or none). below simple version (we don't check actual attributes: use-case either have plain text, or text 1 possible mark-up style). def normalise( self ): # recursive function: def normalise_structure( el, depth = 0 ): indent = ' ' * depth start = el.startoffset print( '%s# el %s |%s|' % ( indent, el, self.gettext( start, el.endoffset - start ))) prev_attr_set = none in range( el.elementcount ): subelement = el.getelement( ) normalise_structure( subelement, depth + 1 ) if subelement.leaf: curr_attr_set = subelement.attributes print( '%s # leaf, attribs %s' % ( indent, cur

Ansible lineinfile duplicates lines -

- vars: npm: npm_global: "{{ ansible_env.home }}/.npm-global" - name: update bashrc npm lineinfile: > dest={{ project.shell_rc_file }} regexp='export path={{ npm.npm_global }}/bin:$path' line='export path={{ npm.npm_global }}/bin:$path' state=present backup=yes create=yes i tried many times duplicates line in export path=... you need escape \$ in regexp parameter since $ in regex means end of line. regex never matched since there can't string path after end of line.

How could I remove sql server's table .mdf file's file_attribute_compressed attributes using C++ API function? -

how remove sql server's table .mdf file's file_attribute_compressed attributes using c++ api functions these table .mdf file not in compressed mode(blue color file). therefore, sql server read/write these tables correctly. found if file of sql server folder "data" become blue(which compressed), program running sql server file pop messagebox of "the file mdf compressed not reside in read-only database or filegroup. file must decompressed." i tried find solution on website , find 1 c++ api function call "setfileattributes", , tried way of adding or removing file_attribute_compressed not effective .mdf file not change color white blue or blue white. could please suggestion kind of effective c++ api function call can remove compress mode of these .mdf or .ldf file , sql server running without these above messagebox? thank help? running environment: sql server 2005 on windows xp code: cstring szfilepath = "e:\\db.mdf"; dword dwfil

ios - Unexpected found nil will unwrapping an Optional value occurs when setting a property of UITableView -

Image
override func viewdidload() { super.viewdidload() tableview.separatorinset = uiedgeinsetszero tableview.tablefooterview = uiview() appdelegate = uiapplication.sharedapplication().delegate as! appdelegate initializefetchedresultscontroller() } the line tableview.separatorinset = uiedgeinsetszero executes fine, next line breaks apparently trying unwrap optional: tableview.tablefooterview = uiview() i ran problem. upon setting tableview footer programmatically seems reloaddata called, table begins looking data, , calls numberofsectionsintableview before viewdidload completes. if setting table data in viewdidload after assigning tableview footer data nil , crashes app.

geometry - C++ Checking For Two Spheres Intersecting/Collidiing -

im getting c++ , have been researching how have 2 spheres interact 1 another. of have found complex or actual math formulas. there more simplistic way of creating function recognize when side of sphere makes contact another? im not asking work, appreciate kind of clean visual, pseudo code or or code snippet, me understand more. or maybe links havent found? thanks! check if distance between spheres' centers less sum of radii. class sphere { public: double centerx, centery, centerz, radius; // .... }; double distancebetween( const sphere& a, const sphere& b ) { return sqrt( pow( a.centerx - b.centerx, 2 ) + pow( a.centery - b.centery, 2 ) + pow( a.centerz - b.centerz, 2 ) ); } bool arecolliding( const sphere& a, const sphere& b ) { return distancebetween( a, b ) < ( a.radius + b.radius ); }

android - How to Know if the incoming call is rejected or get missed -

i want detect if call missed or rejected using call state. public void oncallstatechanged(int state, string incomingnumber) { super.oncallstatechanged(state, incomingnumber); switch (state) { case telephonymanager.call_state_idle: //when idle i.e no call if(flag==2){ toast.maketext(context,"missed call", toast.length_long).show(); flag=0; }else{ toast.maketext(context, "phone state idle", toast.length_long).show(); } break; case telephonymanager.call_state_offhook: // flag=0; // when off hook i.e in call // make intent , start service here toast.maketext(context, "phone state off hook", toast.length_long).show(); flag=1; break; case telephonymanager.call_state_ringing: //when ringing toast.maketext(context, "phon

How to write a custom event handler adder method in C# -

i have defined foo class , used in bar class, event handler: public class bar { public bar() { foo foo = new foo(); foo.my_custom_event += my_event_handler; } public void my_event_handler() { // work here } } and works perfectly. need define method in foo class fired when add event handler my_custom_event , like: public class foo { ... public/private void my_event_handler_adder(target_function) { functions_that_are_fired_on_my_custom_event.append(target_function); } } is there way define such adder method? class foo { private eventhandler explicitevent; public event eventhandler explicitevent { add { explicitevent += value; fireneededmethodhere(); } remove { explicitevent -= value; } } }

Clibboard exchange not working in VMware player 5 -

i have kubuntu 12.10 64bit host , centos 6 32bit guest system on vmware player 5 on dell latitude e6510. despite installation of vmware tools, clipboard exchange not working. i use similar guest system within virtualbox , there cliboard exchange works fine. has experienced same configuration similar mine? , possible, guest system causes problem instead of player? i've found thaht suspending , re-playing vm re-enable clipboard exchange. clipboard exchange work both between vms , host machine between vms themselves. (vmware player 5.0, windows 7)

"downcast from CLplacemark? to Clplacemark only unwraps optional"(swift2) -

how fix error : "downcast clplacemark? clplacemark unwraps optional" so use code : if let p = clplacemark(placemark: placemarks.first as? clplacemark){} and change placemarks[0] array not work and code : clgeocoder().reversegeocodelocation(userlocation) { (placemarks, error) -> void in if error == nil { if let p = clplacemark(placemark: placemarks[0] as? clplacemark){ print(p) self.adsresslabel.text = "\(p.administrativearea)\(p.postalcode)\(p.country)" } }else { print (error) } } at code : if let p = clplacemark(placemark: placemarks[0] as? clplacemark) i have error "downcast clplacemark? clplacemark unwraps optional" how fix error ?! if don't need make copy of first placemark, need : if let p = placemarks.first { print(p) self.adsresslabel.text = "\(p.administrativearea)\(p.postalcode)\(p.country)" } on other hand

mobile - predictive text input(word suggestions) not working in AutoCompleteTextView in android application development -

i have taken 1 autocompletetextview in xml like <autocompletetextview android:id="@+id/myautocomplete" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:completionthreshold="1" android:ems="10" > </autocompletetextview> i want that, input in autocompletetextview should work edittext in predictive mode. when take edittext control in android, automatically enables predictive text input(word suggestions). disable it, have use textnowordsuggestions in inputtype property. i know, have bound autocompletetextview adapter data, right interface not ready. so there way, adapter can android default predictive text input or other way. which can change later on in next version of app. i tried lot of things taking edittext control enable predictive t

javascript - When I hide a sheet in google sheets, it alters the output of my script -

i created script generate pdfs, save them drive , email them if required. the script works fine. just 1 weird issue, when hide sheet called "trafficagentpdf" , run script. creates pdf in drive, it's corrupt somehow. cannot opened google, when opening in browser, it's blank. unhide sheet, , works. the trafficagentpdf sheet vlookup on sheet, show images instead of values. images small icons, , 3 used. red traffic light, amber traffic light , green. (thought i'd mention incase weird rendering issue) here script. if unclear, let me know , annotate it. function getagentname() { var ss = spreadsheetapp.getactivespreadsheet(); ss.getrangebyname('header').clearcontent(); ss.getrangebyname('scores').clearcontent(); ss.getrangebyname('comments').clearcontent(); var sheet = ss.getsheetbyname("pdf creator"); var range = sheet.getrange("a2") var value = range.getvalue(); if(value != 0){ getagentdata(value); } els

Comparing the modules in Python. OK, but why? -

i going through question in checkio. , came across this. import re,math re > math # returns true math > re # returns false can explain how python compares between 2 things. does python thing providing hierarchy modules. furthermore, re > 1 # return true # ok, why? i appreciate deep explanations on these things! everthing object. , modules no exception. therefore: import re, math print(id(re), id(math)) print(re > math) print(id(re) > id(math)) print(re < math) print(id(re) < id(math)) print(id(re), id(math)) in case: 39785048 40578360 false false true true 39785048 40578360 your mileage may vary, because ids not mine , therefore comparison may reversed in case.

Django select_related on multitable inheritance -

i'm tring use select_related on multi-table inheritance lookup. code has drawbacks , wonder if there better solution class parent(models.model): user = models.foreignkey(settings.auth_user_model) class child(models.model): pass with above class definition, i'd serialize parents (heterogeneous) parents = parent.objects.all().select_related('user', 'child') parent in parents: parent.child.user # <-- db access, nullifies select_related('user') # i'm passing parent.child childserializer() expects child object, , access user, it's parent.child.user i can do parent.objects.all().selecte_related('child__user') but has own problem when there multiple child models (it needs join each child class)

web - the browser wont reload automatic,but will once I click somewhere,eg, the browser irself -

this weird problem, , after search, cant fix problem, first time ask on stackoverflow. gulpfile.js following... //i want easy task,once css change,reload browser. var gulp = require('gulp'); var browsersync = require('browser-sync'); gulp.task('watch',['browsersync'], function() { gulp.watch('src/css/*.css', browsersycn.reload); gulp.watch('src/*.html', browsersync.reload); }); gulp.task('browsersync', function() { browsersync({ server: { basedir: 'src' } }) }); thank guys! normally use: var browsersync = require('browser-sync').create(); and use browsersync.**init**({ server: { basedir: 'src' } }) to initialize. hope helps. edit 17 jan 2016: webstorm can seem cache change , not write file system. in case browsersync (gulp) can't see change. clicking out of webstorm or refreshi

css - styling visited links belonging to a class -

i cannot find way style a:visited belonging .extern . a:visited.extern doesn't work , neither a.extern:visited (i' using mozilla firefox 43.0.1 linux x86_64) the reason have small icon i'd add .extern links, , want change url() when link visited. <style> a.extern { padding-right:1.3em; background-repeat: no-repeat; background-attachment: scroll; background-position: right center; background-clip: border-box; background-origin: padding-box; background-size: 0.7em 0.7em; background-image: url("img/link.png"); } a:visited:extern { background-image:url("img/link-visited.png"); } a.extern:visited { background-image:url("img/link-visited.png"); } </style> in end visited links of type should affected <a class="extern" href="http://etc.etc.etc">link</a> basically want restrict

delphi - Kbmmw. Time out message "Anonymous user not authorized" -

i made new topic issue. kim told\ anonymous requests typically means not find username/password not token in clients request. remember token on first request should reused subsequent requests client code (all kbmmwsimpleclient, kbmmwclientquery, kbmmwclientresolver etc). on way centralize put tkbmmwsimpleclient on datamodule , specify client query components use simple client instance template. first thing before else in client application, make initial "login" request call via simpleclient. i changed serversidequeryallclick on client app. copied token server side client edit1.text. procedure tform1.btnnamedserversidequeryallclick(sender: tobject); begin // gets records server event table. if length(trim(edit1.text)) > 0 begin kbmmwsimpleclient1.disconnect; kbmmwsimpleclient1.username:= cb1.text; // login -> franz kbmmwsimpleclient1.password:= cb2.text; // password -> franzpassword

Django Order By Query on Methods in Models -

i have model: class user(models.model): uid = models.autofield(primary_key=true) email = models.emailfield(max_length=200, unique=true) password = models.charfield(max_length=200) name = models.charfield(max_length=200, default='') contact = models.charfield(max_length=10) cash_amount = models.integerfield(default=25000) share_amount = models.integerfield(default=0) def __str__(self): return self.email def total_amount(self): return self.cash_amount + self.share_amount how write queryset ordering result on basis of total_amount() , tried below query: user.objects.order_by('total_amount()') but fielderror: invalid order_by arguments: ['total_amount()'] comes. is there other way possible of writing query ordering result on basis of cash_amount + share_amount without creating total_amount() . you can try using extra user.objects.extra( select={'field_sum' : 'cash_amount + share_amount'}, or

Azure Websites frequent short outages -

mvc5 starter app deployed azure websites, standard tier, 2 small instances, alwayson configured. using new relic's availability monitoring see uptime. over course of 2 days application considered down on 8 occasions, ranging 2-8 minutes. have experienced similar issues azure websites? there options haven't yet discovered reduce these small outages?

c++ - qsort with array of structs? -

i trying use qsort on array of structs error: expected primary-expression before '*' token struct muchie { int x,y,c; } a[100]; int cmp(const void* p, const void* q) { muchie vp,vq; vp=*(muchie* p); vq=*(muchie* q); return vp.c-vq.c; } // .... qsort(a,m,sizeof(muchie),cmp); the casting of parameters wrong - should *(muchie*)p instead of *(muchie* p) . use: int cmp(const void* p, const void* q) { muchie vp,vq; vp=*(muchie*) p; vq=*(muchie*) q; return vp.c-vq.c; }

sql server - INSERT rows from MAPPING table if not exist -

i have these 2 tables: table p | b --------- x | 2 x | 7 x | 10 x | 28 y | 24 mapping m c | d ----------- 7 | 2136 28 | 786 24 | 4212 124 | 5311 935 | 6012 if can find matching value of column b in table p value in column c of mapping m, need add value of column d table p well. for example, 1st record of x , 2 of table p, can't find 2 in column c of mapping m, nothing added. 2nd record x , 7, can find 7 in column c, gonna add x , 2136 table p. hence added table p: x | 2136 x | 786 y | 4212 i find challenging insert these 3 rows. i can this: select p.*, m.d @tablep p join @mappingtable m on (p.b = m.c) and put result temp table , insert, how do in 1 insert statement? i realized it's quite straightforward: insert @tablep select p.a, m.d @tablep p join @mappingtable m on (p.b = m.c)

php - Show button only from monday to friday -

i have written simple code display button 10am 3pm. works fine this, should not display button on satruday , sunday. <?php date_default_timezone_set('europe/zurich'); $currenthour = date("h:i"); $day = date(format) $opentime = "10:00"; $closetime = "15:00"; if ($currenthour >= $opentime && $currenthour < $closetime){ $css = 'display:block;'; }else{ $css = 'display:none;'; } echo '<style type="text/css">.menudelgiorno {'.$css.'}</style>'; ?> i'm newbie in programming in general , me lot if can give me tipps. thank you!! to determine day of week, use formatting option n return iso-8601 numeric representation of day of week (added in php 5.1.0) 1 (for monday) through 7 (for sunday) $dow = date("n") ; if ($currenthour >= $opentime && $currenthour < $closetime && $dow < 6){ $css = 'display:block;'; }

c# - UWP TextBox.Text binding not updating when using PlaceholderText -

i've got text boxes wanted set placeholdertext property. text of each box bound property of underlying view model. when setting placeholder in xaml that <textbox placeholdertext="placeholder" text={binding propertyname} /> i noticed, view model's properties not updated anymore when text box loses focus. whereas without placeholder binding works fine. is behaviour intended , if there workarounds, or have stick classic textblock describes intended input each box? edit: property implement inotifypropertychanged , binding updated in view model when no placeholder set. placeholdertext textbox not change textbox behavior when loses focus. you can try explicitly using "twoway" binding mode text property, instead of "default" binding mode. <textbox placeholdertext="placeholder" text="{x:bind propertyname, mode=twoway}" /> make sure view's datacontext set viewmodel, below public mainpa

mongodb - Find the last element in an array -

i have data below: { "_id" : objectid("569a5328c5905e1b08113987"), "dataid" : "003f2d9c0b9b0f047df458b78a12404a", "datasensors" : [ { "iotserial" : "7ee042ad9d01e3e53c1b05d8923ce2ec", "datemesure" : "2016-01-16 15:51:41", "value" : "0.47" }, { "iotserial" : "aaa042ad9d0aaaaaa1b05d8923ce2aa", "datemesure" : "2016-01-16 15:51:40", "value" : "15.66" }, { "iotserial" : "7ee042ad9d01e3e53c1b05d8923ce2ec", "datemesure" : "2016-01-16 15:51:40", "value" : "15.66" }, { "iotserial" : "7ee042ad9d01e3e53c1b05d8923ce2ec", "datemesure" : "2016-01-16 15:51:42", "value" : "10.15" } ], &

android - Is there a way to do this...R.Id."string"? -

i have folder called "raw" in res folder selection of short audio tracks , screen displays several buttons. i able start mediaplayer this... string[] track = {"track1", "track2", "track3", etc...} mplayer = mediaplayer.create(this, r.raw.track[x]); the issue r.raw.track[x] . is there way in way i'm attempting or need whole new approach? thanks in advance advice can offer. i going assume here x index, perhaps pulled user selection track . you have 2 main options: have corresponding int[] {r.raw.track1, r.raw.track2, ...} , r.raw value way use getresources().getidentifier() identifier @ runtime the second option easier uses reflection , not super-quick. in case, should not matter, doubt looking these ids in tight loop.

matrix - Complement subset in Matlab -

this question has answer here: how remove elements @ set of indices in vector in matlab? 1 answer in r, can following: v <- 11:20 v[-(4:5)] and 11 12 13 16 17 18 19 20 , indices except 4th , 5th. is there equivalent in matlab's indexing logic? however wrap mind around it, not seem correct search terms google own result elementary question. note: of course might use of set functions, e.g. v = 11:20; v(setdiff(1:length(v), 4:5)) however, not intuitive. an alternative remove elements array: u = v; u(4:5) = []; i'm using temporary variable since don't know if it's acceptable modify original array v or not.

security - How to secure S3 download for user sensitve data? -

suppose have web application ebook shopping, users can download books have paid. , ebooks data(like epub data) stored in s3, users got s3 download url when our app validated user bought 1 book. i know s3 generate temporary , time-limited urls user. problem url temporary , time-limited, happen if chance user temporary url within limited time? ok 1 way seems letting limited-time short, 10 seconds, potential risks still there. i know question rigorous, how deal it? or forget it? if concern buyer distribute url, equally distribute file they've downloaded. if concern hold of url without buyer's knowledge, perhaps protect download token buyer know (e.g. password of sort). make url unusable other buyer. downside inconvenience people who've paid product.