Posts

Showing posts from June, 2012

javascript - Nested function and else condition not working -

i practicing js doing project , have run issues (again). upfront, explain want. have top level buttons nation names, on click pic fade container that. gets pic first array on line 1.this works well. however... when container visible, want click handler on "next" button right. handler 1 function (line 29-42) animates second div(.containsnext) changing opacity , rotate values. function calls function (next, should change target div background pics new array) , has if else statement. if condition works supposed to. else condition not run, if take out nested next() function. i think error (console doesn't return one) on next function lines 15 , 16, know lines "funny":-) and if statement in wrapper function not work either. how fix this? please make sure select france, italy or croatia buttons, or next button not respond @ (do not know why either). 1 more question on side, economical way store pics nations arrays selected/triggered next button? how impleme...

javascript - Multiple dynamic maps in same page using maps api v3 -

i have system keep addresses, have loop , return of of them loop script passing id of div , address each one, works, not render correctly maps. can me? http://quax.com.br/clientes/silvaesilva/escritorio i did , ended iframes going right, pass parameter address desire , renderizo in iframe. thank you.

css - How can i set style to QLayout -

i'm trying add stylesheet script using css, looks fine can't set style qlayout. how can change it's background color example of i'm done. def main_style(self): self.setstylesheet(""" .qvboxlayout{ background-color: #616161; } .qmenubar{ background-color: #212121; color: #f5f5f5; } .qmenu{ background-color: #212121; } .qtextedit{ background-color: #424242; color: #f5f5f5; border: 1px #9e9e9e solid; } """) the program running no errors , changes happen except qvboxlayout it's still default

sql server - Importing Large Excel Sheet into SQL -

monthly i'm given spreadsheets need import sql. use sql server import , export wizard , import temp table call stored procedures complete import process. working fine on production server , working fine on development machine until last week when did clean install of windows 10. now, i'm still able import smaller spreadsheets few thousand rows, however, if attempt import data spreadsheets have 500,000+ rows of data takes couple minutes on both "setting source connection" , "setting destination connection" seems hang on "copying". i've checked logs , run sql profiler , see nothing regarding failures. i've let process run upward of hour , killed out, viewed temp table , shows no records imported. data format i'm able import on production server without issue. now here's kicker... i'm able import these large sheets on development server if have spreadsheet open in excel @ same time, (note smaller spreadsheets don't need h...

python 3.x - Print and UnicodeEncodeError -

i know there lots of similar questions, none seem answer question. getting error: print('dimming', device.name, 'to', level) unicodeencodeerror: 'ascii' codec can't encode character '\xe5' in position 3: ordinal not in range(128) if test print character, works: $ python3 python 3.4.3 (default, oct 14 2015, 20:33:09) [gcc 4.8.4] on linux type "help", "copyright", "credits" or "license" more information. >>> print('\xe5') å >>> print('å') å if add .encode('utf-8') outputs dimming b'byr\xc3\xa5' 100 this process running on ubuntu via upstart. how can make output correct character? add env lang=en_us.utf-8 upstart script conf file.

asp.net mvc - Linq to return true or false if a set contains distinct values -

if set returning contains 1 distinct value, return value (string). otherwise, return "multiple". i have set ternary operator , know if can use linq sql determine whether or not set contains distinct value or multiple different values. something following: name = h.namelistings.select(a=>a.nameid).checkfordistinct() ? h.namelistings.select(a=>a.nameid).first() : "multiple" i realize checkfordistinct() not linq method; using explain behavior looking for. var name=h.namelistings.select(a=>a.nameid).distinct().count()==1 ? h.namelistings.select(a=>a.nameid).first(): "multiple"; here's 1 trip database solution, catching exception if there more 1 (may work in english versions -- don't know if exception messages can translated). string result=""; try { result=h.namelistings.select(a=>a.nameid).distinct().single(); } catch(invalidoperationexception ex) { if (ex.message.contains("more one")...

javascript - AngularJS div background color with ngStyle -

one of div s observing background color variable ngstyle. anytime change the value, error. please see below, think more or less consistent example https://docs.angularjs.org/api/ng/directive/ngstyle <div class="item item-divider" ng-style="scorecolor"><b>rate</b>&nbsp;{{score}}</div> <input type="range" name="rate" min="1" max="10" value="5" step="1" ng-model="score" ng-change="changescorecolor(score)"/> $scope.changescorecolor = function(score){ $scope.scorecolor = "{background-color:" + colorfromscore(score) + ";}"; }; typeerror: name.replace not function @ camelcase (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11098:5) @ foreach.css (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11541:12) @ object.jqlite.(anonymous function) [as css] (http://localhost:8100/lib/ionic/js/ionic.bundle.js:11667:9)...

Drawing dynamically multiple lines in java applet -

Image
when try draw single line in shape , don't know problem. want draw multiple lines store points of old lines in array list repainted each time draw new line. public class lines11 extends java.applet.applet implements mouselistener, mousemotionlistener { private final int maxlines = 10; private arraylist<point> starts; private arraylist<point> ends; private point anchor; private point currentpoint; private int currlines; public void init() { starts = new arraylist<point>(); ends = new arraylist<point>(); currlines = 0; this.addmouselistener(this); this.addmousemotionlistener(this); } public void mousepressed(mouseevent e) { anchor = new point(e.getx(),e.gety()); repaint(); } public void mousedragged(mouseevent e) { currentpoint = new point(e.getx(),e.gety()); addline(e.getx(),e.gety()); repaint(); } publi...

OpenCV C++ to calculate vignette effect using gaussian kernel function -

i try convert this reply python c++ , i'm stuck on first call multiply... small input mat 2 dims , 600x400 cols/rows. mat = getgaussiankernel(small.cols, .3); mat b = getgaussiankernel(small.rows, .3); mat ta; transpose(a, ta); mat c = *new mat(ta.rows, ta.cols, ta.type()); cv::multiply(ta, b, c); mat d; cv::max(c, d); d = c / d; mat e; multiply(small, d, e); the error message reads: the operation neither 'array op array' (where arrays have same size , same number of channels), nor 'array op scalar', nor 'scalar op array' in function arithm_op i'm not familiar either numpy or matplotlib i'm constraint c++ reasons lengthy explain... if read documentation cv::multiply see expects first 2 inputs same size , type. because attempting element-wise multiplication . your gaussian kernel a defined 600 x 1 (which getgaussiankernel recommends first input odd ) transpose ( ta ) going 1 x 600. the second input, b defined 400 x...

matrix - Warnings inmatrix multiplication in vhdl -

so, started writing code simple 4x4 matrix multiplication. code crude @ point, try change end, wanted see if works. uses direct assignment 2-bit elements of matrices 8-bit inputs. similarly, 4 outputs created concatenating 4 elements of each row of resulting matrix. below can see code. the problem have after run code, 100 warnings of type "there 'u'|'x'|'w'|'z'|'-' in arithmetic operand, result 'x'(es)." doing wrong? there problem initialization of variables a, b, temp, or else? library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity matrix_mul port( a1: in std_logic_vector(7 downto 0); a2: in std_logic_vector(7 downto 0); a3: in std_logic_vector(7 downto 0); a4: in std_logic_vector(7 downto 0); b1: in std_logic_vector(7 downto 0); b2: in std_logic_vector(7 downto 0); b3: in std_logic_vector(7 downto 0); b4: in std_logic_vector(7 downto 0); x1: out st...

ruby if string contains -

with following code, expect bravo if file name 123456.txt . if file_name#=~ ('.+(775|776|777|778)\.txt') @outputs['answer'] = 'alpha' elsif file_name#=~ (.+(456|546)\.txt) @outputs['answer'] = 'bravo' but answer results in alpha . missing here? # defines start of comment. operator test against regexes =~ , not #=~ . if file_name will case being picked, unless file_name false or nil , hence why 'alpha' . also literal syntax create regexes // , not ('') : if file_name =~ /.+(775|776|777|778)\.txt/

javascript - jquery.on("click") doens't work as i expected -

this question has answer here: event binding on dynamically created elements? 19 answers i building web app. main navigation of web app refreshed jquery after refresh jquery event doesnt work. the "on button" has jquery event bound .on , everytime clicked append paragraph. "reset button" adds "on button" jquery event doesn't apply it. i have used .on method circumvent second "on button" isn't in dom when document ready. here simple example: example on jsfiddle <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>blub</title> <script src="js/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $(".reset").click(...

How to get the labels of items in an R list -

this question exact duplicate of: accessing list names 1 answer i have object of type "large list" , want list of labels follow dollar signs below. how do that? str(example_list) list of 360 $ b32ad9c4fcbdd1f812 : chr [1:2201] "sd" "ssd" "dgaal" "de6" ... $ 6ba9eb1aa59226b8 : chr [1:2320] "83r" "ity" "dkem" "4kl" ... $ e1680cf14ebc88bbd521 : chr [1:2687] "62v" "dae" "ddv" "dal" ... you use names function because each item in larger list list own name. so 1 item: names(example_list[1]) we [1] "b32ad9c4fcbdd1f812" then list of lists names(example_list) we [1] "b32ad9c4fcbdd1f812", "6ba9eb1aa59226b8", "e1680cf14ebc88bbd521"...

How to capture audio in javascript? -

i using getusermedia() , working on firefox , chrome, yet got deprecated , works on https (in chrome). there other/better way speech input in javascript works on platforms? e.g. how websites web.whatsapp.com app record audio? getusermedia() prompts first-time-users permit audio recording, whereas whatsapp application doesn't require user's permission. the getusermedia() using looks this: navigator.getusermedia( { "audio": { "mandatory": { "googechocancellation": "false", "googautogaincontrol": "false", "goognoisesuppression": "false", "googhighpassfilter": "false" }, "optional": [] }, }, gotstream, function(e) { console.log(e); }); chrome require using https , since getusermedia powerful feature . api access should...

c# - Why my MVC client gets null response from WCF Service? -

i have problem asp.net mvc application. in service folder created wcf service this: iservice.cs namespace helloworld { [servicecontract] public interface iservice { [operationcontract] list<string> getusers(); } } service.svc <%@ servicehost language="c#" debug="true" service="helloworld.service" codebehind="service.svc.cs" %> service.svc.cs namespace helloworld { public class service : iservice { private applicationdbcontext db = new applicationdbcontext(); public list<string> users = new list<string>(); public list<string> getusers() { foreach(var item in db.users.tolist()) { users.add(item.username.tostring()); } return users; } } } after added service reference mvc client , created following action controller: // post: simpleclient/create ...

php - Laravel redirect route with id variable won't work -

i have made update function laravel 4.2 website work. updates table in database right infomation when want redirect same view came problem. the url shows: http://localhost:8000/admin/page/%7bpageid%7d when schould say: http://localhost:8000/admin/page/1 here link image showing error in browser: http://i.imgur.com/ggo5elg.png this view ( admin.pages ) @section('content') <div class='box box-info'> <form method="post" action="/admin/page/{{$page->id}}"> <div class='box-header'> <div class='box-body pad'> <input type="text" name="title" value="{{$page->title}}" class="form-control"> </div> </div> <div class='box-body pad'> <textarea id="editor1" name="text" rows="2" cols="80"> ...

r - bigrquery throwing "Error: Invalid Credentials" when using query_exec() -

i've been using bigrquery library in r run queries on google big query project past 6 months. morning ran simple query_exec() command i've run number of times on past few days , got simple message "error: invalid credentials". i haven't been able find documentation telling me how fix this. i'm not sure how give code recreate error. the thing can think of changed signed different gmail account. steps attempted far: i logged out of gmail account , logged in right one. i uninstalled r on computer , reinstalled all. still no luck. i'm realizing there isn't ton of information here. if there's else can provide haven't thought of happy answer questions. thanks can provide. after more searching found way clear access credentials in question , answer: bigrquery - run_query_job to summarize, if force access credentials null set_access_cred(null) , new credentials get_access_cred() ; can re-authenticate.

javascript - why doesn't removeEventListener work? -

i'm not sure what's wrong here, testing in chromium , firefox, find i'm doing wrong respect removing eventlistener element in javascript. the context canvas game. @ first, there's splash screen shown click begin game. after click begin, want remove listener. the main point of interest removeeventlistener in startgame function. doesn't throw error. , code executes (i see game starting message in console , can see "this" game instance). i'm totally confused why if keep on clicking on canvas runs startgame each time. expected behavior clicking there nothing once eventlistener removed. help! function game(canvas) { this.c = canvas; this.ctx = this.c.getcontext("2d"); this.c.width = canvas_width; this.c.height = canvas_height; // background image this.bgready = false; this.bgimage = new image(); this.bgimage.onload = function () { window.g.bgready = true; }; this.bgimage.src = main_background; } game.pr...

for loop - BASH: iterate over a list of floating numbers in decrement -

what want similar python codes beneath, while variables start, end, , spacing float numbers , start > end. for in numpy.arange(start, stop, step): print or, for in numpy.linspace(start, stop, num): print i know awk handy (see second answer in question ). num=$(awk "begin{for(i=${start};i>=${stop};i-=${step})print i}") n in $num $n done but, how realize iteration on list of floating numbers in decrement in bash without using awk? thanks ! you may use seq seq [option]... first increment last

c# - Conditional Expression Return Type -

i have 2 classes implementing imyinterface , async method of return type task<imyinterface> . why receiving compiler error "there no implicit conversion type" return statement, return somebooleandeterminedbythemethod ? class1 : new class2(); , best procedure resolving this? full method: public static async task<imyinterface> mymethodasync(subclass1 class1child) { var listofthings = new list<tuple<int, class1>>(); await task.run(() => { foreach (var item in somecollection) { var dummyclass1 = new class1() {intproperty = 0}; var computationresult = new tuple<int, class1>( dummyclass1.intproperty, dummyclass1); listofthings.add(computationresult); } } try { var returnedclass1 = (from items in listofthings orderby items.item1 select items.item2).firstordefault(); return returnedclass1...

android - gradle commandLine statement blocked by while loop after it -

i have gradle task meant start app installed on connected android device. app designed perform actions , shut down, , task supposed detect this. app unity-built app, it's worth - though i'm not sure should matter. granted, i'm new gradle, please forgive stupid errors made here. the task follows: task androidtests(type: exec) { def output = new bytearrayoutputstream() println "starting unity sample app" commandline 'adb', 'shell', 'am', 'start', '-n', "com.foo.bar/com.unity3d.unityplayeractivity" while(!output.tostring().contains('com.foo.bar')) { // wait app launch println "sample app not running yet." commandline "adb", "shell", "ps", "yplayeractivity" } // wait app close while(output.tostring().contains(packagename)) { println "sample app has not closed yet." commandlin...

javascript - change order of elements after click() -

i wont change order of paragraphs(the 1 clicked user should @ top). came this: <div> <p>11111111</p> <p>22222222</p> <p>33333333</p> </div> $("p").click(function(){ var = $(this).index(); if (a != 0) { $(this).clone().prependto("div"); $(this).remove(); } }) but works "once". http://plnkr.co/edit/6vlwbilgi7fdbv6d0wt2?p=preview you're not far off, it's easier that: prepend element own parent prependto : $("p").click(function() { var $this = $(this); $this.prependto($this.parent()); }); <div> <p>11111111</p> <p>22222222</p> <p>33333333</p> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> if want, don't need jquery it: $("p").click(function() { this.parentnode.insertbefore(this, this.parentn...

How does iOS determine which share extensions are enabled by default? -

Image
some apps have 'share extensions' enabled default when installing app. flickr example of this. however, other apps not - onenote, wunderlist, etc not enabled default. is there setting in plist file controls this? i'm wondering if can enable default, or have user consent enabling default, when app starts up. thank you! these apps have agreements apple. if @ settings app, can see these apps have agreements. vimeo app similar agreement. far know, there no way set app have share extension enabled default. note not have vimeo installed, it's still in settings app.

java - Constructor (super-, sub-, subsubclass) - Help and tips :) -

i'm working on project , made example easly explains problem. i've made superclass (abstract), subclass (abstract) , subsubclass. there piece of code want try keep in constructor of superclass, won't work correctly until put subclass instead. the superclass: public abstract class superclass{ protected int x, y, halfx, halfy; public superclass(){ halfx = x / 2; halfy = y / 2; } the subclass: public abstract class subclass extends superclass{ public subclass(int x, int y){ this.x = x; this.y = y; } the subsubclass: public class subsubclass extends subclass{ int half; public subsubclass(int x, int y){ super(x, y); } public void mymethod(){ half = halfx + halfy; } if remove halfx = x / 2; halfy = y / 2; superclass constructor , put subclass constructor, code works perfectly. this: public abstract class subclass() extends superclass{ public subclass(int x, int y){ this.x = x; this.y = y; halfx = x / 2; halfy...

virtual machine - connect to siebel client with local ip address -

i have installed siebel client , tools on virtual machine. can access siebel web client using http://localhost/start.swe ? my goal connect siebel web client on virtual machine local machine. why cant acces client using vm local ip address http://10.0.x.x./start.swe ? please let me know missing.? havent install siebel enterprise server , siebel web server extension. need ?? there few things need check such firewall, nat , port forwarding settings. this link walks thru example. hope helps

pseudo element - CSS :before repeat issue -

i set :before property on footer i'm facing repeating issue. mean image :before property repeated lot of , don't know why :/ see on website easier understand :) http://iutdoua-webetu.univ-lyon1.fr/~p0902398/prestashop/index.php here code /*insertion image tdb footer*/ div.footer-container ::before{ ontent:url("../img/tonnerre/img_tdb_footer.png"); } /*fin insertion image*/ <div class="footer-container"> <footer id="footer" class="container" data-nb-cols="6"> <div class="container"> <!-- block newsletter module--> <section id="newsletter_block_left"> <h4>lettre d'informations</h4> <div class="block_content"> <form action="http://iutdoua-webetu.univ-lyon1.fr/~p0902398/prestashop/index.php" method="post"> <div class="form-group"> <input class="...

using model method to instantiate object in Django -

i have 2 classes defined in models.py file: class branch_circle(models.model): ... trunk_circle = models.foreignkey('trunk_circle', null=true) class trunk_circle(models.model): ... def create_branch_circle(self): branch_circle = branch_circle(trunk_circle=self) branch_circle.save() return branch_circle using shell instantiate trunk_circle object first, call 'create_branch_circle' method , expect create branch_circle object. doesn't: import trunk_circle import branch_circle r = trunk_circle s = r.create_branch_circle when call branch_circle.objects.all() empty. also, type of 's' <bound method trunk_circle.create_branch_circle of <trunk_circle: trunk_circle object>> to instantiate object or call method have use brackets () : r = trunk_circle() s = r.create_branch_circle()

ios - How to prevent an animation from completing when user leaves and returns to app -

i making app have button moving 1 side of screen other. have created pause button pauses animation once button selected. button , function works fine. added function determines if user has exited application. in function, added pause button function. however, when user returns app after exiting, shows pause screen, animation completed. here code: @ibaction func pausebutton(sender: uibutton) { let button = self.view.viewwithtag(1) as? uibutton! let layer = button!.layer pauselayer(layer) // pausing animation view2.hidden = false // showing pause screen } func pauselayer(layer: calayer) { let pausedtime: cftimeinterval = layer.converttime(cacurrentmediatime(), fromlayer: nil) layer.speed = 0.0 layer.timeoffset = pausedtime } @ibaction func startbutton(sender: uibutton) { let button = uibutton() button.tag = 1 // can retrieve in pause function // code make button nice button.translatesautoresizingmaskintoconstraints = false // allow c...

django - How do I display the number of object returned from a query -

i want display number of objects returned query search. have tried {{ p.count }} , {{ post.count }} here post_list.html. have read other posts use methods , not work me. know missing something. {% extends 'posts/base.html' %} {% block content %} <div class="col-sm-6 col-sm-offset-3"> <h1>{{ title }}</h1> <form method="get" action=" "> <input type="text" name="q" placeholder="search" value="{{ request.get.q }}"/> <input type="submit" value=" search"/> </form> <a href="{% url 'posts:create' %}">create</a> {% p in queryset %} <div class="row"> <div class="col-sm-12 "> <!-- col-sm-6 --> <div class="thumbnail"> {%...

java - How to make Hibernate to use SequenceHiLoGenerator for JPA GenerationType.AUTO on Oracle? -

i have table id below, hibernate uses org.hibernate.id.sequencegenerator instead of sequencehilogenerator generationtype.auto, how can tell hibernate use sequencehilogenerator? @id @sequencegenerator(name="admin_seq", sequencename="unique_id") @generatedvalue(strategy=generationtype.auto, generator="admin_seq") private long id if use generationtype.sequence, hibernate use sequencehilogenerator, need use generationtype.auto compatibility mysql. i have tried using @genericgenerator, works oracle complained mysql: org.hibernate.dialect.mysqldialect not support sequences. @genericgenerator(name = "admin_seq", strategy = "org.hibernate.id.sequencehilogenerator", parameters = { @parameter(name = "sequence", value = "unique_id"), @parameter(name = "max_lo", value = "50") }) @generatedvalue(strategy=generationtype.auto, generator="admin_seq") p...

node.js - How to pass options to dependent package installs for npm? -

my node.js project has dependency on node-sqlite , unfortunately default libsqlite binary embedded there not built options need. now can invoke npm install on package alone build correctly: cflags=-dsqlite_enable_stat4 npm install sqlite3 --build-from-source essentially, sets environment variable , passes option tool. however, npm install should install all project dependencies, including sqlite. how encode package.json or elsewhere npm install install sqlite dependency above command line? you use preinstall or postinstall script this. #!/bin/bash cflags=-dsqlite_enable_stat4 npm install sqlite3 --build-from-source; put in scripts/install_sqlite3_from_source.sh , , set scripts.preinstall or scripts.postinstall in package.json it.

html - How to put Carousel in center -

screenshot of carousel hi guys, im working html , right added carousel item html project, question how can display carousel in middle of page since appears @ left side. edit: heres carrousel code <div class="box-body"> <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1" class=""></li> <li data-target="#carousel-example-generic" data-slide-to="2" class=""></li> </ol> <div class="carousel-inner"> <div class="item"> <img src=...

scala - Why does this Slick test inconsistently fail? -

i coding simple getting started ( http://slick.typesafe.com/doc/3.1.1/gettingstarted.html ) examples slick 3.1.1 documentation. i wrote following test assert on count of coffees: @test def countcoffees() = { // read coffees , print them console val rf = db.run(coffees.result) // equivalent sql code: // select cof_name, sup_id, price, sales, total coffees val r = await.result(rf, duration.inf) assert(r.size == 5) } some times test pass , other times result following: [info] - countcoffees *** failed *** [info] org.scalatest.junit.junittestfailederror: vector() had size 0 instead of expected size 5 (test.scala:40) the testsuite defined follows: class slickscalaejemplo extends funsuite schemaejemplo being schemaejemplo follows trait schemaejemplo extends funsuite slickbase beforeandafter { val setup = dbio.seq( // create tables, including primary , foreign keys (suppliers.schema ++ coffees.schema).create, // insert suppli...

css3 - What are some examples of image effects (css) -

i wondering image effects can done via css, such glint minecraft. there way this, or similar, effects? try script in css: http://una.im/cssgram/ you can replicate instagram's filter class!

javascript - Insert Data using ajax on codeigniter -

i trying insert data using ajax in codeigniter app every time click submit button whole page reloads , nothing happens. form submit button not working in case. when have tried same code without ajax can submit data database using action on form. my view : <script type="text/javascript"> /*submit form via ajax*/ $("#creategrade").on('click', function (e) { e.preventdefault(); $.ajax({ url: '<?php echo base_url();?>index.php?admin/exam_grade/create', data: { grade_title: $("#grade_title").val(), grade_point: $("#grade_point").val(), mark_from: $("#mark_from").val(), mark_upto: $("#mark_upto").val(), comment: $("#comment").val() }, async: 'true', cache: 'false', type: 'post', success: function (data) { //jquery("#attendence_report_holder").html(response); ...

php - How to get the key value from an array if given string value as a variable in Codeigniter -

i not sure if make sense in asking have model: function update_profile_image($id, $image, $data){ $data1=array('profile_thumb'=> $data['images_urls'][$index]); $this->db->where('property_ref_id',$id); $this->db->update('vbc_property_images',$data1); } here $data array: array ( [images_urls] => array ( [0] => property_image_11.png [1] => property_image_13.png [2] => property_image_14.png ) ) and $image in model name of image in array, e.g. 'property_image_13.png'. i trying can key value $index([0], [1]..) $image in query automatically detect image selected. please help. you can loop on array key of image foreach($data['images_urls'] $key => $value) { if($value == $image) { $index = $key; break; } } alternative solution use array_search() $index = array_search($image, $data['images_urls']);

Asynchronously load Image in Enyo -

i have enyo.list 2 items: enyo.image , text component. setsrc on image during onsetupitem. this loads image , since have on 10 rows don't appear till images load. there anyway load these images asynchronously (additionally display image "fade-in" animation ?). thanks. edit: totally wrote next paragraph backwards. list -is- flyweight version. correct set number of rows. what may want replace list repeater . because of flyweight pattern in repeater might not requesting many images @ once. another approach might derive new kind based on scroller detects when images scroll view , load them @ time. pretty involved approach , might need create kind based of image works hand-in-hand other kind. you google lazy-loading strategies , see if can apply those.

Calling Haskell from C, getting "multiple definition of main" linker error -

i trying learn how interface haskell , c. start out, wrote inc.hs , simplest thing can conceive: {-# language foreignfunctioninterface #-} module inc import foreign import foreign.c.types inc :: int -> int inc = (+1) foreign export ccall cinc :: cint -> cint cinc :: cint -> cint cinc = fromintegral . inc . fromintegral and compiled produce inc_stub.h : ghc -c inc.hs worked fine. wrote c file, trying simple humanly possible: #include <stdio.h> #include "inc_stub.h" int main(int argc, char *argv[]) { int = 1; hs_init(&argc, &argv); = cinc(a); hs_exit(); if (a == 2) { puts("worked!"); } return 0; } tried compile it, got linker error: ghc -no-hs-main inc.c inc -o simplest linking simplest.exe ... inc.o:inc.c:(.text+0x0): multiple definition of `main' inc.o:inc.c:(.text+0x0): first defined here inc.o:inc.c:(.text+0x31): undefined reference `cinc' c:/program files/haskell platform...

ruby - How do I precompile assets for a PhoneGap app deployed to Heroku using Guard and Rake? -

i deploy www/ of (phonegap) app heroku. prefer haml/sass/coffeescript created guardfile automatically generate html/css/js , copy src/ www/ . added www/ .gitignore . deploy heroku , have rake assets:precompile generate 'slug'/ www/ directory. added rakefile according guard example require 'guard' namespace :assets desc "precompile assets - build whole app" task :precompile guard.run_all end end however when try run locally, run_all fails. c:\users\chloe\workspace\typefunctions>bundle exec rake assets:precompile rake aborted! nomethoderror: undefined method `run_all' guard:module c:/users/chloe/workspace/typefunctions/rakefile:6:in `block (2 levels) in <top (required)>' tasks: top => assets:precompile (see full trace running task --trace) how can fix this? (or there better way?) i had add require 'guard/commander' ( wiki source ) and guard.setup despite the wiki explicitly saying # ...

javascript - jquery function not catching dynamically generated id -

i have table rows generated ajax query response like: var inp = '<input id="new_po_qty" style="text-align:center" type="text" value="1">'; $('<tr id="new_po_item_row">').html('<td style="text-align:center">' + sku_id + '</td><td style="text-align:center">' + inp + '</td><td id="new_po_cp" style="text-align:center">' + cost_price + '</td><td id="new_po_total_cp" style="text-align:center">' + cost_price + '</td>').appendto('#new_po_body'); now wrote jquery function catch changes on inp variable in table row. jquery function not catching changes in input box. jquery function: $('#new_po_qty').on('change paste', function(){ alert('changes made.'); $.niftynoty({ type:"primary",icon:"",t...

STI with Ploymorphic association in rails -

i have model named slider class slider < activerecord::base end and homebannerslider has single table inheritance relation slider class homebannerslider < slider has_many :images, as: :imageable accepts_nested_attributes_for :images, reject_if: :all_blank, allow_destroy: true end and image model given class image < activerecord::base belongs_to :imageable, polymorphic: true has_attached_file :image end my problem whenever save homebannerslider following command @admin_home_banner_slider = homebannerslider.new(admin_home_banner_slider_params) @admin_home_banner_slider.save it saves imageable_type in image model slider @admin_home_banner_slider.images <image:0x007f5e6ef7af20 id: nil, imageable_id: nil, imageable_type: "slider", title: "2", description: "2", link_button: nil, link_button_title: nil, owner: nil, publish: nil, priority: nil, created_at: nil, updated_at:...

regex - Pattern matching dates -

i'm having troubles trying match pattern of dates. of following dates legal: - 121212 - 4 9 12 - 5-3-2000 - 62502 - 3/3/11 - 09-08-2001 - 8 6 07 - 12 10 2004 - 4-16-08 - 3/7/2005 what makes date matching challenging year doesn't have 4 digits (a 2 digit year assumed in 21st century i.e. 02 = 2002), month/date can either written beginning 0 if 1 digit month, , dates may or may not separated spaces, dashes, or slashes. this have: /((((0[13578])|([13578])|(1[02]))[\/-]?\s*(([1-9])|(0[1-9])|([12][0-9])|(3[01])))|(((0[469])|([469])|(11))[\/-]?\s*(([1-9])|(0[1-9])|([12][0-9])|(30)))|((2|02)[\/](([1-9])|(0[1-9])|([12][0-9])))[\/-]?\s*(20[0-9]{2})|([0-9]{2}))/g this works, except right i'm not sure if i'm assuming length of dates , months. example, in case 121212 , might assuming month 1 instead of 12 . also, reason when i'm printing out $1 , $2 , same value. in case of 121212 , $1 1212 , $2 1212 , $3 12 . however, want $1 121212 . y...

Android Studio, Capture FrameLayout View, While Camera is StopPreview() -

this cameraview.java (i got http://blog.rhesoft.com/ ) public class cameraview extends surfaceview implements surfaceholder.callback{ private surfaceholder mholder; private camera mcamera; public cameraview(context context, camera camera){ super(context); mcamera = camera; mcamera.setdisplayorientation(90); mholder = getholder(); mholder.addcallback(this); mholder.settype(surfaceholder.surface_type_normal); } @override public void surfacecreated(surfaceholder surfaceholder) { try{ mcamera.setpreviewdisplay(surfaceholder); mcamera.startpreview(); } catch (ioexception e) { log.d("error", "camera error on surfacecreated " + e.getmessage()); } } @override public void surfacechanged(surfaceholder surfaceholder, int i, int i2, int i3) { if(mholder.getsurface() == null) return; try{ mcamera.stoppreview(); } catch (exception e){ } try{ mcamera.setpreviewdisp...