Posts

Showing posts from July, 2011

Dropbox for local development, Git for cloud -

i asking question because, while have found related topics, of focus on using dropbox remote, haven't found addresses question: is there hazardous using dropbox local repo way work seamlessly from/between multiple machines (eg. let's made fork, make changes on desktop, want continue work laptop without running $ git commands), having remote elsewhere? another way ask question might be: there way use of dropbox-connected machines 1 local development space ... idea of machines on dropbox 1 machine purposes of development... know isn't clear way ask question, don't know how can more clear. i want make sure there won't conflicts between how repository tracks changes, , way synced via dropbox - more particularly, wondering if make commit, or stage file(s) on machine (let's call these "operations"), , update dropbox-syncs machine b, operations reflected on machine b when dropbox-sync complete, git run automatically ensure operations ref...

Installing Java API for GPIB devices in eclipse -

Image
this trivial question, having trouble installing java api called jpib_windows eclipse should allow me control external devices connected via gpib. this contents of folder downloaded. i created new project in eclipse, right clicked project , went build path -> configure build path. i clicked on add external libraries , added jpib.jar file. file added, still not able use classes in api. is there else need able use api? there better way of importing api project? you jar file installed correctly. jpib (and many other java libraries) wrapper low-level routines. mandatory load corresponding native libraries before using java classes. in eclipse go run > run configurations... > arguments tab, select configuration for, perhaps, main method. specify in vm arguments field: -djava.library.path=c:\path\to\jpib\dll then add @ beginning of main() following line: system.loadlibrary("jpib_32"); then run edited configuration. should ok. in case o...

c++ - Standard functions and operations not working in class constructor -

i trying make first class constructor , seems acting strangely. class derived filebuf , reason, unable open in constructor. tried add cout statement debugging, << operator not recognized. #include <iostream> #include "bin.h" int main() { bin mybin("e:\temp\test.txt"); system("pause"); return 0; } bin.h #pragma once #include <fstream> #include <cstdlib> #include <cstring> class bin : private std::filebuf { int buffsize = 1000; char* buffer; unsigned int length; short int buffcounter; public: bin(std::string filename) { open(filename.c_str(), std::ios::in | std::ios::out | std::ios::trunc); if (!is_open()) std::cout << "error: failed open file " << filename << std::endl; //set io operations unbufferred, buffering managed manually setbuf(0, 0); //create buffer buffer = new char[buffsize]; }; ...

php - Installing Symfony2 -

i decided learn symfony tried install it. after getting composer said in website, executed following command create project , symfony2 composer create-project symfony/framework-standard-edition website/test and unfortunately got message: > installing symfony/framework-standard-edition (v2.7.1) - installing symfony/framework-standard-edition (v2.7.1) downloading: 100% --- > created project in website/test loading composer repositories package information installing dependencies (including require-dev) lock file requirements not resolved installable set of packages. **problem 1** - installation request sensiolabs/security-checker v2.0.5 -> satisfiable sensiolabs/security-checker[v2.0.5]. - sensiolabs/security-checker v2.0.5 requires ext-curl * -> requested php extension curl missing system. **problem 2** - sensiolabs/security-checker v2.0.5 requires ext-curl * -> requested php extension curl missing system. - sens...

memory - Error in C with word counting program using switch statement -

i having trouble counting number of words user enters using switch statement. want ensure multiple presses of keyboard (ascii,32) not count multiple words. can see, have memory variable stores previous keyboard press, , want count word when current keyboard press space, , previous press (i.e. memory variable not space). logic makes perfect sense me; however, code not seem work. please explain flaw in logic is? thanks. // 1.4 exercise 1: output amount of characters, number of words , number of newlines typed user // note escape command on mac enter command z #include <stdio.h> int main() { long characters = -1; // exit program on mac must press command+z long newlines = 0; long words = 1; // assume document starts word printf("type stuff! exit type ctrl+d (some computers use ctrl+z space)\n"); int = 0; int memory = 32; //stores previous keyboard press while (i != eof) // characters continue counting long escape sequence not ente...

scala - Extracting a constraint from a conjunction -

