Posts

Showing posts from August, 2013

haskell - Using Functions of `a` on `newtype a` -

haskell - Using Functions of `a` on `newtype a` - let's have next newtype : newtype foo = foo integer deriving (eq, show) is there concise way add together 2 foo 's: (foo 10) + (foo 5) == foo 15 or max: max (foo 10) (foo 5) == foo 5 ? i'm curious if it's possible utilize functions of a newtype a rather do: addfoo :: foo -> foo -> foo addfoo (foo x) (foo y) = foo $ x + y just haskell98 knows how derive eq , show instances you, can turn on generalizednewtypederiving extension ghc num , ord instances need: prelude> :set -xgeneralizednewtypederiving prelude> newtype foo = foo integer deriving (eq, show, num, ord) prelude> (foo 10) + (foo 5) == foo 15 true prelude> max (foo 10) (foo 5) == foo 5 false haskell newtype

c# - VS2010 does not show unhandled exception message in a WinForms Application on a 64-bit version of Windows -

c# - VS2010 does not show unhandled exception message in a WinForms Application on a 64-bit version of Windows - when create new project, unusual behavior unhandled exceptions. how can reproduce problem: 1) create new windows forms application (c#, .net framework 4, vs2010) 2) add together next code form1_load handler: int vara = 5, varb = 0; int varc = vara / varb; int vard = 7; i expect vs breaks , shows unhandled exception message @ sec line. however, happens 3rd line skipped without message , application keeps running. i don't have problem existing c# projects. guess new projects created unusual default settings. does have thought what's wrong project??? i tried checking boxes in debug->exceptions. executions breaks if handle exception in try-catch block; not want. if remember correctly, there column called "unhandled exceptions" or in dialog box, excatly want. in projects there 1 column ("thrown"). this nasty prob...

objective c - Images.xcassets Xcode 5.0.2: Image truncated -

objective c - Images.xcassets Xcode 5.0.2: Image truncated - my app totally ready app store except 1 issue: when testing app on iphone4 image , launch-image truncated @ bottom. in images.xcassets folder, have illustration of image in image view: the box named 1x has image size 640x960px named laddapp_blue-1.png. box named 2x has image size 640x1136px named laddapp_blue@2x.png. box named r4 has image size 640x960px named laddapp_blue-1-1.png. i have made them in photoshop , saved them png. don't know if resolution 72dpi when saved them or 300. affecting size showing? i have in 'general' set utilize images.xcassets nil wrong there. use launchimage in asset catalog. and select the right alternative in project general tab: objective-c uiimageview xcode5 xcasset

objective c - Presenting view controllers on detached ... - sometimes -

objective c - Presenting view controllers on detached ... - sometimes - like others coming ios8, i'm getting warning: presenting view controllers on detached view controllers discouraged <edititineraryviewcontroller: 0x7ca56e00>. this caused next code: - (void)editactivitydetailsforindexpath:(nsindexpath *)indexpath { nspredicate *predicatefordisplay = [[nspredicate alloc] init]; switch (indexpath.section) { case kincompleteactivitiessection: predicatefordisplay = _predincomplete; break; case kcompleteactivitiessection: predicatefordisplay = _predcomplete; break; default: break; } nsstring *theactivityname = [[nsstring alloc] init]; theactivityname = [[[_activitiesarray filteredarrayusingpredicate:predicatefordisplay] objectatindex:indexpath.row] activityname]; uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; ...

php - Counting the numbers of rows in Zend Framework -

php - Counting the numbers of rows in Zend Framework - in php can utilize function mysqli_stmt_num_rows($stmt) check how much rows there in result set. i wondering, how if using zend framework. i'm trying accomplish check if email existst in database table: customer. i have code. $db = zend_registry::get('db'); $query = "select column1,column2 ". zim_properties::gettablename('customer') ." email = '".$_post['email']."'"; $stmt = $db->query($query); i utilize zend framework 1.8 what did solve problem following. to know more info var $stmt used zend_debug::dump($stmt); it showed: object(zend_db_statement_mysqli)#14 (12) { so went folder "library/zend/db/statement" , , opened file mysqli.php . then checked every method available in class , noticed method rowcount needed one. at controller called rowcount function. $db = zend_registry::get('db'); $query = ...

node.js - Socket.io Chat Tutorial not functioning properly -

