Posts

Showing posts from August, 2012

android - Activity to listen to Intent ACTION_VIEW -

i want open custom activity in setmovementmethod below. textview tx = (textview)findviewbyid(r.id.txthelp); tx.settext(html.fromhtml(getstring(r.string.help))); tx.setmovementmethod(linkmovementmethod.getinstance()); i have html defined links when clicked/pressed, want activity open displaying image(depending on clicked link) i have looked @ thread handle textview link click in android app , tried follow answer used. here activity in manifest defined listen intent action.view. <activity android:name="com.example.metermanager.imagesactivity" android:screenorientation="portrait"> <intent-filter> <category android:name="android.intent.category.default" /> <action android:name="android.intent.action.view" /> <data android:scheme="com.example.metermanager" /> </intent-filter> here activity code. package com.example.metermanager;

how to iterate on array[...][i] (columns) in java -

there easy way access rows of 2d array in java for (int = 0 ; < integer2d.length ; i++) getmyarray(integer2d[i]); but, searched in web find such easy way iterate on columns of 2d-array, like for (int j = 0 ; j < integer2d[0].length ; j++) getmyarray(integer2d[][i]); or for (int j = 0 ; j < integer2d[0].length ; j++) getmyarray(integer2d[...][i]); which works in programming languages. found class realmatrix , matrixutils can convert array2d real matrix , transpose , again convert array , iterate on it. suppose there exist simpler way? edit: iterating on rows noted in first piece of code easy main question how iterate on columns second , third codes work in other programming languages. edit2: mentioned in last paragraph of main question, easiest way know transposing matrix , iterating on rows. for this, can use bigmatriximpl class of commons math library . has getcolumnasdoublearray() method return specified column array.

symfony - symfony2 verbose formatter, adding the line number and the file name to the logged message -

i need add data logger, i'd add file name , line logger called from. have create custom class or file name , line sent somewhere within predefined loggers? works now!! both custom processor , custom formatter have added.

nswindow - How can I set the title of non-main-windows in an NSDocument application? -

i working on document-based osx application, master-detail style windows. understand how open additional windows, display additional information, using -makewindowcontrollers , adding window controllers, can't set title of new windows. have tried using -settitle , -windowtitlefordocumentdisplayname in both document.m , in sub-classed window controller class, can't window title change. how change title of non-main-windows, have sub-classed window controller, in nsdocument based application? edit: know there suggestions on using iboutlet window this, surely window controller has reference window anyway, right?

delphi - Need example for for WM_MouseWheel -

my control(like tmemo) has not mousewheel code. how add correct wheel handler scrolls correct num of lines - if controlpanel has set 3 lines per rotate, need 3 lines scroll 1 rotate. my test is procedure tmymemo.wmmousewheel(var message: twmmousewheel); var delta: integer; begin delta:= message.wheeldelta div 80 * mouse.wheelscrolllines;//?????? scrollposy := scrollposy - delta; message.result := 1; end; i don't think 80 ok, it's guessed- works here (with win7). how correct num of lines scroll? i found ok way. need write protected methods: domousewheelup.....; override; domousewheeldown......; override; and in each, must scroll delta= mouse.wheelscrolllines .

linux - ssh to ubuntu server, /bin/bash: Exec format error -

when trying ssh webserver, connection opens , closes following error /bin/bash: exec format error connection ip.ip.ip.ip closed. ubuntu 12.04.4 lts (gnu/linux 3.8.0-29-generic x86_64) any ideas how fix this?

cocoa - Animating NSTabView Views -