here's tree of boolean predicates. data pred = leaf (a -> bool) | , (pred a) (pred a) | or (pred a) (pred a) | not (pred a) eval :: pred -> -> bool eval (leaf f) = f eval (l `and` r) = \x -> eval l x && eval r x eval (l `or` r) = \x -> eval l x || eval r x eval (not p) = not . eval p this implementation simple, problem predicates of different types don't compose. toy example blogging system: data user = u { isactive :: bool } data post = p { ispublic :: bool } userisactive :: pred user userisactive = leaf isactive postispublic :: pred post postispublic = leaf ispublic -- doesn't compile because , requires predicates on same type -- usercancomment = userisactive `and` postispublic you around defining data world = w user post , , exclusively using pred world . however, adding new entity system necessitates changing world ; , smaller predicates don't require whole thing ( postispublic doesn...

http - Post png image to pngcrush with Ruby -

in ruby, want same result code below without using curl: curl_output = `curl -x post -s --form "input=@#{png_image_file};type=image/png" http://pngcrush.com/crush > #{compressed_png_file}` i tried this: #!/usr/bin/env ruby require "net/http" require "uri" # image crush png_image_path = "./media/images/foo.png" # crush http://pngcrush.com/ png_compress_uri = uri.parse("http://pngcrush.com/crush") png_image_data = file.read(png_image_path) req = net::http.new(png_compress_uri.host, png_compress_uri.port) headers = {"content-type" => "image/png" } response = req.post(png_compress_uri.path, png_image_data, headers) p response.body # => "input empty, provide png image." the problem code not send required parameter server ("input" http://pngcrush.com/crush ). works me: require 'net/http' require 'uri' uri = uri.parse('http://pngcrush.com/crush')...

javascript - Getting the previous tab url on click of tab in chrome extensions -

i have published application in chrome webstore (example.extension.in). requirement add extension of example.extension.in browser programatically. i.e., in test application have icon. if drag , drop beside address-bar extension should added browser. and when user clicks on icon while watching other site eg: www.facebook.com should url (www.facebook.com). is there way achieve this? you can't address bar since that's outside web view, can inline installation: https://developer.chrome.com/webstore/inline_installation in terms of icon while on site, that's doable. need build browser action icon, , use active tab: https://developer.chrome.com/extensions/tabs

ios - Error when setting property in prepareForSegue: -

i'm getting following error when trying set string in public property in prepare segue. idea why? *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uiviewcontroller setquestionobjectid:]: unrecognized selector sent instance 0x7fa713562b40' the code is: - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([[segue identifier] isequaltostring:@"postsegue"]) { commentsviewcontrollernew *commentsvc = (commentsviewcontrollernew *)[segue destinationviewcontroller]; commentsvc.hidesbottombarwhenpushed = yes; pfobject * question=[self.brightenarray objectatindex:self.indexpathofclickedpost.row]; commentsvc.questionobjectid=question.objectid; nslog(@"%@",[self.array objectatindex:self.indexpathofclickedpost.row]); // commentsvc.question = question; as may have gathered, caused because sending setquestionobjectid: message class doesn't recognise messag...

ios - UITableViewCell Segue not Working -

i'm making app have uitableview user adds data to, , want user able tap on cell , see more details cell chose. set segue cell celldetailcontroller later add details of cell chose. when run app , try tap on cell segue, selects cell , nothing happens. doing wrong here? here storyboard set up: (i cant upload pictures yet here's link) http://tinypic.com/r/2ivcwsj/8 heres code class connected tableview: import uikit typealias eventtuple = (name: string, date: string) var eventlist : [eventtuple] = [] class tableviewcontroller: uiviewcontroller, uitableviewdelegate { @iboutlet weak var eventtable: uitableview! override func viewdidload() { super.viewdidload() } override func viewdidappear(animated: bool) { eventtable.reloaddata() } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } // m...

javascript - Closing a menu only with CSS -

i succeeded remove javascript in mobile design , open side menu css. side menu like: <div class="all-content"> <div id="menu-content" class="menu-content"> .... menu content.... </div> </div> link open menu: <a href="#menu-content"><i class="fa fa-navigation></i></a> and in css: .menu-content{ opacity: 0; z-index: 0; left: -100%; } .menu-content:target{ opacity: 1; z-index: 1000; left: 0px; } and this works fine ! what want close menu clicking "anywhere out of menu" without javascript. i'm aware clicking any link close menu couldn't find how binding whole content. thanks now. make checkbox , have hidden opacity:0 have cover large areas width/height:500px have position:absolute not effect position of surrounding elements write css style hide siblings of :checked checkbox #checkbox:checked ~ ...

android - Contacts in listview -

i making app in need read contacts , send text message.i able read contacts unable show contacts name , no in list view. when try set c_number app crashes. and want send sms selected contacts. any cater problems thanks. this single_listview_item.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" > <scrollview android:layout_width="fill_parent" android:layout_height="fill_parent"> <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <checkbox android:id="@+id/chk_box" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignp...

database - Python: Can you Save an Object and all of it's Associated Values? -

i have 2d-array of co-ordinates has arbitrary number of factors each co-ordinate. (some have associated boolean values, string values etc.) is there way, save array , of it's associated values - can load up, on arbitrary ocassion? i wish solution compatible compilation. i using python 2.7 , have tried cpickle, shelve, dill, , jsonpickle.

parsing - PHP Parse/Syntax Errors; and How to solve them? -

Image
everyone runs syntax errors. experienced programmers make typos. newcomers it's part of learning process. however, it's easy interpret error messages such as: php parse error: syntax error, unexpected '{' in index.php on line 20 the unexpected symbol isn't real culprit. line number gives rough idea start looking. always @ code context . syntax mistake hides in mentioned or in previous code lines . compare code against syntax examples manual. while not every case matches other. yet there general steps solve syntax mistakes . references summarized common pitfalls: unexpected t_string unexpected t_variable unexpected '$varname' (t_variable) unexpected t_constant_encapsed_string unexpected t_encapsed_and_whitespace unexpected $end unexpected t_function … unexpected { unexpected } unexpected ( unexpected ) unexpected [ unexpected ] unexpected t_if unexpected t_foreach unexpected t_for unexpected t_while unexpected t_do ...

How can I resize an image from URL using PHP? -

i'm receiving images urls , save these images new directory, in 3 different sizes. i'm getting urls here, need way resize each image, specific height , width. i dont want resize uploaded images, images specific url. my code: $content = file_get_contents('http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg'); $name = "http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg"; $parts = explode('.', $name); $new_url = rand(0, pow(10, 5)) . '_' . time() . '.' . $parts[count($parts) - 1]; file_put_contents(directory.'/' . $new_url , $content); how can that? thanks. here solution based on imagecopyresampled (gd library) http://php.net/manual/en/function.imagecopyresampled.php $content = file_get_contents('http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg'); $name = "http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg"; $parts = explode('....

ruby on rails - How to add a new model (Video) to spree core associated with Product and its controller and a link to create it in Spree Admin layout -

Image
i want add last link video spree admin panel under product. how go ahead , make feature. i appreciate help. thank you you can create spree extension or use 1 of existing extensions. in extension's models/spree directory create model file video.rb . module spree class video < activerecord::base #add active record associations #validations , model methods end end you have decorate spree core models affected new video model. example spree product model. in extension's models/spree directory create product model decorator product_decorator.rb . module spree product.class_eval #your video association product. e.g has_one :video end end you can other spree core models associated video model. in extension's controllers/spree/admin you have create videos_controller.rb . suggest take @ spree backend images_controller directions on how can add controller. if plan upload videos application, might need audio/video transcoder such p...

javascript - jQuery Autocomplete: saving new tags to a database -

i'm noob in kind of field, hope i'll find answer here. i'm trying implement tagging system storing images dabatase. user given chance upload new image, adding little description , (here comes difficult part me) adding tags it. i've found quite documentations aboout using jquery autocomplete read existing tags db. however, need opportunity check if tag exists and, if not, add db. please give me hand on quest? long story short: need use jquery autocomplete (or equivalent plugin) both "getting from" , "saving to" tags database. thank you. :) edit: form i'm planning use insert tags (and description). i've implemented 2 jquery functions limit max number of chars in "description" textarea , max number of words in "tags" one. <form method="post" action="/upload" accept-charset="utf-8"> <div> <label>descrizione:</label> <textarea id="description...