node.js - Socket.io Chat Tutorial not functioning properly - so decided give node.js shot. decided go little chat app break ice. tutorial next straight socket.io site. http://socket.io/get-started/chat/ i next tutorial word word , have tried re-create , paste code source , getting no when type in text , send it. supposed coming in command prompt, not. i had user connected , user disconnected messages appear stumped on 1 have followed tutorial step step. index.js var app = require('express')(); var http = require('http').server(app); var io = require('socket.io')(http); app.get('/', function(req, res) { res.sendfile('/chat/index.html'); }); io.on('connection', function(socket){ socket.on('chat message', function(msg){ console.log('message: ' + msg); }); }); http.listen(3000, function() { console.log('listening on *:3000'); }); index.html: <!doctype html> <...

ios - Making a private cocoapod with dependencies on other cocoapods -

ios - Making a private cocoapod with dependencies on other cocoapods - i've read tutorials (some less others), , discovered there huge focus on using pod lib create command , how new cocoapod the podspec repo , available other developers, missing middle part involving setting , developing pod, xcode illustration project, etc.. i'm trying create cocoapod internal utilize has dependencies on other pods. told pod lib create wanted illustration project , need able build , run using pods depends on. i'm not clear on how pods download. understand there podspec syntax specifying dependencies: spec.dependency 'somepod', '~> ver.0' , doesn't much illustration project. am supposed create podfile in folder illustration project? conflict podspec somehow? need include pod i'm making in podfile? should not using illustration project , developing pod in conjunction test project pulls pod in other cocoapod? also, when testing said , done...

VS 2013 Express, working with Unity configuraion, no IntelliSense support -

VS 2013 Express, working with Unity configuraion, no IntelliSense support - how enable intellisense back upwards unity configuration? i did take @ http://msdn.microsoft.com/en-us/library/dn507436(v=pandp.30).aspx , acted accordingly, no luck. why vs not pick http://schemas.microsoft.com/practices/2010/unity xml? visual-studio-2013 unity-container intellisense

Kinect v2 HandState always unknown -

Kinect v2 HandState always unknown - if (body.istracked) { //if (body.handleftstate.equals(handstate.lasso)) //lbhandstate.content = body.handleftstate; // find left hand state switch (body.handleftstate) { case handstate.open: lbhandstate.content = "open"; break; case handstate.closed: lbhandstate.content = "closed"; break; case handstate.lasso: lbhandstate.content = "lasso"; break; case handstate.unknown: lbhandstate.c...

sockets - python `with .. as ..` statement and multiple return values -

sockets - python `with .. as ..` statement and multiple return values - i trying utilize python with-statement (a.k.a. context manager) ensure tcp connection socket created server_socket.accept() closed. obvious form not work because accept() returns multiple values. is there way utilize with-statement functions multiple homecoming values? a minimal illustration below, want utilize commented code replace try/finally block. #!/usr/bin/env python3 import socket socket import socket socket socket(socket.af_inet, socket.sock_stream) server_socket: server_socket.bind(('', 8011)) server_socket.listen(1) print("server ready") while true: # server_socket.accept() (connection_socket, _): # request = connection_socket.recv(1024).decode('ascii') # reply = request.upper() # connection_socket.send(reply.encode('ascii')) try: ...

Sending SMS in iOS with Swift -

Sending SMS in iOS with Swift - first of all, i'm surprised not duplicate, because there tons of stackoverflow questions solve in objective-c, have yet see reply used swift. what i'm looking code snippet in swift sends arbitrary string body of text message given phone number. essentially, i'd this apple's official documentation, in swift instead of objective-c. i imagine isn't difficult, can done in couple of lines of code in android. edit: i'm looking 5-20 lines of swift code, not agree broad. in java (for android), solution looks this: package com.company.appname; import android.app.activity; import android.telephony.smsmanager; public class mainactivity extends activity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); public static final mphonenumber = "1111111111"; public static final mmessage = "hello phone"; smsmanager.getdefault().sendtextmessa...

ruby on rails - Why does 'as_json' return the whole object instead of simple text? -

