Posts

Showing posts from May, 2013

objective c - create NSString UTF8/Unicode character from int >127 -

i want create characters int values >127. for example: calculate 133 , want character Å or calculate 149 , want character Õ (see http://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=dec ) i use following code, not return correct character: int pos = 133; nsstring *tf = [nsstring stringwithformat:@"%c", pos]; this because int >127 no regular ascii (which can done %c) also %c not work. do need encoding? or different operator in stringwithformat ? have looked @ cfstring class, don't understand how can use here , if applicable. what encoding using 133 encoded character Å? from site unicode utf-8 code point character (dec.) name u+00c5 Å 195 133 latin capital letter ring above 133 not valid value, value want is: 195 133 (two bytes). utf8 1 byte characters 127. char utf8[2] = {195, 133}; nsstring *s = [nsstring stringwithutf8string:utf8]; nslog(@"s: '%@'", s); nslog output:

php - Is there anyway to send a text message from Twilio so that the from number contains an extension? -

is there anyway send text message twilio number contains extension? something this: <?php // php helper library twilio.com/docs/php/install require_once('twilio-php/services/twilio.php'); // loads library // account sid , auth token twilio.com/user/account $sid = "..."; $token = "..."; $client = new services_twilio($sid, $token); $client->account->messages->sendmessage( "+441337944066+123#", // "+441234567891", // "hello world" // body ); at moment attempting produces error message: fatal error: uncaught exception 'services_twilio_restexception' message 'the 'from' number +441337944066+123# not valid phone number or shortcode.' twilio support here. unfortunately not support extensions when sending messages. however if you're looking dial extension on voice calls can use senddigits parameter: https://www.twilio.com/docs/api/rest/making-calls tom

android - Update listview - single row - chat from sqlite -

how can update row in listview (a chat) ? is easy make customadapter = new (..), if have 50000 message? slow make = new "always" how update "x" row? i try adaptermessages.notifydatasetchanged(); , not update, normal, don't know row listview example : user1 : hi user2 : hi? (update here) row "x" user1: hello user2: aa ok (update here) row "x" i use adapter update listview, (message receiv or not receiv) http://fielinks.com/sites/default/files/styles/large/public/images/double-check-whatsapp.jpg?itok=qbi0lgql listview = (listview)rootview.findviewbyid(r.id.listview1); listdata= getcalldetails(); listview.setadapter(new customadapter(getactivity().getbasecontext(),listdata)); listview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view arg1, int positiontoremove, long

xcode - windowDidLoad() never called using storyboards for mac -

i've played around new mac storyboard-feature included in xcode 6. i've set new os x-project using storyboards , swift, i've created new file mainwindowcontroller.swift , created initializer init(coder: nscoder!) (because otherwise compiler warns me) , hooked in main.storyboard file (set mainwindowcontroller -class windowcontroller in inspector). everything compiles fine, window specified window content -view opens. code i've written in windowdidload -function never called. let like: override func windowdidload() { super.windowdidload() println("executed") } i've tested if initializer called - is. does has clue? i've never used storyboards intensively on ios before, maybe miss substantial. in yosemite, nsviewcontroller has been promoted powerful new features make work storyboards. meanwhile, nswindowcontroller got demoted. storyboards, windows no longer loaded nib, windowdidload() doesn't called anymore. it makes s

android - How to load image from SD card using Picasso library -

i need load images sd card gridview. efficiency i'm using picasso library picasso.with(activity).load(images.get(position).getdatapath()) .resize(96, 96).centercrop().into(viewholder.image); i used following code in adapter. unfortunately m unable see images please can 1 help. note , can suggest efficient image loading library load images sd card. requirement dont load image every time when scrolling. if loaded dont load image on scrolling to load file need convert uri first uri uri = uri.fromfile(new file(images.get(position).getdatapath())); picasso.with(activity).load(uri) .resize(96, 96).centercrop().into(viewholder.image); requirement dont load image every time when scrolling. if loaded dont load image on scrolling picasso excellent this

python - How to set DJANGO_SETTINGS_MODULE? -

i have structure: example.com — bin — include — lib — local — project |— manage.py |— project |— __init__.py |— settings.py |— urls.py |— wsgi.py i set export django_settings_module=project.settings , trying install mongodb following command: pip install git+https://github.com/django-nonrel/mongodb-engine after execution, following error occurs: downloading/unpacking git+https://github.com/django-nonrel/mongodb-engine cloning https://github.com/django-nonrel/mongodb-engine /tmp/pip-gv3v7o-build running setup.py egg_info package git+https://github.com/django-nonrel/mongodb-engine error:root:error while trying django settings module. error was: not import settings 'project.settings' (is on sys.path?): no module named project.settings requirement satisfied (use --upgrade upgrade): pymongo in ./lib/python2.7/site-packages (from django-mongodb-engine==0.5.2) requirement satisfied (use --upgrade upgrade): djangot

encryption - Encrypting data in oracle database -

what ways in data can encrypted? example salary column, admin should not able see encrypted columns if possible, data should visible through application users have access defined in application, changes in application (adding new functionality encrypt/decrypt @ application level) last resort , minimal. so far have thought of 2 ways fresh ideas or pros , cons of ones below appreciated: 1. using oracle tde (transparent data encryption). - con : admin can possibly grant himself rights see data 2. creating trigger encrypt before insert , along lines of pipeline retrieve. oracle database vault way prevent dba being able access data stored in database. cost product, however, , requires have additional set of security admins job grant dbas whatever privileges need. barring that, you'd looking @ solutions encrypt , decrypt data in application outside database. involve making changes database structure (i.e. salary column declared raw rather number ). , involves

sql - PHP prepared statement -> only returns first letter from a column in database -

i have code $sql = "select name data id=? limit 0,1"; //prepares statement $stmt = self::getconnection()->prepare($sql); $stmt->bind_param("i", $id); $ids = array(1,2,3); foreach ($ids $key => $id) { $stmt->execute(); $stmt->bind_result($name); $stmt->fetch(); $stmt->store_result(); var_dump($name); } my database table looks this id | name 1 | first name 2 | second name 3 | third name now output looks this: string(10) "first name" string(1) "s" string(1) "t" the first name correct. outputs first letter of following rows. don't know why. tried out column integer-type. worked. string-type column doesn't. i tried change $ids-array in this: $ids = array(2,3,1) . outputs string(11) "second name" string(1) "t" string(1) "f" i have no clue

ruby on rails 4 - time_ago_in_words is cut short -

Image
i face minor problem in chapter 10 of rails tutorial. spec tests pass list of user microposts bit different shown in tutorial - namely, time stamp displayed without "ago" word - "posted 4 days ago" becomes "posted 4 days": i think followed instructions correctly. here code micropost partial: <li> <span class="content"><%= micropost.content %></span> <span class="timestamp"> posted <%= time_ago_in_words(micropost.created_at) %> </span> </li> and here stylesheet: /* microposts */ .microposts { list-style: none; margin: 10px 0 0 0; li { padding: 10px 0; border-top: 1px solid #e8e8e8; } } .content { display: block; } .timestamp { color: $graylight; } .gravatar { float: left; margin-right: 10px; } aside { textarea { height: 100px; margin-bottom: 5px; } } what doing wrong? time_ago_in_words not add ago word.you should adding maually. this should work.

c++ - Eye detection with OpenCV (detecting eye from "Scream's mask") -

i have detect eyes picture , after need coordinates them. http://damngoodcup.com/wp-content/uploads/scream-mask.jpg i have used opencv, , following command: eyes_cascade.detectmultiscale(frame_gray, eyes, 1.1, 2, 0 | cv_haar_scale_image, size(30, 30)); on other pictures (for eg.: on selfie) it's working, "scream face" it's useless. is there way find eyes on picture? (using opencv not important if there easier solution) haar classifier provided opencv not work image (face, eyes, etc), because differs positive training data, limited humans' faces. example, humans' eyes have different features extracted haar features "eyes" in image you've provided. if detect eye-like region in image haar cascade, have train own yourself. don't think can find kind of such trained classifier.

Providing a default value for an Optional in Swift? -

the idiom dealing optionals in swift seems excessively verbose, if want provide default value in case it's nil: if let value = optionalvalue { // 'value' } else { // same thing default value } which involves needlessly duplicating code, or var unwrappedvalue if let value = optionalvalue { unwrappedvalue = value } else { unwrappedvalue = defaultvalue } which requires unwrappedvalue not constant. scala's option monad (which same idea swift's optional) has method getorelse purpose: val myvalue = optionalvalue.getorelse(defaultvalue) am missing something? swift have compact way of doing already? or, failing that, possible define getorelse in extension optional? update apple has added coalescing operator: var unwrappedvalue = optionalvalue ?? defaultvalue the ternary operator friend in case var unwrappedvalue = optionalvalue ? optionalvalue! : defaultvalue you provide own extension optional enum: extension optio

ruby on rails - Translate devise labels in registration? -

i want translate labels in registration form, can't see schema follow in .es locale. wont work "registrations". knows? can't find correct answer in internet. thanks .es locale devise: registrations: name: "nombre" email: "email" password: "contraseña" password_confirmation: "recordarme" it's done via active record translations es: activerecord: attributes: user: password: "contraseña" email: "email" password_confirmation: "recordarme"

Finding median of list in Python -

how find median of list in python? list can of size , numbers not guaranteed in particular order. if list contains number of elements, function should return average of middle two. here examples (sorted display purposes): median([1]) == 1 median([1, 1]) == 1 median([1, 1, 2, 4]) == 1.5 median([0, 2, 5, 6, 8, 9, 9]) == 6 median([0, 0, 0, 0, 4, 4, 6, 8]) == 2 python 3.4 has statistics.median : return median (middle value) of numeric data. when number of data points odd, return middle data point. when number of data points even, median interpolated taking average of 2 middle values: >>> median([1, 3, 5]) 3 >>> median([1, 3, 5, 7]) 4.0 usage: import statistics items = [1, 2, 3, 6, 8] statistics.median(items) #>>> 3 it's pretty careful types, too: statistics.median(map(float, items)) #>>> 3.0 decimal import decimal statistics.median(map(decimal, items)) #>>> decimal('3')

mongodb - Using same form for insert and edit -

how can use same form inserting , editing document in meteor. for insert use empty form without variable: <template name="frmorganization"> // no doc variable <form class="form-horizontal" role="form"> ... <input type="text" class="form-control" id="name"> and update use form variable: <template name="frmorganization"> {{#with organization}} // doc variable <form class="form-horizontal" role="form"> ... <input type="text" class="form-control" id="name" value="{{name}}"> (using meteor 0.9.3 + iron-router) i had same issue , workaround used follows (seems more of hack avoid having multiple forms) <template name="frmorganization"> // no doc variable <form class="form-horizontal" role="form"> ... <input type="text&quo

android - ListFragment with Navigation Drawer -

bit of noob @ android, made far. trying listview navigation drawer... following doesn't work unless uncomment setcontentview line. throws null ptr exception. when uncomment it, listview works, nav drawer quits showing up. also, onlistitemclick doesn't trigger, that's later problem me learn. import java.util.arraylist; import java.util.list; import android.app.activity; import android.os.bundle; import android.support.v4.app.listfragment; import android.util.log; import android.view.view; import android.widget.listview; import android.widget.toast; public class all_listview extends listfragment { @override public void onlistitemclick(listview l, view v, int position, long id) { super.onlistitemclick(l, v, position, id); log.d("onclick", string.valueof(position)); activity = getactivity(); string item = (string) getlistadapter().getitem(position); toast.maketext(a, item + " selected", toast.length_long).show(); } @override

c# - Best way to store table like data -

what best way store table data | column 0 | column 1 | column 2 | column 3 | column 4 row 0 | 0.984546 | 0.654564 | 0.467676 | 0.673466 | 50.03333 row 1 | 0.684546 | 0.457564 | 0.467776 | 0.674566 | 45.73335 row 2 | 0.884546 | 0.424564 | 0.445676 | 0.664566 | 12.23333 row 3 | 0.284546 | 0.054564 | 0.237676 | 0.124566 | 45.01333 both max column , row dynamic , coordinates of value important have calculation based on value. it's not database because data different every time , don't want forever there. also, need access. try use linked list double[] it's difficult me locate each of value. speed factor too. any suggestion on type of collection should use or ways handle it? i think should declare variable: list< list<double> > matrix = new list< list<double> >(); later can use matrix.capacity decide number of rows , use same property on each row set number of columns. way wont have memory wasted. you can use

javascript - Binding multiple event handler pairs on dynamically generated elements in jquery with on -

i have dynamically generated elements class my-class on want bind events. have below code works properly. $(document).on("event1", ".my-class", function () { alert("event 1"); }); $(document).on("event2", ".my-class", function () { alert("event 2"); }); i want refactor there can single call on category. this $(document).on(".my-class", { "event1": function() {alert("event1")}, "event2": function() {alert("event2")} }); is possible in jquery? there might better way, i've used before , worked me: demo fiddle i wouldn't delegate off document, instead i'd use closest parent container. js: $('body').on('click mouseenter', 'div', function(e) { if (e.type === 'click') { $('div').html('clicked'); } else { //you'd need else if here if had more 2 eve

Python Minidom XML parsing interchangable upper and lower case node names -

hoping here. writing small script pull info data file. following start of xml...its quite big. <?xml version="1.0" encoding="iso-8859-1"?> <flatnet version="1" id="{014852f8-3010-4a5f-8215-8f47b000ea60}" sch="vbt-mbb-1.4.scs"> <partnumbers> <partnumber name="pn_lib_name" version="1"> <properties ver="1"> <a key="partname" value="part_name"/> <a key="altpartref" value="part_ref"/> my problem in of files need parse, node capitalized , in lower case. how node name (either "a" or "a") variable can use function? else stuck changing manually every time want parse new file depending on file contains. thanks heaps in advance! you either have have 2 nodelists , work them individually a1 = doc.getelementsbytagname('a') a2 = doc.getelementsbytagname('a') #do stuff a1 , a2 or

arrays - Ruby: creating a matrix with diagonal band of 1,2,1 -

before start, plz understand total beginner @ ruby , computer programming, possess no prior knowledge , need programming basic of basic or else cannot understand. doing project school , stuck. i have create code in ruby matrix n rows , n columns banded values [2,1] [2,1,0,0,0] [1,2,1,0,0] [0,1,2,1,0] [0,0,1,2,1] i made code dont know why wrong , where.. plz help!! def make1d(n) = array.new(n) in 0..(n-1) a[i] = 0 end end def make2d(height,width) = array.new(height) in 0..(height-1) a[i] = make1d(width) end end def matrixa(n) a=make2d(n,n) k in 0..n-2 a[k][k]=2 a[k+1][k]=1 a[k][k+1]=1 a[n-1][n-1]=2 end end ruby has great features can take advantage of. example, array.new takes block ( do ... end ) specify default value. block gets current index parameter ( do |index| ... end ). perfect scenario! your logic seems quite complex setting values on diagonal. if take step back, makes diagonal special if @ row , column indices? rig

jsp - Struts2 custom 404 error page never shows -

i'm using struts2 framework webapp. while trying create custom 404 error page discovered struts2 doing more work me intended. i use struts.xml , web.xml file. in web-xml file added following code: <error-page> <error-code>404</error-code> <location>/error/error404.jsp</location> </error-page> now, when start webapp goes homepage usual. when try urls of type (all urls don't exist): http://localhost:8080/mywebapp/fhgfhfhfhgfhgfhfhfh http://localhost:8080/mywebapp/fhgfhfhfhgfhgfhfhfh.action struts process request, run interceptors, , automatically redirect default page. have expected 404 error page shown on these pages. removed line in struts.xml still redirects! <default-action-ref name="index" /> when use following url: http://localhost:8080/mywebapp/fhgfhfhfhgfhgfhfhfh.jsp struts shows blank screen , no request being procesed (no interceptors, no redirecting...). find weird because don't see w

ruby - Setting method local variables from a proc -

if have class 2 instance variables @x , @y , can change them proc using self.instance_exec : class location attr_accessor :x, :y def initialize @x = 0 @y = 0 end def set &block self.instance_exec(&block) end end location = location.new location.set @x = rand(100) @y = rand(100) end puts location.x puts location.y if have class method set 2 local variables x , y , can use proc return values set them: class location def set &block x = 0; y = 0; x, y = block.call() # x , y puts x puts y end end location = location.new location.set x = rand(100) y = rand(100) [x, y] end is there way access set method local variables x , y proc without using return values? you can it, sort of, isn't pretty there way block set variable in calling method, isn't pretty. can pass in binding, eval code using binding: def foo(binding) binding.eval "x = 2" end x = 1 foo(binding) p x #

spacebars - Meteor: nested templates and a pseudo switch conditional -

i'm new meteor , @ moment i'm testing out nested templates. more specific, i'm trying pseudo switch working. i have parent template gets data template.helper function gets data {{#each}}. this parent template <template name="result"> {{#each tresult}} <div class="jow"> <h3>{{name}}</h3> <p>{{type}}</p> <div>{{> tstatus}}</div> </div> {{/each}} </template> the parent includes template {{> tstatus}} this child template <template name="tstatus"> {{#status_is "green"}} {{> tstatus_green}} {{/status_is}} {{#status_is "red"}} {{> tstatus__red}} {{/status_is}} {{#status_is "orange"}} {{> tstatus__orange}} {{/status_is}} </template> <template name="tstatus_green"> <span>green

How to make atomic group work with alternations in java regex? -

i have seen simple demo of atomic group. regex : a(?>bc|b)d i try run on java 7 , doesn't work expected because matches in demo: pattern pattern = pattern.compile("a(?>bc|b)d"); matcher matcher = pattern.matcher("abd"); system.out.println("matches="+matcher.matches()); prints: matches=true but atomic group avoid trying alternatives. how turn on atomic group in java? it seems misunderstood example http://www.regular-expressions.info/atomic.html you need understand purpose of atomic group prevent backtracking impossible change already matched substring new substring. match not found first case of alternation ok test next case of alternation. so string abd , regex a(?>bc|b)c regex parts | matched string parts ---------------+---------------------- | (?>bc|b) | b - happens because `bc` can't matched next case | alternation inside atomic group

google app engine - Python TypeError on NDB Model.query() -

i following ndb queries doc of gae in python, can not continue following errors: # python google_appengine/remote_api_shell.py -s 127.0.0.1:8020 app engine remote_api shell python 2.7.3 (default, mar 13 2014, 11:03:55) [gcc 4.7.2] db, ndb, users, urlfetch, , memcache modules imported. dev~env> class customer(ndb.model): ... name = ndb.stringproperty() ... dev~env> class purchase(ndb.model): ... customer = ndb.keyproperty(kind=customer) ... price = ndb.integerproperty ... dev~env> c = customer() dev~env> c.name = 'lvqier' dev~env> k = c.put() dev~env> k key('customer', 5629499534213120) dev~env> p = purchase() dev~env> p.customer = k dev~env> p.price = 10 dev~env> kp = p.put() dev~env> purchase.query(customer=c.key).fetch() traceback (most recent call last): file "<console>", line 1, in <module> file ".../google_appengine/google/appengine/ext/ndb/model.py", line 3209, in _query

c - Extracting IP and port from multiple sockaddr_storage's into a char* -

i have fixed length array, every entry type struct contact typedef struct contact { int fd; union { struct sockaddr_in v4addr; struct sockaddr_in6 v6addr; struct sockaddr_storage stor; }; char buf[frame_buf_len]; int len; char name[32]; } contact_t; and need extract ip , port every entry char*. result should this 192.168.0.1 1234\n192.168.0.2 1235\n192.168.0.3 1236\n //and on.. i have no clue how information , allocate correct size final char*. use (for example) struct sockaddr_storage stor 's member ss_family determine address family , depending on chose v4addr or v6addr used inet_ntop() . the port number comes in network bytes order, shall pass ntohs() before being used. the members of v4addr , v6addr used drawn <netinet/in.h> : /* structure describing internet socket address. */ struct sockaddr_in { [...] in_port_t sin_port; /* port number. */ struct in_

Simple way of creating a 2D array with random numbers (Python) -

i know easy way create nxn array full of zeroes in python with: [[0]*n x in range(n)] however, let's suppose want create array filling random numbers: [[random.random()]*n x in range(n)] this doesn't work because each random number created replicated n times, array doesn't have nxn unique random numbers. is there way of doing in single line, without using loops? you use nested list comprehension: >>> n = 5 >>> import random >>> [[random.random() in range(n)] j in range(n)] [[0.9520388778975947, 0.29456222450756675, 0.33025941906885714, 0.6154639550493386, 0.11409250305307261], [0.6149070141685593, 0.3579148659939374, 0.031188652624532298, 0.4607597656919963, 0.2523207155544883], [0.6372935479559158, 0.32063181293207754, 0.700897108426278, 0.822287873035571, 0.7721460935656276], [0.31035121801363097, 0.2691153671697625, 0.1185063432179293, 0.14822226436085928, 0.5490604341460457], [0.9650509333411779, 0.7795665950184245, 0.

mysql - Django -- Custom filter or SQL raw -

i have application model has 3 tables implementing toxi tagging model. 1 table jobs, 1 table skills , 1 table map them, in form of jobid -- skillid. due number of mappings if use following: {% job in jobs %} <p>{{ job.job_title }}</p> {% skill in skillmaps %} {% if job.id == skill.job_id.id %} #{{ skill.skill_id|title }} {% endif %} {% endfor %} {% endwith %} it uses processor , takes long time, in order of 30 minutes. if query db skillids in mapping table jobid = "nnn", query fast. i wondering best approach, this: {% job in jobs %} <p>{{ job.job_title }}</p> {{ print skills job.job_id}} {% endwith %} i've tried custom filters, can't code above work, seems have filter value skillmaps foor lop, it's same problem. possible define class raw query , pass variable loop in template? or best approa

multithreading - Java Audio Metronome | Timing and Speed Problems -

i’m starting work on music/metronome application in java , i’m running problems timing , speed. for testing purposes i’m trying play 2 sine wave tones @ same time @ regular intervals, instead play in sync few beats , out of sync few beats , in sync again few beats. from researching metronome programming, found thread.sleep() horrible timing, avoided , went checking system.nanotime() determine when sounds should play. i’m using audiosystem’s sourcedataline audio player , i’m using thread each tone polls system.nanotime() in order determine when sound should play. create new sourcedataline , delete previous 1 each time sound plays, because volume fluctuates if leave line open , keep playing sounds on same line. create player before polling nanotime() player created , has play sound when time. in theory seemed method getting each sound play on time, it’s not working correctly. i’m not sure if timing problems running different threads or if has deleting , recreating sourcedatal

typo3 - How to Create a Multi-Column Custom Content Element -

i'm trying create custom two-column content element in typo3 neos. i'm aware neos shipped multi-column functionality, particular case need create own custom content element. so far i've been able create 1 of columns (see below gist code). however, try add second column, page turns blank , no further changes can made. gists 1 column activated (working properly): https://gist.github.com/anonymous/c5f33c7923faae26aa1a 2 columns activated (not working): https://gist.github.com/anonymous/85fc6994e9e2c5892a11 any idea why happening, or how solve / build multi-column custom content element in neos? i found solution! had execute following flow command create missing node: ./flow node:autocreatechildnodes --node-type daniel.multicolumn:twocol

PHP foreach and strpos newbie -

why doesn't work? $statement = array( images_name[0] => 'small_01.jpg', images_name[1] => 'large_01.jpg', ); foreach ($statement->images $image): if (strpos($image->name, 'small')) { echo ('yes'); } endforeach i can print image name without problem strpos not working. you must use: foreach ($statement->images $image) if ( strpos($image->name, 'small') !== false ) { echo ('yes'); } explained here: http://us3.php.net//manual/en/function.strpos.php also, if want know why need use of "!==" or "===" read this: how php equality (== double equals) , identity (=== triple equals) comparison operators differ?

oop - PHP SplObjectStorage Cannot create within a class -

this question has answer here: getting error trying initialize public class variable using dirname() outside method 9 answers would possible initialize protected splobjectstorage map within class? seem running error whenever try this. similar example below: class { protected $a = new splobjectstorage(); ... } you need use constructor class { public function __construct() { $this->a = new splobjectstorage(); } protected $a; ... }

html - css weird margin -

does know why in example the inner <div> displayed vertically instead of horizontally? i use chrome element inspect can see huge margin area on right of each <div> , without margin value. found example could answer question, too. in case needs it. it happens because using block layout each inner div ( display:block default div elements). instead should use (for example ) display:inline-block , reduce width (to 33% in example) adds pixels spacing between 3 inner divs : .cols_section > div{ display:inline-block; } example another option use table layout, don't have change width each inner div: .cols_section { display:table; width:100%; } .cols_section > div{ display:table-cell; } example

firewall - Can't connect to port 25 on Google Compute instance (incoming SMTP) -

i running postfix on google compute instance. listening on 0.0.0.0:25, , have opened port 25 on firewall, cannot connect outside. have reviewed this , this , not resolve issue. don't see in google compute documentation explain this. the port open on firewall: % gcutil --project=xxx getfirewall smtp +---------------+-------------------------------+ | name | smtp | | description | incoming smtp allowed. | | creation-time | 2014-06-08t13:29:16.052-07:00 | | network | default | | source-ips | 0.0.0.0/0 | | source-tags | | | target-tags | | | allowed | tcp: 25 | +---------------+-------------------------------+ from outside, can connect port 80 (which open)... % telnet 108.xxx.xxx.xxx 80 trying 108.xxx.xxx.xxx... connected 108.xxx.xxx.xxx. escape character '^]'. / <!doctype html&g

Parsing Meteor error: Exception from Deps afterFlush -

i these deps errors time time , can never figure out mean or they're pointing to: exception deps afterflush function function: syntaxerror: unexpected identifier @ eval (native) @ http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:372:22 @ function.jquery.extend.globaleval (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:373:7) @ jquery.ajaxsetup.converters.text script (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9806:11) @ ajaxconvert (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:8873:18) @ done (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9293:15) @ callback (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9753:8) @ object.send (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9759:7) @ function.jq

django get_model returns null when called from __.init__.py? -

from django.db.models import get_model modelname=get_model('base','reports') the above code works fine in views.py , django shell,but returns null when called init .py folder structure shown below projectsfolder --base ----models.py ----views.py ---- init .py that can't possibly work. in __init__.py going executed first time in directory imported. django has import models in order register them, you've got chicken-and-egg situation: won't register them until imports them, you're trying models when they're imported... can explain though why don't from models import reports ?

android - Posting Tweets Works on Some Devices -

i using twitter4j in android. have weird instance wherein can post tweets in sony experia phone while cannot post in samsung galaxy tab , s4. logcat says, 06-09 14:07:53.602: w/defaultrequestdirector(22501): authentication error: unable respond of these challenges: {} 06-09 14:07:53.610: e/sample.app.twitter.preparerequesttokenactivity(22501): oauth - access token retrieval error 06-09 14:07:53.610: e/sample.app.twitter.preparerequesttokenactivity(22501): oauth.signpost.exception.oauthnotauthorizedexception: authorization failed (server replied 401). can happen if consumer key not correct or signatures did not match. some because of wrong date in phone looked @ phone's date , time right. wrong this? hope me. thank you.

android - Google In App Billing My App Name is not showing.Its Show "Sample Title ". Why? -

i have uploaded signed .apk on google play.i have added in-app billing files on project when click on in app purchase show [1]: http://i.stack.imgur.com/xntvn.png this. i'm following http://www.androidhub4you.com/2013/03/how-to-inegrate-in-app-purchase-billing.html tutorial.kindly me how can put app's name on dialogue? that because using android.test.purchased sku. use own , see title set in developer console.

java - SSL use symmetric or asymmetric? -

so far understand: sender starts handshake server. server generates pair of public , private key using asymmetric encryption , re-encrypt public key alone using symmetric encryption. , passes public key sender. sender encrypt message using public key , sends encrypted message server. server decrypt message using symmetric encryption , decrypt message again using private key. is right way how ssl encryption works?? please correct me. sender starts handshake server. client starts handshake server. server generates pair of public , private key using asymmetric encryption , re-encrypt public key alone using symmetric encryption. no. and passes public key sender. no. sends certificate client , start secret-key negotiation. sender encrypt message using public key no. uses symmetric session key negotiated during handshake. and sends encrypted message server. yes. server decrypt message using symmetric encryption yes. a

Elements combination of same array in PHP -

in project, have receive string user (in textarea). string converted array . problem that, character length must minimum of 3, in following array next element should joined current 1 if character length less 3. how perform in php . a[0]=>this a[1]=>is a[2]=>an a[3]=>example a[4]=>array. output should be: a[0]=>this a[1]=>isan a[2]=>example a[3]=>array. just try with: $input = ['this', 'is', 'an', 'example', 'array.']; $output = []; $part = ''; foreach ($input $value) { $part .= $value; if (strlen($part) > 3) { $output[] = $part; $part = ''; } } output: array (size=4) 0 => string 'this' (length=4) 1 => string 'isan' (length=4) 2 => string 'example' (length=7) 3 => string 'array.' (length=6)

c# - Exception Info: System.Reflection.TargetInvocationException -

i working on wpf application receive error @ run time on single device. exception info: system.reflection.targetinvocationexception my question: any clue of cause error? any idea how debug application in release mode? exception info: system.reflection.targetinvocationexception stack: @ system.runtimemethodhandle.invokemethod(system.object, system.object[], system.signature, boolean) @ system.reflection.runtimemethodinfo.unsafeinvokeinternal(system.object, system.object[], system.object[]) @ system.delegate.dynamicinvokeimpl(system.object[]) @ system.windows.threading.exceptionwrapper.internalrealcall(system.delegate, system.object, int32) @ ms.internal.threading.exceptionfilterhelper.trycatchwhen(system.object, system.delegate, system.object, int32, system.delegate) @ system.windows.threading.dispatcheroperation.invokeimpl() @ system.windows.threading.dispatcheroperation.invokeinsecuritycontext(system.object) @ system.threading.executioncontex

java - Having a null foreign key in torque 4 -

is there way torque translate value of 0 null, foreign key? i have following schema: <table name="juser" idmethod="native"> <column name="id" primarykey="true" required="true" type="integer"/> <column name="name" required="true" size="2147483647" type="varchar"/> </table> <table name="juserdepend" idmethod="native"> <column name="id" primarykey="true" required="true" type="integer"/> <column name="juserref" required="false" type="integer"/> <foreign-key foreigntable="juser"> <reference foreign="id" local="juserref"/> </foreign-key> </table> and table created sql: create table juserdepend(id serial not null primary key, juserref int, name text not null, foreign key(juserref) referen

Is it possible to check status or turn on/off HDCP on Mac OSX? -

is possible programatically check status or turn on/off hdcp on mac osx? there official apple documentation on this? have seen elsewhere commented not possible turn off hdcp in osx. ok need definite proof true. i know can't turn off. once tried hook output of mac device have full control. specified in edid of device accept no hdcp protected data. way, source should switch off if hdcp not must on side. however, didn't work , no output mac.

multithreading - Java - File Download makes Program Stop -

when download file in java following code, can't use program anymore, it's not responding. when download finishs can use again. url website = new url("my_url"); readablebytechannel rbc = channels.newchannel(website.openstream()); fileoutputstream fos = new fileoutputstream("grafik"); fos.getchannel().transferfrom(rbc, 0, long.max_value); how fix that? e.g. loading screen showed or dialog pops up? in advance :d time learn wonderful world of concurrency ! new thread(new runnable() { @override public void run() { url website = new url("my_url"); readablebytechannel rbc = channels.newchannel(website.openstream()); fileoutputstream fos = new fileoutputstream("grafik"); fos.getchannel().transferfrom(rbc, 0, long.max_value); } }).start(); doing launch separate thread -- line of execution hat acts independently of 1 it's spawned from. allow user interface continue function whil

CSS Only Selecting Certain Classes -

hi i'm working wordpress template. have separate template page blog section. on other pages of site have class works fine , looks this .post header h2 { display:none; } on blog page, add css , works should #main .post header h2 { display:block; } however if try other classes #main .wrapper { background-color:#000000; } nothing happens. i've tried adding !important, i've tried writing such body.page-id-15 #main .wrapper { background-color:#000000; } with no luck. here link site. http://gregtregunno.ca/news the css selector wrong. does not work: #main .wrapper { background-color:#000000; } does work: .wrapper #main { background-color:#000000; } in html of wordpress page, link have supplied, #main div located inside of .wrapper div: ... <div class="wrapper"> ... <div id="main"> ... </div> ... </div> ...

Grails unit testing custom codec using Spock -

i'd create spock unit test test custom codec created. of examples see test custom codecs extending grailsunittestcase this. can point me in right direction on how using spock? i ended doing following: @testmixin(grailsunittestmixin) class securecodecspec extends specification { def setup() { grailsapplication.config.acme.encryption.password = 'topsecret' mockcodec(securecodec) } @unroll def "securecodec string value #original encodes , decodes properly"() { when: def encoded = original.encodeassecure() def decoded = encoded.decodesecure() then: original != encoded encoded != decoded original == decoded where: original | _ 'secret' | _ '' | _ } }

How to export data from Cassandra to CSV file using Java -

i tried use datastax java driver , found out not support copy command, know other methods of exporting data using java? thanks. for example have created event table: cqlsh:kunderatest> describe table event ; create table event ( id text, log text, timstamp bigint, primary key (id) ) and inserted 3 record cqlsh:kunderatest> insert event (id, log , timstamp ) values ( '1', 'my first log' , 12345678); cqlsh:kunderatest> insert event (id, log , timstamp ) values ( '2', 'my second log' , 12345679); cqlsh:kunderatest> insert event (id, log , timstamp ) values ( '3', 'my third log' , 12345680); 1) first can using cqlsh client. can export data of event table file (in case log.txt) executing following command. cqlsh:kunderatest> copy kunderatest.sample (id, name, age, address) './log.txt' delimiter = '|' , quote = '''' , escape = '''' , null = '&l

Passing variables to function in python -

this question has answer here: local variables in python nested functions 3 answers i'm writing simple gui change brightness of monitor, i'm having problem. def start_ui(self): root = tk() root.wm_title("set brightness") col = 0 k, v in self.monitors.iteritems(): print k scale(root, variable = doublevar(), command = lambda(r): self.change_brightness(k, r)).grid(row=0, column=col) labelvar = stringvar() label = label(root, textvariable=labelvar).grid(row=1, column=col) labelvar.set(k) col += 1 root.mainloop() this start ui, self.monitors dictionary looks this: {'lvds1': '1.0', 'vga1': '1.0'}. the output of loop "lvds1, vga1" expected, however, when move sliders , callback called, last value of k passed, in case "vga1", no ma

Assigning a zero to all array elements in C -

in program i'm working on, particular operation not going bottleneck, did me thinking. answers questions such this one , this one i've learned 2 ways (efficiently) set elements of array 0 in c: double myarray[3]; static const double zeroes[3] = {0}; memcpy(myarray, zeroes, sizeof(zeroes)); and double myarray[3]; memset(myarray, 0, numberofelementsinmyarray * sizeof(myarray[0])); before move onto real question: i'm not entirely sure based on the information i've read, assume method would, @ least in principle, fill array int zeroes (well, unsigned char 's these seem equivalent ). correct? if so, explicit conversion of int zeroes double zeroes necessary or done implicitly if myarray declared array of double 's? anyway, real question this: if array isn't big @ (like myarray i've declared above), either of these methods still preferred on little loop? if have few arrays of same small size need assigned zeroes? if commented properly, thi

angularjs - Display a value each time it changes in a repeater -

i have angularjs repeater. <tbody data-ng-repeat="game in model.games | unique:'number'"> <tr><td colspan="3">{{game.location}}</td></tr> <tr> <td>{{game.number}}</td> <td>{{game.away}}</td> <td>{{game.home}}</td> </tr> </tbody> in game there property location remain constant change @ point, instance: [ { number: 1, location: 'place 1', home: 'team 1', away: 'team 2' }, { number: 1, location: 'place 1', home: 'team 3', away: 'team 4' }, { number: 2, location: 'place 1', home: 'team 1', away: 'team 2' }, { number: 2, location: 'place 1', home: 'team 3', away: 'team 4' }, { number: 3, location: 'place 2', home: 'team 1', away: 'team 2' }, { number: 3, location: 'place 2', home: '

html - GAE Golang template parsing error - "operation not permitted" -

i developing google app engine go application , need use html templates in 1 of packages. current file structure is: gopath/github.com/name/project/ app/ app.go app.yaml package/ package.go templates/ template.html to include package, use: import "github.com/name/project/package" inside of package.go, try parsing template.html file in various ways: //template, err := template.parsefiles("package/templates/template.html") //doesn't work - "the system cannot find path specified." //template, err := template.parsefiles("github.com/name/project/package/templates/template.html") //doesn't work - "the system cannot find path specified." //template, err := template.pa