Sort data by factor and output into a matrix (or df) R -

i have looked through other posts , think have idea of do, want clear! i have large data frame contains 4 variables , number of rows. chain resid resnum energy 1 c o17 500 -37.03670 2 arg 8 -0.84560 3 leu 24 -0.56739 4 asp 25 -0.98583 5 b arg 8 -0.64880 6 b leu 24 -0.58380 7 b asp 25 -0.85930 each row contains chain (a, b, or c), resid, resnum, , energy. sort data of energy values belonging specific resid , num in each chain clustered together. cluster mean of values "arg 8" grouped or of rows containing "arg 8" grouped. don't know more efficient. ideally, output residues arg 8 0.000 0.000 0.000 where "0.000" energy values arg 8 or o17 , on. sorry header breaks, wanted data clean, can't insert images. data structure(list(chain = structure(c(3l, 1l, 1l, 1l, 2l, 2l, 2l ), .label = c("a", "b", "c"), class = "factor...

ios - Make local Notification stay on lock screen -

i have habit making app reminds user of habits via uilocalnotifications. time @ user should reminded habit not time scheduled it. my question if there way keep notification on lock screen after user has unlocked iphone / ipad , not have moved notification center, because visited, kind of on android phones. app written in objective-c you can check app out here: https://itunes.apple.com/us/app/life-habits-let-your-habits/id979064412?l=pl&ls=1&mt=8

exc bad access - Crash report - EXC_BAD_ACCESS (SIGABRT) -

first time posting here , i'm new whole developer thing please nice! i have submitted app (a 3d game made in unity) , has returned 3 crash reports, pretty similar me. i've put them through unity. i'll post 1 below (it long posted first bit) long, if can id happy post other 2. any appreciated! thanks! incident identifier: 938fff53-56a2-4a1d-bf23-4e24567ba101 crashreporter key: 3286a932eadfb6a4501de9b1e0044450b3f54fb3 hardware model: xxx process: box [1376] path: /private/var/mobile/containers/bundle/application/00e4561a-f30c-4c48-b2bd-355a71a4d971/box.app/box identifier: bob.bob version: 1 (1) code type: arm (native) parent process: launchd [1] date/time: 2015-06-02 17:16:47.033 -0700 launch time: 2015-06-02 17:16:42.956 -0700 os version: ios 8.3 (12f69) report version: 105 exception type: exc_bad_access (sigabrt) exception subtype: kern_invalid_address @ 0...

angularjs - Testing controller with resolve dependencies -

i'm trying unit test controller relies on resolve keys using jasmine. using controlleras syntax. routing code follows: $routeprovider.when('/questions', { templateurl: 'questions/partial/main_question_viewer/main_question_viewer.html', controller:'mainquestionviewerctrl', controlleras:'questionctrl', resolve: { default_page_size: ['questionservice', function (questionservice) { //todo work out page size users screen return 50; }], starting_questions: ['questionservice', function (questionservice) { var questions = []; questionservice.getquestions(1).then( function(response){ questions = response; } ); return questions; }], }, }); the controller (so far): angular.module('questions').controller('mainquestionviewerctrl', [ 'questio...

php - Dynamically create callback functions in the loop in wordpress settings API -

i created wordpress setting page suppose add sub setting pages code same each new page , works fine. than loop through sections , settings fields , concatenate name of subpage , strings in order create custom properties. when loop through callbacks im having problem. since changing names of functions inside loop not possible in php wonder how that? function initialize(){ $mylist = get_option('listofmaps'); $mylist = explode(",", $mylist); if(count($mylist)>1){ ($x = 0; $x < count($mylist)-1; $x++) { $pagename = str_replace(" ","",$mylist[$x]); add_settings_section( "googlemapssection", "google maps options section", $pagename."_google_maps_section", "maps".$pagename ); ..... } add_action(...

java - Is it possible to extract logical page numbers (page labels) from pdfs using JPOD? -

i'd extract annotations of pdf , page numbers/labels using jpod . know page number annotation added using pdannotation.getpage() , pdpage.getnodeindex() . the problem nodeindex represents physical page index running consecutively starting 0. logical page label differ index (e.g. page index 5 has label called ii or 3 or 'cover') , i'd extract corresponding label, too. didn't find information on browsing documentation : so, possible extract information pdf using jpod , how achieve that? additional information: http://pdf.editme.com/pdfua-pagelabels

Looping Through XML File VB.NET -

Image
i have xml file : <?xml version="1.0" encoding="utf-8"?> <!--xml database.--> <disease> <name id="1">info1 <subarticle>info1</subarticle> <mainarticle>info1</mainarticle> <image>info1</image> </name> <name id="2">info2 <subarticle>info2</subarticle> <mainarticle>info2</mainarticle> <image>info2</image> </name> <name id="3">info3 <subarticle>info3</subarticle> <mainarticle>info3</mainarticle> <image>info3</image> </name> </disease> and have usercontrol : and have flowlayoutpanel have flowdirection (topdown) i need make program add new usercontrol in flowlayoutpanel information in xml file examble: program add 3 usercontrol in panel usercontrol1 = <name id="1"> usercontrol2 = <name id="2"> usercontrol3 = <name id=...

backbone.js - Backbone JS - Combination of collection, views and models -

i had following setup in 3 different projects, thought maybe it's worth asking here. there's chance i'm not person wondering this. so there comes: i have list of objects the list items have special function draggable or onclick-events my question: how build scenario backbone? i guess create model , view list objects. use collection keeping objects. now wonder: instantiate object view in model constructor , instantiate models in collection constructor? or there better way achieve want? neither; use mediator instantiate views , inject them model/collection. marionette.js has a nice implementation sort of mediating object, called controller - suggest check out. further more, don't have explicitly instantiate collection models - declare type in collection's prototype, e.g.: var mymodel = backbone.model.extend({ // shit }); var mycollection = backbone.collection.extend({ model: mymodel // pass type collection instantiate }); ...

WPF treeview: "non listed items" -

based on model want build treeview. me turns out problem, members of collection can displayed in treeview. means, have create viewmodel containing collection holds properties of model. i want build tree this: house   adress   color   numberofrooms   family    father    mother    daughter     age     hair color     friends      ...   pets    dog    mouse my house model has property adress, color, numberofrooms, family , pets. not of lists, , house isnt list either. have put properties in list of objects displayed in tree fashion, , create hierachical datatemplate each of properties. doing once not big deal, have many models deal with, doesnt seem right way... i know make hierachical datatemplate house type, put "house" in h...

oop - Why is 1_2_3_4 a valid integer literal in java? -

this question has answer here: meaning of 0_0 in java 7 [duplicate] 3 answers wierd syntax - underscores between digits [duplicate] 1 answer why following work? int a=1_2_3_4; system.out.println(a); // 1234 numeric literals specified in jls 3.10.1 . a decimal numeral either single ascii digit 0, representing integer zero, or consists of ascii digit 1 9 optionally followed 1 or more ascii digits 0 9 interspersed underscores, representing positive integer. [...] a hexadecimal numeral consists of leading ascii characters 0x or 0x followed 1 or more ascii hexadecimal digits interspersed underscores, , can represent positive, zero, or negative integer. [...] an octal numeral consists of ascii digit 0 followed 1 or more of ascii digits 0 through 7 in...

c# - How to move data from one database table to another table of same database using ASP.NET MVC? -

i new asp.net , want move data database table table in same database. searched lot didn't find such thing in asp.net mvc. have table 1 , table 2 in abc database , want move data table 1 table 2. not have knowledge thing have know blog can solve problem. tried lot did not find. like http://www.codedisqus.com/0qyjvjgpqg/move-data-from-one-listbox-to-another-on-button-click-in-aspnet-mvc.html http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-code-based-migrations-walkthrough.aspx entity framework codefirst move data 1 table another in order insert data 1 table (database1) table(database2). check following code: insert database2.dbo.table1 select * database1.dbo.table1 with due respect sir ramiramilu :)

UserForm in Excel 2013 Discount Textbox -

i have problem because want compute discount 2 textbox display on 3rd textbox . 1. txtprice 2. txtdiscount 3. txttotal but don't know how put txtprice * .txtdiscount (eg 100 * .10) computing discount. i'm using code : private sub txtdiscount_change() if txtprice.value = "" exit sub if txtdiscount.value = "" exit sub txttotal.value = cdbl(txtprice.value) * cdbl(txtdiscount.value) end sub made few changes on code , solves problem. hope in future. private sub txtdiscount_change() if txtprice.value = "" exit sub if txtdiscount.value = "" exit sub txttotal.value = (cdbl(txtprice.value)) - (cdbl(txtprice.value) * cdbl(txtdiscount.value)) end sub

Using Octave in C++ -

i new in both octave , c++ ! want use octave in c++ , found webpage . started upper code , tried run it. unfortunately there no document on matter , encountered lot of errors. first used msvc 2010 , found should use gcc!! here i'v done far: download octave link , (i download octave-4.0.0_0.zip) i tried compile code: int main (void) { std::cout << "hello octave world!\n"; int n = 2; matrix a_matrix = matrix (n, n); (octave_idx_type = 0; < n; i++) (octave_idx_type j = 0; j < n; j++) a_matrix(i,j) = (i + 1) * 10 + (j + 1); std::cout << a_matrix; return 0; } i included: 1) iostream , 2) octave directory: n:\octave-4.0.0\include\octave-4.0.0\octave\oct.h i got error in msvc10: 1>n:\octave-4.0.0\include\math.h(169): error c2065: ' asm ' : undeclared identifier 1>n:\octave-4.0.0\include\math.h(169): error c2146: syntax error : missing ';' before identifier ' volatile ' 1>n:\octave-4.0.0\i...

Searching for all open HTML tags and closing them [PHP] -

i've got page on our church website called "the fridge" meant mimic fridge place sticky notes information on what's happening in church. you can see here: http://www.ypc.org.au/resources/fridge because sticky notes may various sizes , have more or less information, information on 50 characters truncated ellipses , rest of information can viewed through modal box clicking on note. this working fine tags won't end properly. instance, if < p > tag opened , information in paragraph on 50 characters truncated before paragraph closes. this causing invalid html , colours of notes (which being randomised through css) same colour . not huge issue nice have valid html , have colours randomised bit. what wanting search open tag, determine open tag , once 50 characters reached, end open tags detected. know won't perfect solution if tag half opened or closed, user see that, it's easy enough add or remove few words in cirumstances. so thinking nee...