ruby on rails - Why does 'as_json' return the whole object instead of simple text? - i trying create api sends info ios application using json. my controller has method called `index: def index @news = news.all @banners = news.get_news_banners @news render json: { all_news: @news.as_json( only: [:id, :headline], include: [:thumbnail]), success: true, banners: @banners.as_json } end the news model has method called thumbnail passing json method: def thumbnail image_multimedia = self.multimedia.where(file_type: multimedia.file_types[:picture]).all if image_multimedia.empty? self.banners.last.image_file.url(:preview) else image_multimedia.each |m| m.asset.url(:preview) end end end the json received looks like: { all_news: [1] 0: { id: 4 headline: "some new" thumbnail: [1] 0: { id: 4 server_location: null created_at: "2014-10-14t13:13:33.000z" updated_at: "2014-10-14t13:13:3...

algorithm - Shortest path to connect n points -

algorithm - Shortest path to connect n points - i have n points , need connect of them minimizing final distance. image above represents algorithm in each node connects nearest 1 final output might of. i've been searching lot, know pathfinding algos unaware of 1 solves case. found question on math stackexchange reply not providing algorithm - http://math.stackexchange.com/a/581844/156584. is there algorithm solves problem? otherwise can bruteforce it. edit: clarification regarding result i'm expecting: each node can connected 2 other nodes, creating continuous path (like taking pen , without ever lifting it, connect nodes minimizing final distance). don't want create cycle (that beingness travelling salesman problem). ps: question can translated "complete graph n vertices, , wanting take set of edges such graph connected, sum of border weights minimized" this problem known shortest hamiltonian path problem , np-hard. if number of points s...

Insert Data from a Table in another DataBase - Sql Server -

Insert Data from a Table in another DataBase - Sql Server - insert customersnew (customername, country) select customername, country customersold status='n'; in above case can insert client info table "customersnew" exist in table customersold. these 2 tables in same database how perform same operation if these tables resides in 2 databases. ex table "customersnew" in db_new. table "customersold" in db_old. these 2 databases in 2 different locations.... how access security..(data bases have passwords......) insert db_new.dbo.customersnew(customername, country) select customername, country db_old.dbo.customersold status='n' sql-server sql-server-2008

ruby on rails - validates_length_of with a variable -

ruby on rails - validates_length_of with a variable - i have activerecord model: class message < activerecord::base which has 2 attributes: content (string) , max_content_length (integer) both dynamic , set user. i'm trying validate length of content string using max_content_length integer so: validates_length_of :content, maximum: self.max_content_length or so: validates_length_of :content, maximum: lambda{ self.max_content_length } but validates_length_of throws either "no method found" or "maximum must nonnegative integer or infinity" exception (respectively). is there other way "register" max_content_length function validator length? thank you! (i know question perchance duplicate this question , this one unfortunately answers there little off-topic , confusing) make own validation: class message < activerecord::base validate :validate_content_length private def validate_content_length i...

java - Get the class in which an enum is declared -

java - Get the class in which an enum is declared - this java question regarding enum. i have these classes: class test{ public static enum testenum implements variable{ test_something ; } } class main{ public static void main(string[] args){ //how class object test var? variable var = testenum.test_something; } } so, how class object test variable variable value test.testenum.test_something ? you can utilize reflection so: class<?> testclass = testenum.test_something.getclass().getdeclaringclass(); the phone call getclass() returns class object describing testenum enum, "class" of test_something . ensuing phone call getdeclaringclass() returns test , test class in testenum declared (its declaring class). here finish documentation of java.lang.class , starting point practically reflective operation. java enums

BeautifulSoup html5lib parsing strange phenomenon ..is that a bug? -

BeautifulSoup html5lib parsing strange phenomenon ..is that a bug? - python2.6 + htmllib0.99 + bs4 when run next code throw exception #!/usr/bin/python # -------_*_ coding: utf-8 _*_ bs4 import beautifulsoup import html5lib html = ''' <html> <head> <title> test </title> </head> <body> <div id="tcp">hello</div> </body> </html> ''' cs = beautifulsoup(html,"html5lib") print cs.contents[0].contents[2].contents[1]['id'] main_tag = cs.find('div', id='tcp') print main_tag.text ####result#### #tcp #traceback (most recent phone call last): # file "c:\users\xxxxxxxx\desktop\test.py", line 21, in < # print main_tag.text #attributeerror: 'nonetype' object has no attribute 'text' after removing space between "<title>" , "test" ,the programme run successfully this known bug in bs4. s...

ios - Open Graph Object books.book publishing fails -

ios - Open Graph Object books.book publishing fails - i created object in developer app page , followed code shown in "get code". facebook user login went well, when started post test user account, got "cannot specify type in both path , query parameter" error message. my code: [fbrequestconnection startforuploadstagingresourcewithimage:myimage completionhandler:^(fbrequestconnection *connection, id result, nserror *error) { if (!error) { nsstring *urlofstagedimage = [result objectforkey:@"uri"]; if (urlofstagedimage) { nsmutabledictionary <fbgraphobject> *object = [fbgraphobject opengraphobjectforpostwithtype:@"books.book" title:@"my title" ...

haskell - How do I convert 4 bytes of a ByteString to an Int? -

haskell - How do I convert 4 bytes of a ByteString to an Int? - how can convert bytestring int? i have next 4 bytes want convert (it represents size in bytes of .bmp file): "v\soh\nul\nul" which know equals 374 for binary parsing, have @ binary bundle - http://hackage.haskell.org/package/binary it defines get monad, can write like: data header { ftype :: bytestring, size_ :: word32, reserved_ :: bytestring, offset_ :: word32 } parseheader = ft <- getbytestring 2 size <- getword32le reserved <- getbytestring 4 offset <- getword32le homecoming $ header ft size reserved offset and later: main = bytes <- hgetcontents handle allow header = runget parseheader bytes ... haskell

jquery - How to remove input watermark if the field is not empty? -

jquery - How to remove input watermark if the field is not empty? - i have code add together watermark on input. input page title. works ok. write caption, watermark disappears (that's right). if i'm editing content, title disappears , watermark again. why watermark returns when input field contains content? <script type="text/javascript"> $(document).ready(function() { var watermark = 'write city + state (separated commas)'; //init, set watermark text , class $('#edit-title').val(watermark).addclass('watermark'); //if blur , no value inside, set watermark text , class again. $('#edit-title').blur(function(){ if ($(this).val().length == 0){ $(this).val(watermark).addclass('watermark'); } }); //if focus , text watermrk, set empty , remove watermark class $('#edit-title').focus(function(){ if ($(this).val() == watermark){ $(t...

hadoop - Reducer is not being called -

hadoop - Reducer is not being called - this code ebola info set. here reducer not beingness called @ all. mapper output beingness printed. the driver class: import org.apache.hadoop.conf.configuration; import org.apache.hadoop.fs.path; import org.apache.hadoop.io.text; import org.apache.hadoop.mapreduce.*; import org.apache.hadoop.mapreduce.lib.input.fileinputformat; import org.apache.hadoop.mapreduce.lib.input.keyvaluetextinputformat; import org.apache.hadoop.mapreduce.lib.output.fileoutputformat; import org.apache.hadoop.mapreduce.lib.output.textoutputformat; public class ebola { public static void main(string[] args) throws exception , arrayindexoutofboundsexception{ configuration con1 = new configuration(); con1.set("mapreduce.input.keyvaluelinerecordreader.key.value.separator", " "); job job1 = new job(con1, "ebola"); job1.setjarbyclass(ebola.class); ...

How do I prevent Maven from downloading metadata for an artifact that I already have in my repo? -

How do I prevent Maven from downloading metadata for an artifact that I already have in my repo? - i’m using maven 3.2. have dependency in pom.xml file (a war project) <dependency> <groupid>joda-time</groupid> <artifactid>joda-time</artifactid> <version>1.6.2</version> <scope>provided</scope> </dependency> whenever run phase pom (e.g. “mvn install”), app attempts download metadata dependency … downloading: http://repo.spring.io/milestone/joda-time/joda-time/maven-metadata.xml how tell maven stop doing that? have artifact cached in local maven repo. thanks, - dave maybe update policies need specified explicitly. see answer: why maven downloading metadata every time? <pluginrepositories> <pluginrepository> <id>central</id> <url>http://gotonexus</url> ...

regex - Regular expression to filter URLs? -

regex - Regular expression to filter URLs? - i need filter specific urls using regex in google analytics. should filter below format urls urls recorded: /job/41-content-verification?action=register /job/62-data-verification?action=register /job/33-data-entry?action=register like starts '/job/' 'some string/data' , ends '?action=register' i need regex set in google analytics filter. please help. try this: ^/job/.+?\?action=register$ regex google-analytics

android - Is calling a script in unityscript slow? -

android - Is calling a script in unityscript slow? - my enemy script linked prefab , beingness instantiated main script. it kills enemies in random order (i jumping on them , not dying, not want). (what trying accomplish enemy die when jump on head , play death animation. enemy script phone call other script jump <-- linked player script , jump boolean value. processing of jump slow? need help tried everything) works on enemies ideas why? community. can help me find improve method? could help me maybe find if players y => amount alter jump var on enemy just had perfect run, whats wrong working not partly working if add together audio, doesn't work. #pragma strict var enemy : gameobject; var speed : float = 1.0; var enemanim : animator; var isdying : boolean = false; private var other : main; var playerhit: boolean = false; function start () { other = gameobject.findwithtag("player").getcomponent("main"); this.transform.po...

Laravel Mail: Undifine variable $data -

Laravel Mail: Undifine variable $data - my controller generates info array: array ( [bothweek] => array ( [0] => 2014-10-26 [1] => 2014-10-19 ) [projects] => array ( [0] => stdclass object ( [day_name] => quarta-feira [project_date] => 2014-10-22 [invoiced_date] => 2014-10-31 [week_end_day] => 2014-10-26 [user_name] => john ) ) ) but when seek send mail service blade, not recognize array, can please give me solution, give thanks you, mail::send('project.mail', $data, function ($message) { $message->from('email', 'abc'); $message->to('send'); }); if want $data accessible in view file project.mail need utilize ['data' => $data] sec argument, otherwise 2 variable...

mysql - How to solve Notice: Undefined index: id in C:\xampp\htdocs\invmgt\manufactured_goods\change.php on line 21 -

mysql - How to solve Notice: Undefined index: id in C:\xampp\htdocs\invmgt\manufactured_goods\change.php on line 21 - this question has reply here: php: “notice: undefined variable” , “notice: undefined index” 14 answers i have problem php code saying "notice: undefined index" sure simple, since beginner not getting wrong please help me. here's code <?php require_once('../connections/itemconn.php'); ?> <?php $id=$_get['id']; $query=mysql_query("select * manuf id='$id' ")or die(mysql_error()); $row=mysql_fetch_array($query); ?> <form action="updateprice.php" method="post" enctype="multipart/form-data"> <table align="center"> <tr> <td> <label><strong>item name</strong></label...

android - How to pin a ParseObject with a ParseFile to the Parse Local Datastore in OFFLINE? -

android - How to pin a ParseObject with a ParseFile to the Parse Local Datastore in OFFLINE? - i using next code store parseobject parsefile. have enabled parse local datastore in application subclass. code storing instance of parseobject in local datastore , in parse server when application in connected internet. final parsefile file = new parsefile(position + ".mp4", data); file.saveinbackground(new savecallback() { @override public void done(parseexception e) { parseobject po = new parseobject("recordings"); po.put("code", position); po.put("name", myname); po.put("file", file); po.saveeventually(); } }); same code when app not connected net throwing next exception. java.lang.illegalstateexception: unable encode unsaved parsefile. , app crashing. object not stored in local datastore. so how can store parseobjec...

html - Horizontal scrollbar appearing on display: table element -

html - Horizontal scrollbar appearing on display: table element - i have simple page layout this: css: html, body { height: 100%; margin: 0; padding: 0; } .table-wrapper { display: table; width: 1366px; height: 100%; } .cell-left { display: table-cell; width: 240px; } .cell-right { display: table-cell; width: 1126px; } html: <div class="table-wrapper"> <div class="cell-left"></div> <div class="cell-right"> /* long content */ </div> </div> when content in .cell-right becomes long plenty browser display vertical scrollbar adds horizontal scrollbar ruins layout. problem goes away if set 100% width on .table-wrapper shrinks both cells not want. must have fixed widths on 3 elements proper tweaks responsive design project requires. both cells need span across document height. funny thing net explorer 11 not have problem both firefox , chrome d...

c# - PrincipalSearchResult with PrincipalSearcher FindAll, why does T have to be Principal and not UserPrincipal -

c# - PrincipalSearchResult<T> with PrincipalSearcher FindAll, why does T have to be Principal and not UserPrincipal - i'm curious: list<string> adusers = new list<string>(); using (principalcontext principle_context = new principalcontext(contexttype.domain, "mydomain")) using (userprincipal user_principal = new userprincipal(principle_context) { enabled = true, name = "*", emailaddress = "*" }) using (principalsearcher user_searcher = new principalsearcher(user_principal)) using (principalsearchresult<principal> results = user_searcher.findall()) { foreach (principal p in results) { adusers.add(p.name + " " + ((userprincipal)p).emailaddress); } } ...is there way avoid having cast results here? wanted like: using (principalsearchresult<userprincipal> results = user_searcher.findall()) ...so search result of type needed it, seems findall method allows using <principal> ...

regex - Calling Ant ReplaceRegexp from TeamCity with strings including quotes and equalsigns -

regex - Calling Ant ReplaceRegexp from TeamCity with strings including quotes and equalsigns - i have ant file contains targets used teamcity configs. have target defined uses replaceregexp: <replaceregexp file="${targetfile}" match="${originalstring}" replace="${updatedstring}" byline="true" /> i need replace string in targetfile includes set of doublequotes; specifically, need replace minlevel="trace" minlevel="warn". in teamcity phone call antfile following: -doriginalstring=minlevel="trace" -dupdatedstring=minlevel="warn" but ignores doublequotes. i'm sure there's combination of escape characters i'm not understanding. right way phone call teamcity? thanks- try enclosing property values in double quotes, , escape literal quotes backslashes. -doriginalstring="minlevel=\"trace\"" -dupdatedstrin...

php - Keep getting Fatal error: Call to undefined method DB::prepare() -

php - Keep getting Fatal error: Call to undefined method DB::prepare() - that's response reflection::export(new reflectionclass($this)); class [ class users extends crud ] { @@ c:\xampp\htdocs\classes\users.php 5-76 - constants [0] { } - static properties [0] { } - static methods [0] { } - properties [7] { property [ protected $table ] property [ private $username ] property [ private $email ] property [ private $password ] property [ private $passwordrepeat ] property [ private $nickname ] property [ private $permission ] } - methods [20] { method [ public method setusername ] { @@ c:\xampp\htdocs\classes\users.php 15 - 17 - parameters [1] { parameter #0 [ $username ] } } method [ public method setemail ] { @@ c:\xampp\htdocs\classes\users.php 19 - 21 - parameters [1] { parameter #0 [ $email ] } } method [ public method setpassword ] { @@ c:\xampp\htdocs\classes\users.php 23 - 28 - parameters [2...

java - How do i input all the values from one array into random indexes of another array? -

java - How do i input all the values from one array into random indexes of another array? - i cant figure out how input money amounts,which stored in array (case_value), other array, (cases).i trying randomly. programme run never finishes. have far. in case couldn't guess, trying re-create format of deal or no deal. also, if there way create code more efficient, appreciate it. give thanks help. import java.util.scanner; import java.lang.math; public class dond { public static void main (string [] args) { scanner sc = new scanner (system.in); int [] cases=new int [26]; //array cases int [] case_value=new int [26]; //array money amounts int b=0; case_value[0]=1; // money amounts case_value[1]=2; case_value[2]=5; case_value[3]=10; case_value[4]=25; case_value[5]=50; case_value[6]=75; case_value[7]=100; case_value[8]=200; case_value[9]=300; case_value[10]=400; case_value[11]=500; case_value[12]=750; case_value[13]=1000; case_value[14]=5000; case_value[15]=10000; case_valu...

Email intent no longer working in Android Lollipop -

Email intent no longer working in Android Lollipop - i have been using below code start intent in android send email. prior android lollipop (api level 21) worked fine. unfortunately, in android lollipop, throws "unsupported action" error. intent intent = new intent(intent.action_sendto); intent.settype("message/rfc822"); intent.setdata(uri.parse("mailto:" + email)); startactivity(intent); it's pretty basic, passes e-mailaddress , lets user pick application use. how should adapt code create work across api levels? minimum api level 16 (jellybean). edit i've included mime-type, per comments , answers. i've got it. caused not having set emailaccount. after setting 1 in @ to the lowest degree 1 email app, works. it's not problem lollipop. android android-intent android-5.0-lollipop

Php array string or var string? -

Php array string or var string? - i've been wooking strings in php create own framework... there's "bothers" me. $var = "hello!"; $arr = array("h","e","l","l","o","!"); can tell me 1 ( $var or $arr ) uses more memory other one? , why? at first sight array utilize more memory since has position each character within array itself, i'm not sure. the array utilize more memory string a string , array zval structures in own right, each element in array string well, each own zval; arrays take surprising amount of memory. there fact array element comprises both key , value, each using memory take read of article see how much memory used array structure php arrays string var

objective c - How to close connection on Mailcore2? -

objective c - How to close connection on Mailcore2? - i see mailcore2 has like: [_session disconnectoperation] but not know how implement that. how can disconnect server (close connection)? and found it: [_session.disconnectoperation start:^(nserror * error){}]; objective-c xcode mailcore2

Delphi 7: create a new instance of an unknown object -

Delphi 7: create a new instance of an unknown object - i have tobject reference instance of unkown class. how phone call constructor of unknown class create instance of it? know delphi has rtti, isn't clear how utilize it. you can't build object of unknown type. compiler has know right class type @ compile-time can generate proper code. if constructor requires parameters? how many? info types? passed stack or registers? info important. that beingness said, if classes in question derived mutual base of operations class has virtual constructor, , can build such objects. can utilize tobject.classtype() method reference class type of existing object, type-cast base of operations class type, , phone call constructor. example: type tbase = class public constructor create(params); virtual; end; tbaseclass = class of tbase; tderived1 = class(tbase) public constructor create(params); override; end; tderived2 = class(tbase...

Server side Firebase listeners with load balancing -

Server side Firebase listeners with load balancing - if want utilize firebase on server side, in place of rest routes using express , node.js, how go dealing scaling , load balancing? example, if have express app uses firebase on server side, every single server spins contain these listeners , react them? there scale-able solution using firebase on server-side elastic load balancing in mind? i think question broad in current form, give @ to the lowest degree few (equally broad) options. there dozens of solutions possible, of them variations on these 2 broad scenarios: centralized vs decentralized. you can utilize centralized authority, assigns each task 1 of worker nodes. load balancer does, might want search load balancing algorithms. alternatively can have each node seek claim work. nodes should utilize transaction update "work queue", 1 node ends doing work. related: https://github.com/firebase/firebase-work-queue firebase load-balancing ama...

paypal lightbox does not work in IE -

paypal lightbox does not work in IE - i using paypal lightbox login in web site. works fine in chrome , firefox. in ie, doesn't work. page loading long time. please allow me know solution resolve it. paypal

javascript - Getting button click event handler to fire more than once -

javascript - Getting button click event handler to fire more than once - i have quantity of rows: var goal_index = 2; and have function, create rows (default 2 rows) 2 buttons: trash (remove row), add(adding anoter row). // creating goals var goals_creating = function(){ var goals_area = $('.goalsarea'), add_button = $('<span class="add_btn"></span>'), trash_button = $('<span class="trash_btn"></span>'); goals_area.html(''); for(var = 0, j = 1; < goal_index; i++, j++ ){ goals_area.append( '<div class="row" data-trashgoal = ' + + '>' + '<div class="col-lg-1">' + '<span class="trash_btn" data-trashgoal = ' + + '></span>'...

python - Text box entry in a GUI -

python - Text box entry in a GUI - for class coding little chess simulator gui using python. come in move have text box can type in, , 1 time press btn move, moves piece. currently have gui radio buttons each piece. under function btn move them have: if btn == 4: cmds.select('a4') cmds.move() i not know how write code simple text box in gui or propper code reference text box is. q: how code simple working text box, , how write code functions can reference gui. can create text box using textfield command. create typical textfield command: my_textfield = cmds.textfield() in maya, every ui element has unique identifier name string. when phone call textfield command in create mode, homecoming name of textfield created. here, my_textfield python variable contains name of created textfield can refer later. access text value of textfield like: text_entered = cmds.textfield(my_textfield, query=true, text=true) here, access text entered in ...

php - Can Look-up Array be Stored Outside Class? -

php - Can Look-up Array be Stored Outside Class? - i'm starting larn oop , converting little existing site in process. have big global array ($countries) store country code, name in 2 different languages, , international calling code 240 countries. want create class (country) methods values $countries. need store array within class, or can store in separate file? if can set in separate file, how access in methods? yes, homecoming array file, , utilize like: $array = include('file.php') http://php.net/manual/en/function.include.php file.php <?php homecoming array( 'name' => 'josh smith' ); index.php <?php $arr = include('file.php'); var_dump($arr); class whatever class whatever { public function getcountries() { $arr = include('file.php'); homecoming $arr; } } $what = new whatever(); $c = $what->getcountries(); var_dump($c); php oop

php - stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection refused) -

php - stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection refused) - i made php file sending notification apple iphone users. working other server not working in server. have made .pem file accurately , opened port number 2195,2196. still not working. please help me out rid of issue. here php code sending force notification: <?php // set device token here (without spaces): $devicetoken = 'f672c26cbfb279e45c1b66d0ddb738d8043c785d5bb8dd20a72d52ae88d4a604'; // set private key's passphrase here: $passphrase = 'pushchat'; // set alert message here: $message = 'welcome in testing'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); // open connection apns server $fp = stream_socket_client( 'ssl://gateway.sandbox.push.apple.com:2195', $err,...

What type of design patterns do you use regularly? -

What type of design patterns do you use regularly? - what type of design patterns utilize regularly? i'm trying thought of how formal people code. factory, builder, strategy patterns, etc. thanks! i utilize of gof patterns on regular basis. i've had implement of them @ to the lowest degree 1 time in course of study of career. languages , libraries written since gof published incorporate several patterns apis. java has observable, iterators , proxies example. almost of code makes utilize of factories, builders, strategies, adapters, decorators etc. complex has in order maintain maintainable , extendable. i recommend reading holub on patterns author writes 2 programs utilize gof patterns together. shows how patterns work together. design-patterns

notifications - Parse : [PFInstallation currentInstallation] returns null -

notifications - Parse : [PFInstallation currentInstallation] returns null - i have been revolving around issue long time couldn't relevant solution this.i intended send force notification device within miles (miles decided user). utilize next code on click of button, working fine before came across pathetic problem. if (setmiles == 0) { uialertview *alert = [[uialertview alloc]initwithtitle:@"broadcast alert" message:@"please select broadcast range" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles: nil]; [alert show]; } else { pfinstallation *installation = [pfinstallation currentinstallation]; nslog(@"%@",installation); [pfgeopoint geopointforcurrentlocationinbackground:^(pfgeopoint *geopoint, nserror *error) { if (!error) { pfquery *userquery = [pfinstallation query]; [userquery wherekey:@"...

Exception Handling on methods C# -

Exception Handling on methods C# - let's suppose have next code... try { await task.run(() => autobuyandsell.discard_players(client, this)); if (stop == false) { await task.run(() => autobuyandsell.buy_300_players(client, this)); } } grab (expiredsessionexception ex) { relogin = true; b_stop.performclick(); } inside autobuyandsell expiredsessionexception can occur phone call methods can throw exception. question is, need add together try/catch block within function or it's plenty handle extern exception? answer accepted: as need of programme exit method , restart variables, eventually, decided utilize try/catch outside method. you grab them have won't "know" if/how much of discard_players or buy_300_players code executed, , @ point exception occurred, etc. may bad idea. for illustration if these methods persist state disk/database wont "know" if happened or not. (i maintain ...

android - Issue positionning customLinear Layout -

android - Issue positionning customLinear Layout - i've created custom linear layout in order have "square" layout fitting width of parent i'm having problem positioning linearlayout. want linearlayout below squarelinearlayout , got (both layout top aligned): i've tried android:parentalignbottom="true" , android:gravity="bottom" nil works me ... here layout xml : <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.dekajoo.rpg.main...

php - Caching relationships eager loaded in the model (protected $with) with Laravel and Eloquent -

php - Caching relationships eager loaded in the model (protected $with) with Laravel and Eloquent - in article model eager load category relationship within model: protected $with = array('category'); when articles in controller cache results of both articles , relationships eager load there: $articles = article::with([ 'owner' => function ($q) {$q->remember(10);}, 'tags' => function ($q) {$q->remember(10);}, 'thumbnail' => function ($q) {$q->remember(10);} ]) ->remember(10)->get(); but; article.category not cached. thought cached article model, since eager loaded in model. not happen. it cached if eager load (with cache) in controller adding article::with : 'category' => function ($q) {$q->remember(10);} i know can remember() relationship itself: public function category() { homecoming $this->belongsto('category', 'category_id')->remember(10);...

ios - UICollectionView not loading programatically -

ios - UICollectionView not loading programatically - i trying hook uicollectionview in application , see black screen every time load it. below code have written: caller code: uicollectionviewflowlayout *flowlayout = [[uicollectionviewflowlayout alloc] init]; [flowlayout setitemsize:cgsizemake(200, 200)]; [flowlayout setscrolldirection:uicollectionviewscrolldirectionhorizontal]; myappdashboardhomeviewcontroller *adashboardviewcontroller = [[myappdashboardhomeviewcontroller alloc] initwithcollectionviewlayout:flowlayout]; [self presentviewcontroller:adashboardviewcontroller animated:yes completion:nil]; uicollectioncontroller sub class #import <uikit/uikit.h> @interface myappdashboardhomeviewcontroller : uicollectionviewcontroller <uicollectionviewdelegate, uicollectionviewdatasource> @end #import "myappdashboardhomeviewcontroller.h" #import "myappdashboardcollectionviewcell.h" #import "myappcustomnavigationbar...

asp.net mvc - Mail Settings for SendGrid using AppHarbor -

asp.net mvc - Mail Settings for SendGrid using AppHarbor - i'm trying set email sending asp.net mvc4 project using sendgrid , appharbor. know appharbor injects relevant smtp configuration in application's configuration, want send email locally testing. hence need know right mailsettings manually add together these settings application. here have far: <network host="smtp.sendgrid.net" port="587" enablessl="true" defaultcredentials="false" password="xxxx" username="xxx@apphb.com"></network> i maintain getting error "failure sending email". copied username sendgrid account, i'm not sure utilize password. you can find password here: https://appharbor.com/applications/name_of_your_app/configurationvariables here can find on menu: http://www.screencast.com/t/iealay3d8 asp.net-mvc asp.net-mvc-4 email appharbor sendgrid

java - Prevent components inside jscrollpane from extending past horizontal edge -

java - Prevent components inside jscrollpane from extending past horizontal edge - in project i'm doing have set of jtextpane's wrapped in jpanels within jframe. jtextpane's can various sizes when programming running, , size cannot predicted, unless hardcoded. create sure of jtextpane's (which within jpanels) viewable, have set in scroll pane. here's catch: i want jtextpane's extend past bottom of jscrollpane if needed, don't want them extend past side. want jpanels/jtextpanes take much space possible horizontal, without requiring utilize of horizontal scroll bar. means if window resized horizontally, jtextpanes need resize fill horizontal space. jtextpanes wrapped first in panel uses "grouplayout" supplied netbeans gui builder, , in panel uses boxlayout. reason boxlayout add together new elements (jtextpane's wrapped in panel), via code. much easier using boxlayout. i tried setting prefferred width of jtextpane's integer.max_v...