i trying animate each view of nstabview slide in when view selected. have working in fashion, animates first time select new tab view. after not see animation when switching tab views, although can see the function fired every time.? override func tabview(tabview: nstabview, didselecttabviewitem tabviewitem: nstabviewitem) { tabviewitem.view!.setframeorigin(nspoint(x: tabviewitem.view!.frame.origin.x + 300, y: tabviewitem.view!.frame.origin.y)) tabviewitem.view!.animator().setframeorigin(nspoint(x: tabviewitem.view!.frame.origin.x - 300, y: tabviewitem.view!.frame.origin.y)) // can see fires every time switch tab views animation works fist time } i have changed little solve first time problem. define integer store previous tab index in delegate. - (void)tabview:(nstabview *)tabview didselecttabviewitem:(nstabviewitem *)tabviewitem{ cabasicanimation *controlposanim = [cabasicanimation animationwithkeypath:@"position"]; if (prevtabviewindex

php - How to join N regex patterns into one -

i have few patters these: $confirm = '~/[a-z][a-z]/confirm\?hash=[0-9a-za-z]+~u'; $letter = '~/[a-z][a-z]/letter/[0-9a-za-z]+~u'; $tracker = '~/[a-z][a-z]/(tracker\?hash)=[0-9a-za-z]+~u'; preg_match($confirm, $text); they work fine. how can join these 3 patterns one? have tried | conditional, it's not working. i need like: preg_match ($confirm or $letter or $tracker, $text) if match found ok you try put 3 patterns one: $pattern = '~/[a-z][a-z]/(confirm\?hash=|letter|tracker\?hash=)[0-9a-za-z]+~u'; preg_match($pattern, $text);

mysql - Magento store broken after moving to other folder -

i had move magento store folder on same server. did couple of times , worked fine, last time didn't. site loads broken, there's dash missing in middle of links. can't login through /admin, cause page broken. the thing remember doing differently turned compilation , css merging on before moving files. the store @ http://www.atelieminimalista.com.br/loja/ and, can see, css , images don't load , links weird, dash missing. database definitions fine guess, changed secure , unsecure link. if go admin, it's weird. i tried check htaccess, deleted cache, seems fine. you'll want manually flush cache var/cache/ directory , remove compiled code in includes/src/ directory or disable compiler (edit file includes/config.php , comment out both 'define' lines).

pascal - How to write events of "fastreport band" in delphi code -

Image
i have masterdata band in fastreport. can write code on "masterdata after print" in pascal script, want know there way write code in main delphi form. pascal script: procedure masterdataonafterprint(sender : tfrxcomponent) begin sup_page.text := 'cont on page ' + inttostr(<page> + 1); end; you have different options interfer report while printing. might use events afterprint and/or beforeprint provide component parameter every time printed. if want access component 1 provided in events, can use findcomponent delivering component page printed. access functions within report can call calc functions name parameter . other option depending on demands use getvalue event which, called every time variable evaluated, providing name of variable , var parameter value, enable return value like. short example might useful: procedure tformordm.frxreport1afterprint(sender: tfrxreportcomponent); begin // if sender tfrxmasterdata // filter ou

phpunit - Models unit testing on Yii2 -

i'm trying build yii2 app through unit testing , have questions it. class userstest extends \codeception\testcase\test { /** * @var \unittester */ protected $users; protected function _before() { $this->users = new \app\models\users; } protected function _after() { } // tests public function testgeid() { } } when try run test class have fatal error message users class not found. cause of problem , how solve it? there readme file in yii2 tests folder tell setup yii2-faker , yii2_basic_tests database. these 2 things , why should use them? thank you. it need create application instance in tests/_bootstrap.php. must following code in file: require('/../vendor/autoload.php'); require('/../vendor/yiisoft/yii2/yii.php'); $config = require('config/web.php'); (new yii\web\application($config));

multithreading - how to get frames from video in parallel using cv2 & multiprocessing in python -

i've been working cv2 & multiprocessing in python, , have working script stuff individual frames once in input queue. however, wanted speed getting frames queue in first place using multiple cores, tried use same multiprocessing approach read each image queue. can't seem work though, , i'm not sure why. thought maybe because trying write 1 queue, split up, i'm wondering if it's because i'm trying read same video file @ same time. here hoping accomplish in pseudocode: for process in range(processcount): start process this: frame in range(startframe,endframe): set next frame startframe read frame add frame queue here current code. i've tried using pool & separate processes, i'm sticking separate processes because i'm not sure if problem queue management. if call getframe manually, right stuff queue, think function works okay. i'm sure i'm doing silly (or odd). can suggest solut

Do compiled C++ binaries store the original source code? -

when run c++ code, , receive error, manages print out exact line in particular source file on error occurred. great debugging, believe program running built in release mode. questions is, programs built in release mode store original source c++ code, references in compiled binary? seems inefficient way create binary if distributed consumers, rather developers. i never saw "mainstream" c++ compiler store original source. when see references source, typically boils down 1 of tricks: references source file/line: these created via macros. logging libraries provide macro includes in bowels __file__ , __line__ macros, which, at compile time , expands current file , line; macros __function__ common extension; expressions in failed asserts: assert macro (and similar beasts) not uses __file__ , __line__ , stringifies (again, @ compile time) given expression, show when assert fails; names of classes in executable: if enable rtti, compiler has store somewhere nam

Java extract integers from a string containing delimiters and range symbols -

is there library can me split string integers delimiters , range marks? instance values="32,38,42-48,84" output: int[] = 32,38,42,43,44,45,46,47,48,84 if want whole range (from 42-55 example), i'm not entirely sure, can use regular expressions find that's not number . expression "[^0-9] use replace , change character (e.g commas). split commas. feel free read more here: http://www.vogella.com/tutorials/javaregularexpressions/article.html (note: i'm not related in way vogella. liked tuto :) edit: can see output want (which believe wasn't there). if that's want, find split commas first. after, check if have elements in have symbol (- example), , if so, split , use numbers create range. here's example of working code: public static void main (string[] args) throws java.lang.exception { // code goes here scanner scan = new scanner(system.in); string s = scan.nextline(); string[] splitted = s.split(","

c# - Managed Bootstrapper initializing progress indicator -

our bootstrapper consuming burn of 70mb, containing net framework 4, vc runtimes , 2 more pre-requisites + product.msi itself. whenever execute network location, took longer time execute (last time 40 seconds . suspect such delay due extraction of files in local temp folder before displaying first ui. so can override event in managed bootstrapper show message or progress bar while initializing itself? or how display progress bar while extracting packages whenever execute burn exe package? thanks bunch... assuming you're using custom managed bootstrapper application, there's not way show progress bar during extracting phase. however, can show static splash screen. this, you'll need add bitmap (.bmp) file bootstrapper project content build action , copy output folder set 1 of copy options. then, in bundle.wxs file, include splashscreensourcefile attribute: <bundle name="my cool product" version="1.0.0" upgradecode=&q

php - CakePHP, triple equal signs misunderstanding -

hi i'm making tutorial cakephp , got stuck when @ if statement. please @ if statement triple equal signs. class item extends appmodel{ protected function _processfile(){ $file = $this->data['item']['file']; if($file['error'] === upload_err_ok){ $name = md5($file['name']); $path = www_root.'files'.ds.$name; if(is_uploaded_file($file['tmp_name']) && move_uploaded_file($file['tmp_name'],$path)){ $this->data['item']['title_img'] = '/files/'.$name; unset($this->data['item']['file']); return true; } } return false; here question why if statement when makes error uploading file executes rest of codes upload file? should rest of codes placed @ "return false;"? please let me know missed understand if statement. thank guys this basic php , not relat

java - Implementation of switch case for check box -

Image
is there way implement switch case checkbox? example: have 4 checkboxes, if selected 2 checkboxes, how trigger case output want? double exam = 0.0, assign = 0.0, quiz = 0.0, ct = 0.0; if (examchkbox.isselected()) { exam = double.parsedouble(examtextfield.gettext()); } if(ctchkbox.isselected()) { ct = double.parsedouble(cttextfield.gettext()); } if(quizchkbox.isselected()) { quiz = double.parsedouble(quiztextfield.gettext()); } if(asschkbox.isselected()) { assign = double.parsedouble(asstextfield.gettext()); } if (!(exam + ct + quiz + assign == 100)) { markerrorlbl.settext("total marks must 100"); } else { // implementation of code here } design view. let ticked ex

html - How can I improve cross browser compatibility of my CSS only slider menu? -

Image
i have css menu, background must slide animation selected menu item: .wrapper { font: 0/0 a; position: relative; white-space: nowrap; } .radio { -webkit-appearance: none; color: rgb(0, 0, 0); margin: 0 10px 0 0; outline: 0; padding-bottom: 10px; padding-top: 10px; position: relative; text-align: center; transition: color .5s linear; z-index: 2; } .radio:after { content: attr(data-text); } .radio:checked { color: rgb(255, 255, 255); } .bg { background: black; border-radius: 10px; bottom: 0; position: absolute; top: 0; transition: left .25s linear; z-index: 1; } .radio, .bg { width: 100px; } .radio:checked + .radio + .radio + .radio + .radio + .bg { left: 0; } .radio + .radio:checked + .radio + .radio + .radio + .bg { left: 110px; } .radio + .radio + .radio:checked + .radio + .radio + .bg { left: 220px; } .radio + .radio + .radio + .radio:checked + .radio + .bg { left: 330px;

android - Regarding layout weight and margins -

why when set attribute layout_marginstart="130dp" of button whole upper edittext shifts accordingly? 2- i'm planning have screen divided 4 sections, total weight = 9 , sections 1,2,3,4 should has 2/9,2/9,4/9,1/9 accordingly. please let me know if need modify something. xml : <linearlayout 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:orientation="vertical" android:weightsum="9" tools:context="${relativepackage}.${activityclass}" > <tablelayout android:id="@+id/table_0" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="4"> <tablerow android:id="@+id/row0" android:layout_width="match_parent" andr

Rails attributes not being saved -

when trying save new entity ( vote ) ajax calls, attributes not being assigned. class , method being used: class votecontroller < applicationcontroller respond_to :json def vote question_id = params[:question][:id] user_id = current_user.id vote = vote.where(["question_id = :q", { q: question_id }]).where(["user_id = :u", { u: user_id }]).take respond_with |format| if vote.nil? @vote = vote.new @vote.question = question_id @vote.user = user_id @vote.save format.json { render :json => { :status => 'ok' } } else format.json { render :json => { :status => 'failed', :msg => 'you voted' } } end end end end the model: class vote < activerecord::base belongs_to :user belongs_to :question attr_accessor :user, :q

java - Modifying all the string primitives in a JSON structure -

in java, given textual representation of json object, how can apply function leaves strings? for example, converting string values upper case: input: { "name": "john", "address": { "street": "elm", "number": 4 }, "children": ["george", "paul"] } output: { "name": "john", "address": { "street": "elm" "number": 4 }, "children": ["george", "paul"] } use gson (or other json parser) parse data map , remove non strings, serialize json using gson

sql - Only want the first if several matches are returned -

Image
i have sql script returns number of records. code: select distinct eb.exerciseindex, eb.exercisestarttime, avg(pb.playerbirthyear) birthavg, count(pb.playerindex) playersinexercise, pb.playersex playerbase pb inner join exbase ex on ex.explayerindex = pb.playerindex inner join exercisebase eb on eb.exerciseindex = ex.exexerciseindex exerciseallowanceindex='b26e10c5-53e1-413a-8a49-a7088d33e690' , exercise_is_paying='true' group exercisestarttime, pb.playersex, eb.exerciseindex order exerciseindex, playersinexercise desc i have attached image results. now, want kind of distinct on results. if note, on occasions several rows returned same exerciseindex (see row 1 , 2 example). need first row exerciseindex returned (the 1 higher playercount). any ideas how can done? regards, bob you should neat little so-called window function called row_number . using this, like: select * ( select *, row_number() on (partition exerciseindex orde

mysql - Cake php join query -

i have write join query in cake php 1.3. $supportbooks=$this->supportbook->find('all',array('joins'=>array( array( 'table'=>'supportbookstatuses', 'alias'=>'supportstatus', 'conditions' =>array('supportstatus.unique_id=supportbook.`unique_key`') ) )),array('conditions'=>array('supportbook.user_id'=>$user_id))); this return following query: select `supportbook`.`id`, `supportbook`.`category`, `supportbook`.`user_id`, `supportbook`.`email`, `supportbook`.`subject`, `supportbook`.`message`, `supportbook`.`reply`, `supportbook`.`unique_key`, `supportbook`.`replied` `fl_supportbooks` `supportbook` join `fl_supportbookstatuses` `supportstatus` on (`supportstatus`.`unique_id`=`supportbook`.`unique_key`)

batch file - Slow performance in spark streaming -

i using spark streaming 1.1.0 locally (not in cluster). created simple app parses data (about 10.000 entries), stores in stream , makes transformations on it. here code: def main(args : array[string]){ val master = "local[8]" val conf = new sparkconf().setappname("tester").setmaster(master) val sc = new streamingcontext(conf, milliseconds(110000)) val stream = sc.receiverstream(new myreceiver("localhost", 9999)) val parsedstream = parse(stream) parsedstream.foreachrdd(rdd => println(rdd.first()+"\nrule starts "+system.currenttimemillis())) val result1 = parsedstream .filter(entry => entry.symbol.contains("walking") && entry.symbol.contains("true") && entry.symbol.contains("id0")) .map(_.time) val result2 = parsedstream .filter(entry => entry.symbol == "disappear" && entry.symbol.contain

osx - Python tries to install everything into /lib on os x -

i think somehow path /lib stored in python dist should not be. it started when having troubles installing python modules using pip. pip seemed install /lib/python2.7/site-packages python not find it. sidenote: pip uninstall not find package in /lib either, pip install install it. i tried: which pip $/usr/bin/pip $which python /usr/bin/python i decided uninstall pip, $ easy_install uninstall pip error: can't create or remove files in install directory following error occurred while trying add or remove files in installation directory: [errno 13] permission denied: '/lib' installation directory specified (via --install-dir, --prefix, or distutils default setting) was: /lib/python2.7/site-packages/ it seemed in easy-install, '/lib' location used. googled bit, , decided reinstall easy-install. removed it: $sudo rm /usr/local/bin/easy_install and tried install again: $ sudo curl https://bootstrap.pypa.io/ez_setup.py -o - | python checking .pth

c# - Executing an ASPX file on an ASP.NET MVC Web Application -

i'm going try best explain situation here. in work, had our whole website using basic asp.net, , kind of created our whole own custom mvc framework scratch, creating our own httpmodules , , httphandlers . this because time, mvc did not exist (at least here), we're talking 12 years ago approximately. we tried move on, , try upgrade our current project site new asp.net mvc 5 technology. managed make work (apparently), , @ same time keep our legacy business logic untouched. our business requirements led make route every possible request in our application, , includes static files requests. we included catch-all route our static requests. route delegate request our custom staticresourcehttphandler , , processrequest method executed: public void processrequest(httpcontext context) { string file = routedata.values["file"].tostring(); string basepath = getbasepath(); string fullpath = path.combine(basepath, file); var extension = file.split(

javascript - AngularJS: How do I send an image file in POST via $resource? -

i trying make http request using $resource, send same information postman request does. of course, not doing right. here request need replicate: postman request: http://i.stack.imgur.com/9zgnf.jpg postman headers: http://i.stack.imgur.com/org0m.jpg index.html <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title>file upload</title> <link href="lib/ionic/css/ionic.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <!-- if using sass (run gulp sass first), uncomment below , remove css includes above <link href="css/ionic.app.css" rel="stylesheet"> --> <!-- ionic/angularjs js --> <script src="lib/ionic/js/ionic.bundle.js"></scri

vhdl - Converting 8 bit binary to BCD value -

i have spent countless hours on , decided need help..so here am. basically doing taking 8 bit input adc , converting value bcd dsiplay on 7 segment board. here code far: library ieee ; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use ieee.std_logic_unsigned.all; entity voltage_lut port ( scaled_value : in unsigned(7 downto 0); true_value : out std_logic_vector (15 downto 0) ); end voltage_lut; architecture behavioral of voltage_lut function divide (a : unsigned; b : unsigned) return unsigned variable a1 : unsigned(a'length-1 downto 0):=a; variable b1 : unsigned(b'length-1 downto 0):=b; variable p1 : unsigned(b'length downto 0):= (others => '0'); variable : integer:=0; begin in 0 b'length-1 loop p1(b'length-1 downto 1) := p1(b'length-2 downto 0); p1(0) := a1(a'length-1); a1(a'length-1 downto 1) := a1(a'length-2 downto 0); p1 := p1-b1; if(p1(b'len

Cast of a Generic Type in .NET -

why following cast not working ? public void add<t>() t : myinterface { var newobject = new factory<t>() factory<myinterface>; ... } public class factory<t> t : myinterface { ... } newobjects remains null. probably because factory<t> not subtype of factory<myinterface> , , cast fails. factory<t> invariant (assuming it's class), means factory<string> not derive factory<object> , though string derives object . what you're looking covariance . unfortunately, classes cannot variant in c#, interfaces can, iiiif generic type parameter t used output (e.g., method's return type) , never input (e.g., method parameters). if factory uses t output, can define covariant inteface such as: public interface ifactory<out t> {} public class factory<t> : ifactory<t> {} now can cast ifactory<t> t:myinterface ifactory<myinterface>

c# - Use SQL 2012 FORMAT function with LINQ to Entity Framework -

i add built in sql 2012 format function static function class use linq entity framework. followed this source code mimic adding built in sql function. public static class extendsqlfunctions { [dbfunction("sqlserver", "format")] public static string format(int64? arg, string formattype, string culture) { throw new notsupportedexception(); } } error: specified method 'system.string format(system.nullable`1[system.int64], system.string, system.string)' on type 'extendsqlfunctions' cannot translated linq entities store expression. update able working version adding "format" ssdl of entity framework model. looks microsoft not support "dbfunction sqlserver" outside of internal libraries. not sure this? http://msdn.microsoft.com/en-us/library/vstudio/bb738614(v=vs.100).aspx if knows how add built in sql function without editing ssdl please let me know. update have added iss

C# Methods differ only by optional parameters -

i have found topic, it's vb...and error: vb issue here method signatures. notice 1 has different return type. public static bool populaterunwithsimplevaluebyfieldidsync(string fieldvalue, string fieldid, iviewmodel myself, int index) vs public static void populaterunwithsimplevaluebyfieldidsync(string fieldvalue, string fieldid, iviewmodel myself, int index = 0, populatedonecallback populatedone = null) the actual call making: populaterunwithsimplevaluebyfieldidsync(date, dtx.datefield, saver, index); the compiler decided pick first method, , not give me error. once first method removed (it unused code), started calling second method. is there option somewhere treat error? you're going need use form of 3rd party code analysis if want flagged @ compile time, since c# language specs define current behavior should happen.

python - Does celery allow tasks execute one by one? -

@celery.tasks def a(): time.sleep(2) print 'aaa' @celery.tasks def b(): time.sleep(2) print 'bbb' now want when celery take task-a , task-b @ same time, task-a execute first, , task-b should execute after task-a. celery allow happend?

emacs bookmark+ :How to create a file specific bookmark file? -

bookmark+ package provides (bmkp-this-file-bmenu-list) function. this, suppose, loads file specific bookmark file , filters bookmarks, relate file. question: how create specific bookmark file specific file? the result should filtered list of bookmarks, when using c-x p , command (which bound (bmkp-this-file-bmenu-list) ). edit: use 1 default bookmark file ~/.emacs.d/bookmarks . file has bookmarks ~/.emacs file . now, when visit, say, ~/.emacs file, run c-x p , , following error: bmkp-this-file-bmenu-list: no bookmarks file ~/.emacs. no, actually, command bmkp-this-file-bmenu-list (from doc string): show bookmark list bookmarks current file. set `bmkp-last-specific-file` current file name. if current buffer not visiting file, prompt file name. it shows *bookmark list* display, listing , bookmarks target current file. so if use command in file buffer see displayed, in buffer *bookmark list* , of bookmarks current file, , bookmarks. this has nothing using

php - How to fetch the values of a column named % -

?>php while ($row = mysql_fetch_object($sql)) { echo $row->%; } ?> //error parse error: syntax error, unexpected '%', expecting identifier (t_string) or variable (t_variable) or '{' or '$ <?php while ($row = mysql_fetch_assoc($sql)) { echo $row['%']; } ?>

php - Printing Average of Positive Numbers -

how can exercise using php? write program requests user type positive numbers, or stop typing number smaller 1. print average.use do-while loop. enter number : 3 enter number : 5 enter number : 11 enter number : 1 enter number : 0 average : 5 enter number : 31 enter number : 4 enter number : 4 enter number : -12 average : 13 i tried finish this. do { echo 'enter number: '; $number = trim(fgets(stdin)); if($number < 1) { break; } $sum += $number; ++$count; } while(true); $avg = $sum / max($count,1); //} echo("average : ".$avg); exit; ?> the thing needed cast value have received standard input integer (everything came stdin string): - $number = trim(fgets(stdin)); + $number = (int)trim(fgets(stdin)); hope helps.

Objective-C / iOS share documents to upload in my app -

Image
i'm doing app dropbox , need know difference between 2 photos: i want upload selected file in server. i want app appear here: but appears here: how can show app apps in first photo?? (pruebamenu app) edit this documents types: edit2 info.plist code: <key>cfbundledocumenttypes</key> <array> <dict> <key>cfbundletypeiconfiles</key> <array> <string>approv</string> <string>logoapp</string> </array> <key>cfbundletypename</key> <string>prueba</string> <key>cfbundletyperole</key> <string>viewer</string> <key>lshandlerrank</key> <string>owner</string> <key>lsitemcontenttypes</key> <array> <string>com.adobe.pdf</string> <string>public.image</string&g

c - PIC18F timer for minutes and hours -

#include<p18f452.h> void t0_init(); void main() { trisc=0; // configure portb output port. latc=0x01; t0con=0x07; // prescaler= 1:256, 16-bit mode, internal clock t0_init(); while(1) { // initialize timer0 latc=0x00; t0_init(); //delay 1 sec latc=0x01; t0_init(); //again delay 1 sec } } void t0_init() { int a=0; //while(a<2) // { tmr0h=0xf0; // values calculated 1 second delay 4mhz crystal tmr0l=0xbd; //4/4mhz =1us=1us*prescaler=256us=1sec/256u=0xf42-(ffff)=f0bd t0conbits.tmr0on=1; // timer0 on while(intconbits.tmr0if==0); // wait until tmr0if gets flagged t0conbits.tmr0on=0; // timer0 off intconbits.tmr0if=0; // clear timer0 interrupt flag // a++; // } } it accurate delay , doing work want longer delays of hours or minutes. , longer delays. tried using counter incre

php - MySQLi multiple prepared statements using previous fetched $variable -

$stmt = $mysqli->prepare("select id,name,master,level,exp player.guild order exp desc"); $stmt->execute(); $stmt->bind_result($id, $name, $master, $level, $exp); $stmt->fetch(); $guildnum = $stmt->num_rows; $stmt->store_result(); $stmt->close(); $stmt2 = $mysqli->prepare("select id,login account.account id=?"); $stmt2->bind_param("i", $master); $stmt2->execute(); $stmt2->bind_result($boss_id, $boss_name); $stmt2->store_result(); $stmt2->close(); $stmt3 = $mysqli->prepare("select empire player.player_index id=?"); $stmt3->bind_param("i", $boss_id); $stmt3->execute(); $stmt3->bind_result($empire); $stmt3->store_result(); $stmt3->close(); $stm2 , $stm3 not returning result.. //explaining code $stm fetch details , store them $variables $stm2 uses variable $master fetch "id" , "login" , store them other variables $stm3 uses $boss_id (stored $st

sonarqube - Sonar javascript plugin issue -

currently, using 1.3 javascript jar. in code analysis, 3rd party files/folders being analyzed. thinking upgrading new 2.1 javascript plugin. fix issue? sonar analysis scan developers code , not 3rd party code. otherwise, developer turn off javascript analysis completely. have looked @ release notes did not find anything. you can setup exclusion patterns prevent analysis of 3rd party libraries.

asp.net mvc - Generic CRUD controllers and views -

i'm going through intro tutorials asp.net , i've got decent idea of how implement simple crud admin app. are there commonly used patterns implement generic list/create/update/delete actions? seems pretty tedious have build scaffolding every model, , maintain of add, edit , list views , controllers. lot more efficient , less error-prone implement generic actions like: /list/model /edit/model/id /update/model/id /delete/model/id that handle model. i've done similar, think, you're talking in admin application built. basically, key use generics. in other words, create controller like: public abstract class admincontroller<tentity> : controller tentity : ientity, class, new() { protected readonly applicationdbcontext context; public virtual actionresult index() { var entities = context.set<tentity>() return view(entities); } public virtual actionresult create() { var entity = new tentity()

java - Checking if an array of string is sorted lexicographically case insensitive -

i'm writing method gets input array of strings , integer n . method check if strings until length n in lexicographical order. code returns false every input , cant figure out why! public static boolean isstringarraysorted(string[] strs, int n) { boolean answer=true; (string word : strs) { for(int i=1; i<strs.length; i++) { string check1 =word.substring(0,n); string check2= strs[i].substring(0,n); if ( check1.comparetoignorecase(check2) > 0 ) return false; } } return answer; } because iterating in inner loop entire array while should word onwards. for (int j=1; j<strs.length; j++){ for(int i=j+1; i<strs.length; i++){ string word = strs[j]; string check1 =word.substring(0,n); string check2= strs[i].substring(0,n); if (check1.comparetoignorecase(check2)>0) return false; } }

sql - MySQL joining tables gives unexpected output -

i have been bashing head against brick wall trying working , don't know why it's not. i join tables , b using my_field. run sub query my_field table b where complete = 1 . want use query tables c , d this current query select table_a.*, table_b.*, table_c.*, table_d.* table_a inner join table_b on table_a.my_field = table_b.my_field left join (select my_field table_b complete ='1') test on table_b.my_field = test.my_field right join table_c on test.my_field = table_c.my_field inner join table_d on table_c.my_field = table_d.my_field this output of current query table_a.field1 | table_a.field2 | table_b.field1 | table_b.field2 | table_c.field1 | table_c.field2 | table_d.field1 | table_d.field2 | test.complete =================================================================================================================================================================

Upload image in cakephp -

i want have in function (add) file upload process in cake application. have tried various tutorial across web bur reach solution problem. new cake , dont want reinvent wheel want learn based on have implemented far. grateful help. add.ctp <?php echo $this->form->create('movie'); ?> <?php echo __('add movie'); ?> <?php echo $this->form->hidden('movie_id'); echo $this->form->input('title'); echo $this->form->input('date', array( 'type' => 'date', 'label' => 'date', 'empty' => false, 'dateformat' => 'dmy', 'minyear'=>'1990', 'maxyear'=>date('y'), )); echo $this->form->input('description'); echo $this->form->input('file', array('type' => 'file'));?> <?php echo $

google apps script - OnOpen or time trigger - move rows to another spreadsheet if 2 criteria met -

i have little experience, in fact near none of terminology 'herd' not known. i have 2 spreadsheets 1 sheet named same in each. spreadsheet "production" sheet "master" - sheet id 1gog0ts1_2jwlgretreynrvk-q6tey3iwg_5vxfozlus spreadsheet "archived_production" "master" - sheet id 1mr4ljmp1smpds1i8u_pe5uloevjlc599vq87m9hwcx0 with onopen script, or maybe timed trigger, set in "production" spreadsheet need move rows "archived_production" spreadsheet meet 2 criteria criteria 1 - date in column b 7 days older current date but if, also criteria 2 - entry in column o "100%" in included screenshot example, given today's date 11/19/14, first entry highlighted in yellow moved upon next opening of spreadsheet. thank you, always, in advance help. sorry, not enough postings yet allow image upload, text explains. you can use function perform operation want on onopen() script. function

javascript - Adding more, another loop to my Underscore template with a new backbone model? -

update : i have got code working, of sorts, have 2 issues , 1 problem not sure how fix. post current code below. 1 clients append right section within timesheetdata template. wraps option tag within clientdata template within option . so : <select> <option> <option value="xx"> xxx </option> </option> </select> now know designed do, have root element can not seem find solution issue, although still works. now other issue need select default client, loaded timesheet model, timesheetrow.client_id holds database saved row. not sure how access in if statement or other way within client template. now problem have client data not load? when reload / refresh page lists clients in option tags, loads nothing, giving me empty select tag. when not load anything, don't have console log errors or anything? all welcome :) so current backbone code: client data code : var clientmodel = backbone.model.extend({