Posts

Showing posts from June, 2010

ruby - Combining yard docs for multiple gems -

i'm using yard generate docs couple projects i'm working on. in one, i'm co-developing gem hosts lot of redundant , shared resources used other projects. what'd i'd references first project classes or methods in gem show in docs main project. example gem class widget # spins widget of course. def spin end end project class specialwidget # jump , {#spin}. def dance end end i'd docs specialwidget generate actual link widget#spin method. can done?

hiveql - Hive Data selecting latest value based on timestamp -

i have table having following columns. c1,c2,process timestamp,insertdatetimestamp p1,v1,2014-01-30 12:15:23,2013-10-01 05:34:23 p1,v2,2014-01-31 05:11:34,2013-12-01 06:12:31 p1,v3,2014-01-31 07:16:05,2012-09-01 07:45:20 p2,v4,2014-02-01 09:22:52,2013-12-01 06:12:31 p2,v5,2014-02-01 09:22:52,2012-09-01 07:45:20 now, want fetch unique row each primary key based on latest process timestamp . if process timestamp same row having latest insertdatetimestamp should chosen. so, result should be. p1,v3,2014-01-31 07:16:05,2012-09-01 07:45:20 p2,v4,2014-02-01 09:22:52,2013-12-01 06:12:31 how achieve via hiveql ? i using hive 0.10. can not use subquery in or exists. thanks. select c1, s.c2, s.processtimestamp, s.insertdatetimestamp ( select c1, max(named_struct('unixtime', unix_timestamp(processtimestamp, 'yyyy-mm-dd hh:mm:ss'), 'c2', c2, 'processtimestamp', processtimestamp, 'insertdatetimestamp', insertdatetimestamp)

.htaccess - How to block files from access by URL -

i have subpage like mypage.com/subpage but alias , files in /data/subpage . , file needed accessed user himself index.php , other files imported index itself, depending on attributes (get, sessions etc.) i want this: let user access index.php using /subpage not /data/subpage do not let user directly access in /data/subpage , subfolders still let index.php access files. i hope wrote understandably. thank help edit: current .htaccess (located in root) rewriteengine on rewriterule ^subpage$ /data/subpage/index.php [l] rewriterule ^subpage/(?:([^/]+)/?|)(?:([^/]+)/?|)$ /data/subpage/index.php?section=$1&subsection=$2 [l] rewriterule ^edit/subpage/?(?:([^/]+)/?|)(?:([^/]+)/?|)$ /data/subpage/index.php?edit=true&section=$1&subsection=$2 [l] try: rewritecond %{the_request} \ /+data/subpage/ rewriterule ^ - [l,r=404] so direct requests /data/subpage/ results in 404. can replace r=404 f if rather result in "403". edit:

javascript - how to change focus of (this) from .box > .overlay (child) -

<div class="box" id="box1"> <div class="overlay" id="ovlay1"> </div> </div> <style> .box{ height:200px; width:200px; } .overlay{ height:50px; width:200px; position:absolite; top:-50px; } </style> <script> $(".box").mouseover(function(){ // $(".overlay").animate({ // $(this).animate({ top: "+=50px", }); }); </script> assuming have 5 of .box divs, each ascending id box1 -> box5 etc. overlay should slide in on mouseover, on hovered box.. can't figure out jquery function this. runing animate on (".overlay") shows overlay on every box, using (this) not work because referring (".box")... how can focus (this) on overlay? you can use find method of jquery: $(".box").mouseover(function(){ $(this).find(".overlay").animate({ top: "+=50px", });

java - how can i call a method with a startActivity(Intent) from another class? -

i want call sendpicture() class. seems can't make sendpicture() static type because has startactivity() in it. wondering if possible call class if so, how? sendpicture() code: public static void sendpicture() { file f=new file(environment.getexternalstoragedirectory().getabsolutepath()); intent sendintent = new intent(intent.action_send); sendintent.putextra("address", "number"); sendintent.putextra("sms_body", "see attached picture"); sendintent.putextra(intent.extra_stream, uri.fromfile(f)); sendintent.settype("image/jpg"); startactivity(sendintent); } startactivity() method of context need have reference context. might try getapplicationcontext().startactivity(sendintent), or pass context static method , use reference.

node.js - Resize and crop image and keeping aspect ratio NodeJS & gm -

i've been trying create thumbnails using gm package nodejs, i'm out of lucky. need resize images bigger 600x600 (could width/height, starting given one) when pass size gm, creates image doesn't have same size requested. for example, given code, assume running node app /path/to/image.png i'll receive image size of 200x100, instead got, say, image of 180x100 or 200x90... gm(filelocation) .thumb(200, 100, 'processed.' + process.argv[2].split('.').pop(), function() { console.log("done!"); }); i've tried resize option. there's option force size, aspect ratio of output goes horrible... gm('/path/to/image.jpg') .resize(353, 257) .write(writestream, function (err) { if (!err) console.log(' hooray! '); }); try imagemagick package nodejs: https://github.com/yourdeveloper/node-imagemagick im.crop({ srcpath: process.argv[2], dstpath: 'cropped.' + process.

data.table - Data Tables in R: manipulating a column with/without a subset filter -

suppose have data table library(data.table) ff=data.table(date=c("2013-01-01","2013-01-02","2013-01-03","2013-02-02"),x=c(1,2,3,4)); setkey(ff,date) then works ff[,as.date(date)] doesn't ff['2013-01-01',as.date(date)] latter throwing error "error in as.date.default(date) : not know how convert 'date' class “date”" as @justin pointed out, fixed in next release. temp workaround 1.8.10 daisychain [][] in: ff['2013-01-01'][, as.date(date)] # or, if want dt back: ff['2013-01-01'][, list(as.date(date))]

visual studio 2012 - Compilation of detours on vs2012 (Windows 8.1) -

using visual studio 2012 command tools (i.e. in 'native tools command prompt' command console) have run vcvars32.bat , , navigated *c:\program file(x86)\microsoft research\detours express 3.0*. on running nmake in directory, begins building successfully, exits error: cl /nologo /nologo /zi /mt /gm- /w4 /wx /od /ddetours_bits=32 /i..\..\include /gs /ddetours_x86=1 /ddetours_32bit=1 /d_x86_ /ddetours_option_bits=64 /fdobj.x86\vc.pdb /foobj.x86\member.obj /c member.cpp member.cpp member.cpp(88) : error c2440: 'type cast' : cannot convert 'void (__thiscall cmember::* )(void)' 'pbyte &' reason: cannot convert 'overloaded-function' 'pbyte *' there no context in conversion possible member.cpp(90) : error c2440: 'type cast' : cannot convert 'void (__thiscall cdetour::* )(void)' 'pbyte &' reason: cannot convert 'overloaded-function' 'pbyte *' there no context in conversion possible // err

java - Image for ImageButton doesn't change as intended -

my goal here change image imagebutton(ibchamp). package com.example.custombuilds; import android.app.activity; import android.content.context; import android.content.intent; import android.os.bundle;z import android.view.layoutinflater; import android.view.view; import android.view.view.onclicklistener; import android.widget.imagebutton; public class champions extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.champions); imagebutton ibannie = (imagebutton) findviewbyid(r.id.ibannie); ibannie.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo check errors relativelayout test = (relativelayout) findviewbyid(r.id.layoutchampions); layoutinflater layoutinflater = (layoutinflater) getsystemservice(context.layout_inflater_service); view view = layoutinflater.inflate(r.

json - Map or Array for RESTful design of finite, unordered collection? -

a coworker , in heated debate regarding design of rest service. of our api, calls collections return this: get /resource [ { "id": 1, ... }, { "id": 2, ... }, { "id": 3, ... }, ... ] we must implement call collection of properties identifying attribute "name" (not "id" in example above). furthermore, there finite set of properties , order in sent never matter. spec came looks this: get /properties [ { "name": "{property_name}", "value": "{property_value}", "description": "{property_description}" }, { "name": "{property_name}", "value": "{property_value}", "description": "{property_description}" }, { "name": "{property_name}", "value": "{property_value}", "description": "{property_description}" }, ... ] my coworker th

javascript - Custom directive value with bindonce in Angularjs -

i got ng-repeat thousands of item in it, decided tryout bindonce reduce number of watches. couldn't figure out how use properly. got following code: <div ng-repeat="card in cards"> <div class="item-box" draggable="{{card.category}}" itemid="{{card._id}}"> <img ng-src="{{card.image}}" width="100%" height="100%"> </div> </div> as read in bindonce doc , should add directive , use bo-* directives, fugured out this: <div ng-repeat="card in cards" bindonce> <div class="item-box" draggable="{{card.category}}" itemid="{{card._id}}"> <img bo-src="card.image" width="100%" height="100%"> </div> </div> so question how can use {{card.category}} , {{card._id}} using bind-once? bo-attr bo-attr-draggable="card.category" bo-attr-itemid="

How to read this grammar? (The C Programming Language 2e) -

this grammar reference section of 'the c programming language 2e'. a.7.6 multiplicative operators the multiplicative operators *, /, , % group left-to-right. multiplicative-expression: multiplicative-expression * cast-expression multiplicative-expression / cast-expression multiplicative-expression % cast-expression i understand multiplicative-expression consists of 3 sub expressions. looks circular grammar me. because grammar not include terminal expressions 'primary expression'. how read grammar? the definitive reference should 1 of standards or draft standard both c99 , c11 publicly available. if @ draft c99 standard section 6.5.5 multiplicative operators grammar follows: multiplicative-expression: cast-expression multiplicative-expression * cast-expression multiplicative-expression / cast-expression multiplicative-expression % cast-expression

javascript - Generate layout histogram with specified parent values -

i new d3, project of d3 rough problem me , need help, have been search solutions days. the problem is, want draw hierarchical bar chart, every time 1 clicks bar, sub layout of bar shown, 1 http://bl.ocks.org/mbostock/1283663 , however, value of parent node sum value of children node. want set parent value myself , keep layout. json file is: { "name": "flare", "children": [ { "name": "analytics", "children": [ { "name": "cluster", "children": [ {"name": "agglomerativecluster", "size": 3938}, {"name": "communitystructure", "size": 3812}, {"name": "hierarchicalcluster", "size": 6714}, {"name": "mergeedge", "size": 743} ] }, i want

mysql - Insert values with auto-increment foreign keys -

i have database 3 tables: matrix, mark , matrix-mark (the relationship between matrix , mark n-n). here attributes of each one: matrix: mx_id (auto-incremented); name; mark: mk_id (auto-inc); name; color; matrix-mark: mk_id (fk); ma_id(fk). for example, how insert multiple marks associated same matrix? i'm getting values through php post. thanks in advance. in php on inserting record u can last inserted id. there function this. mysql_query("insert matrix(name) values ('deepak')"); $matrix_id = mysql_insert_id(); mysql_query("insert marks(name,color) values ('deepak','white')"); $marks_id = mysql_insert_id(); // u can insert these 2 id in third table..

android: how do I add padding to a LinearLayout inside a FrameLayout -

i have framelayout many children. 1 of children linearlayout. want width of linearlayout match_parent 90% so; means want add sort of paddingleft/right or margingleft/right . when add padding or margin, not applied in graphical layout. how do correctly? <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/blue" > <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal" android:background="@color/red" android:marginleft="20dp" android:marginright="20dp" android:orientation="vertical" > .... you have android:marginleft="20dp" android:marginright="20dp" instead change t

ajax - why error function is invoked when form data is submitted to google forms? -

i using jquery ajax post form data google forms. every thing works fine instead of done function fail function invoked ready state 4, status code 404, status text error. form data inserted successfully. in nettabs says 200 ok. can tell me why invokes fail function? here's code: var params = { "entry.870461494" : $('#name').val(), "entry.1837540694":$('#email').val(), "entry.794973559" : $('#cname').val(), "entry.1682659266" : $('#cnumber').val(), "entry.1004228063" : $('#city').val(), "entry.874570127" : $('#interested_in').val(), "entry.1619445424" : $('#bcategory').val().join() } $.ajax({ url : "https://docs.google.com/a/<company-name>/forms/d/<key>/formresponse", data: params, type : "post", datatype: "xml" }) .done(function( msg ) { alert( "saved google docs: " + msg ); }) .fail(functi

c - Generating correct .DEF files to export non-static functions AND GLOBALS -

following on a question detecting bad linkage globals across dll boudaries , turns out need modify .def file generator tool used postgresql project correctly emits data tags .def entries global variables. problem i can't seem find way, using microsoft's tools, symbol table listing differentiates between global variables , functions, , includes globals aren't initialized @ definition site. ideas? broken current approach the tool loops on dumpbin /symbols output generate .def file. unlike nm , i'm used to, dumpbin /symbols not appear emit entry each symbol indicate symbol type - function, initialized variable, uninitialized variable. shows whether symbol locally defined or not. with each dumpbin output line followed corresponding definition in .c file, have first initialized global: 00b 00000000 sect3 notype external | _defaultxactisolevel int defaultxactisolevel = xact_read_committed; vs function non-static linkage: 022 0000

angularjs - Yeoman Generated Angular Project Imported into IntelliJ -> Huge Mess -

the project generated looks pretty nice. intellij finds socket.io/flash app in node_modules , tries make module out of that. app folder not there. think based on angular seed. can't believe no 1 has tried though. only option create empty idea project , move folders there. or else you'll have use webstorm.

user interface - UI solution for C++ / Visual Studio 2012? -

new programmer question! goal code simple ui's visualize c++ assignments have. there native solution use in c++ in visual studio 2012? looking like: #using <some_ui_solution> class window(....) : ..... { gridlayout(.... show(); }; i've looked around bit, , overwhelmed info out there. help! feel free edit question needed.

jquery - how to create a radio button in jqgrid -

this jqgrid cheack box not take value @ time of click submit button please 1 me.. edittype:'custom', editoptions: { custom_element: function() { var elemstr = '<div class="col-xs-3">'+ '<label>'+ ' <input type="checkbox" class="ace ace-switch ace-switch-4" name="alternatemobilenumber">'+ ' <span class="lbl"></span>'+ '</label>'; return $(elemstr)[0]; }, custom_value: function(elem) { var op = ($('input[name="alternatemobilenumber.value()"]').attr('checked'))? "1":"0"; return op; } }, change custom value function like, custom_value: function(elem) { var op = $('inpu

laravel - Is it possible to have a HasManyThrough relationship that's deeper than two levels? -

i have following models: product baseproduct basecode series each of them of separate entity, they're related. product has foreign key baseproduct , baseproduct has foreign key basecode , basecode has foreign key series . i have specified method within basecode model can select of products related particular basecode : public function products() { return $this->hasmanythrough('product', 'baseproduct', 'basecodeid', 'baseproductid'); } basecodeid pk basecode , fk in baseproduct pointing pk, , baseproductid pk baseproduct , , in product table, there's fk points it. this , good, , works dandy me. i'd go 1 level further though, , define following in series model: public function products() { //it's here i'd have no idea - there three-level deep "hasmanythroughthrough" or something? return $this->baseproducts()-> /* , whatever i'd here products */ } public function basep

mysql - How to insert into a table from another table and from user input? -

what trying this insert books(borrower_name,isbn) values("jane",select isbn table...); this wrong obviously. trying work way (if did). you very close insert books (borrower_name, isbn) select 'jane', isbn table_name -- id = ? you might want limit number of rows coming table_name using where clause , proper condition(s) here sqlfiddle demo more on if meant return select only scalar value (just 1 isbn) correct in first place , could've used syntax showed in question insert books (borrower_name,isbn) values ('jane', ( select isbn table_name id = 1 )); here sqlfiddle demo

checkbox - Android - checked perform action -

Image
as i'm new android, problem i'm developing application want increment/decrement numbers clicking on buttons in home page,but first of should check in settings menu check box checked,if checked perform actions... mainactivity.java package com.example.sanple; import android.app.activity; import android.content.intent; import android.content.sharedpreferences; import android.content.sharedpreferences.editor; import android.os.bundle; import android.preference.preferencemanager; import android.util.log; import android.view.keyevent; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.view.window; import android.view.windowmanager; import android.widget.button; import android.widget.checkbox; import android.widget.textview; import android.widget.toast; public class mainactivity extends activity { public button incre; public button dec; publ

java - Invalid content was found starting with element 'elementName'. No child element is expected at this point -

i'm working xml , i'm using xsd validate xml file. xsd , xml file long , can give part of them. xsd file: ... <xs:complextype name="banktype"> <xs:choice> <xs:element name="code" type="codetype" minoccurs="1" maxoccurs="1" /> <xs:element name="newcode" type="codetype" minoccurs="0" maxoccurs="1" /> <xs:element name="swiftbic" type="swifttype" minoccurs="0" maxoccurs="1" /> <xs:element name="name" type="nametype" minoccurs="0" maxoccurs="1" /> <xs:element name="coraccount" type="accounttype" minoccurs="0" maxoccurs="1" /> <xs:element name="subcoraccount" type="accounttype" minoccurs="0" maxoccurs="1" /> <xs:element n

html - How to display a full-width grid of images that resizes and flows with the browser window with pure CSS -

Image
i'm trying display set of images in grid, , reproduce effect of album grid view in itunes pure css, if possible. desired functionality (video: http://quick.as/17l3sdgr ): the images should displayed in grid padding, filling browser width. when window resized, images & padding shrink until minimum img width (let's 150px). then 1 image pushed next row, , images become bigger until window width decreased again. i know possible javascript, css provide better performance. possible? edit: recorded screencast show functionality itunes: http://quick.as/17l3sdgr try (untested) fiddle css : img{ float:left; width : 10%; padding : 1%; max-width : 150px; min-width : 50px; } html : <img src="yourimage.jpg" /> <img src="yourimage.jpg" /> <img src="yourimage.jpg" /> <img src="yourimage.jpg" /> <img src="yourimage.jpg" /> <img src="yourimage.jpg" />

http - Reason for browser not showing X-Forwarded-For headers -

note : please read full question i'm trying understand why browsers doesn't show me x-forwarded-for header every time request page btw here request headers like request url:http://localhost:3000/users/sign_in request method:get status code:304 not modified request headers: accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding:gzip,deflate,sdch accept-language:en-gb,en-us;q=0.8,en;q=0.6 cache-control:max-age=0 connection:keep-alive cookie:undefined=0; poasterapp=s%3a4faaa6b1723e7c6fbd949083532c52598652547b.snx%2bkoeed2teqkqn7i7k5lgpohmrpwerkfvuegmntvi; _minerva_session=bah7cukid3nlc3npb25fawqgogzfrkkijweym2q0ztvimweyodbiymfmodewztjhzmuwnwu5odk5bjsavekie3vzzxjfcmv0dxjux3rvbjsariigl0kicmzsyxnobjsarm86jufjdglvbkrpc3bhdgnoojpgbgfzado6rmxhc2hiyxnoctokqhvzzwrvoghtzxqgogpaagfzahsgogphbgvydfq6debjbg9zzwrgog1azmxhc2hlc3sgowpjigagowbuoglabm93mekief9jc3jmx3rva2vubjsarkkimun0uk56sxu0dudidzgwcfzjm3r0l2n4dlovrlltsgrrq2o1r0vvanhiavk9b

java - DefaultHttpMethodRetryHandler change the retry interval -

i using defaulthttpmethodretryhandler class retry failure request. i have tried httpclient client = new httpclient(); client.getparams(). setparameter(httpmethodparams.retry_handler, new defaulthttpmethodretryhandler( 3, false )); this retrying 3 times. have not found option retry request after 10 minutes or 1 hour. how can set intervals between retries? based on answer http://www.programcreek.com/java-api-examples/index.php?api=org.apache.commons.httpclient.defaulthttpmethodretryhandler , can use following: client.getparams(). setparameter(httpconnectionparams.connection_timeout, 2000); cheers!

.htaccess - Where does htaccess cut query string? -

here htaccess php_flag session.use_trans_sid off php_flag session.use_only_cookies on options +followsymlinks rewriteengine on rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\ http/ rewriterule ^(.*)$ http://automaticheskie-vorota.ru/? [r=301,l] rewritecond %{query_string} mosconfig_[a-za-z_]{1,21}(=|\%3d) [or] rewritecond %{query_string} base64_encode[^(]*\([^)]*\) [or] rewritecond %{query_string} (<|%3c)([^s]*s)+cript.*(>|%3e) [nc,or] rewritecond %{query_string} globals(=|\[|\%[0-9a-z]{0,2}) [or] rewritecond %{query_string} _request(=|\[|\%[0-9a-z]{0,2}) rewriterule .* index.php [f] rewriterule .* - [e=http_authorization:%{http:authorization}] rewritecond %{request_uri} !^/index\.php rewritecond %{request_uri} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [nc] rewritecond %{request_filename} !-f rewrit

Java collection program showing error - Stack is abstract, cannot be instantiated -

import java.util.*; public class stackdemo { public static void main (string[] args) { stack st = new stack(); } } while running code on jcreator jdk 1.6 error occured - stack abstract; cannot instantiated stack st = new stack(); otherwise program runs on online compilers http://www.compileonline.com/ please help. try do: java.util.stack st = new java.util.stack(); you have abstract class called stack in project. note stack raw type, don't forget infer generic type arguments.

asp.net - Special Characters with Data Annotation MVC4 -

i have done validations using mvc4 data annotations. and restricted special characters too. but want allow spaces between each words . i tried this: [required(errormessage = "category name should not empty")] [regularexpression(@"^[a-za-z0-9]+$", errormessage = "special character should not entered")] public virtual string name { get; set; } right system not allowing me insert. because have entered space. considering space special char. how allow space? same time above validation should work. myself found answer. instead of @"^[a-za-z0-9]+$" need add @"^[a-za-z0-9'' ']+$" . ''single space' in expression '' ' for more information i'd suggesting reading - using data annotations customize data classes (msdn)

What is =C in bash? -

i read in script somewhere : a_var=c ls i tried it. executes ls (i see content of current directory) , leaves a_var empty. =c in bash ? first time see it. this set environment-variable a_var "c" in environment ls runs in. used set collation ls uses influence sorting ( lang=c ls or lc_collate=c ls ). using c collation ls sort files case-sensitive, meaning files starting a-z come after a-z. other collations may have additional rules, such ignoring dots or treating umlauts vowels - c doesn't have this.

c# - WF Designer re-hosting System.StackOverflowException -

i need re-hosted designer of wf4. should used design complex workflow there limit of nested activities. (it's around 40th nested activities in 1 branch). if limit exceeded, system.stackoverflowexception occurred in presentationcore.dll. is there way, how increase limit system.stackoverflowexception? here code example download. after building , executing application, move scrollbars last activity number 40 , exception should occur. i can run without error , scroll bottom - though bit slow - (64 bit machine, 16 gb memory). you can allocate stack size on creation of new thread, don't know how change size default ui thread in application...and if can i'm not sure it'd idea. besides, increasing limit hiding overall issue - why need in first place - going nest 40 layers of complexity in workflow? unwieldy , incredibly difficult support. couldn't logic split sub workflows, etc?

jsf 2 - displaying the input value on confirm dialog returned null -

i working on j2ee6 project extract emails web browserrs. have command button calls extraction method after user entered emails number. once extraction completed confirm dialg shows , displaying number of emails extracted. here xhtml code: <h:form id="mainform"> <p:panel id="panelform" header="email extractor" > <h:panelgrid id="formulaire" columns="2"> <h:panelgroup id="formblock" layout="block" > <p:panelgrid columns="2"> <p:outputlabel for="emailsnbr" value="enter emails'number:" /> <p:inputtext id="emailsnbr" type="number" requiredmessage="emails number required" value=&

html - How to put alert on my all anchor tag using javascript -

how put alert on anchor tag using javascript , alert box show link & text of anchor tag you can document.getelementsbytagname , returns htmlcollection of elements given tag name. eventtarget.addeventlistener method registers specified listener on eventtarget it's called on. var anchors = document.getelementsbytagname("a"); (var = 0; < anchors.length ; i++) { anchors[i].addeventlistener("click", function (event) { event.preventdefault(); alert(this.href); alert(this.innerhtml); }, false); } fiddle note: have use event.preventdefault() , cancel anchors default behaviour , addeventlistener supported in ie9+

ruby on rails - Simple_form, edit multiple associated items -

i'm trying edit multiple association in single form. i'm using simple form , association easy: class gallery has_many :pictures end class pictures end every picture has image , caption, have uploaded pictures in separated form: need add caption text every picture in single form. i try simple_form doing this: = simple_form_for [:admin, gallery] |form| - if gallery.pictures.present? - gallery.pictures.each |p| = image_tag(p.image.url(:thumb), height: '50') but cannot find way add caption text field every picture of gallery. any hint? use method simple_fields_for nested resources example: simple_form_for [:admin, @gallery] |f| f.simple_fields_for :pictures |p| # here have simple_form methods available p.input :caption end end also, add line gallery class #this allow save attributes on associated records through parent accepts_nested_attributes_for :pictures update - show small thumb inside for

date - How to retrieve provider time in Android programmatically? -

i doing android app has display current server/network operator time since device time can changed user. don't want change/set device time. tried few source codes didn't work well. i'm able device date , time need date , time server or network provider itself. please me it seems need interface network time protocol (ntp). there similar questions here on use of ntp service , get datetime network provider (as noted gheo) suggesting to: use android.net.sntpclient.java source code , javadocs read through this google groups thread as noted in comments of these posts, of honeycomb cannot network operations in main activity thread (suggestion: use service instead). update: a further search led me find dominik schürmann's ntp-sync repository on github. provides different examples of how can use library can compile , run on emulator/device.

Dynamic menu from PHP array -

hey have question dynamic menu created in php. code stackoverflow, want parent styled red color if children of parent selected, here code: $menu = array( array( 'title' => 'home', 'link' => 'a' ), array( 'title' => 'parent', 'link' => 'b', 'children' => array( array( 'title' => 'sub 1', 'link' => 'c' ), array( 'title' => 'sub 2', 'link' => 'd' ), ) ) ); function buildmenu($menuarray) { foreach ($menuarray $node) { $selected = ($node['link']== $_get['menu']) ? $selected = 'style="color: red;"' : null; echo "<li ".$selected."><a href='?menu=".$node['link

ruby on rails - New password is only accepting old password not different password -

in rails 3.2.13 project, using devise plugin. if going change password need enter current_password 3 fields, if try enter different password new_password & confirm_password fields show error message "current password invalid". i have referred https://github.com/plataformatec/devise/blob/bf5bcd52cb9edaefb002927434d7ede398e74bc5/lib/devise/models/database_authenticatable.rb#l46 in model, def valid_password?(password) return false if encrypted_password.blank? bcrypt = ::bcrypt::password.new(encrypted_password) password = ::bcrypt::engine.hash_secret("#{password}#{self.class.pepper}", bcrypt.salt) devise.secure_compare(password, encrypted_password) end def update_with_password(params, *options) current_password = params.delete(:current_password) if params[:password].blank? params.delete(:password) params.delete(:password_confirmation) if params[:password_confirmation].blank? end result = if valid_password?(current_password) update_att

curl - Bash Script: Help find the bug -

i'm trying run script import action via rightscale's api, keeps reporting "bad request 400" second curl operation, , looks url isn't forming correctly. i've tried putting post url in double-quotes, didn't change result. both accountlist.txt , templatelist.txt have account numbers , template numbers respectively, 1 on each line. debug, i've put 1 account number , template number in each file, respectively. please me understand what's wrong piece of code. i'm guessing it's trivial, can't understand is: cat "accountlist.txt" | while read acc ; rm scriptcookie curl -i -h 'x-api-version:1.5' -c scriptcookie -d email="emailid@company.com" -d password="p@sswd" -x post -d account_href="/api/accounts/$acc" https://my.rightscale.com/api/sessions cat "templatelist.txt" | while read temp ; echo $temp curl -i -h 'x_api

encryption - Reading Password-Protected ZIP Files in Java -

i have zipped , protected file password. need retrieve file java. need unlock password , unzip java make proper connection file. my first questions is: java unzip , unlock zipped file on local drive? (so no point protecting it?). i have read encryption, searching easiest way here. link: http://blog.alutam.com/2009/10/31/reading-password-protected-zip-files-in-java/ my second question link above: cannot find lines pointing zipped file on local drive+ password uses unlock file (is hardcoded?) thank you you may want have on zip4j key features: create, add, extract, update, remove files zip file read/write password protected zip files supports aes 128/256 encryption supports standard zip encryption supports zip64 format supports store (no compression) , deflate compression method create or extract files split zip files (ex: z01, z02,...zip) supports unicode file names progress monitor

javascript - precompile angular js template to speed up application startup -

i have big angular application 5 templates included in main page using <script type="text/ng-template" id="/mymaintemplate.html">...</script> <script type="text/ng-template" id="/mytemplatepage2.html">...</script> <script type="text/ng-template" id="/mytemplatepage3.html">...</script> <script type="text/ng-template" id="/mytemplatepage4.html">...</script> however, application takes lot of time startup. removing templates 2/3/4 fix of course broke app, guess angularjs takes time compile 5 templates. is there way pre-compile angularjs templates, example nodejs or similar (the same way can compile templates handlebar maybe) ? if understand $compile instruction, idea move instruction $compile(mytemplate) in server-side inside of client take @ grunt-html2js task. https://github.com/karlgoldstein/grunt-html2js it converts plain angul

javascript - how to allow drag and drop in multiple divs using html5 -

am trying build form using html5.. have 1 div contains list of fields , and div can put fields build form.. on dropping text name respective text field , label drooped in div.. want create 2 divs can put fields in 2 divs can 1 tell how using code working 1 div <html> <head> <title>drag , drop</title> <link rel="stylesheet" type="text/css" href="css/style.css"> <script type="text/javascript"> var i=0; function allowdrop(ev) { ev.preventdefault(); } function drag(ev) { ev.datatransfer.setdata("text",ev.target.id); } function drop(ev) { i++; ev.preventdefault(); var data=ev.datatransfer.getdata("text"); //alert(data); var field_type=field_set(data); var output=document.getelementbyid("div1"); if(!document.getelementbyid('drag'+i)) { var ele = document.createelement("div"); ele.setattribute("id"

c# - Need to install thirdparty software before my setup.exe installs in VS 2010 -

i have created setup.exe project. need add custom action where-in checks if given thirdparty software installed or not. if not install; proceed installation of thirdparty software install project setup. how do quickly. c# used coding langauge , on windows os. you may able use bootstrap manifest generator tool. it's way add own search , install of prerequisites beyond ones visual studio setups supply.

java - android.text.BoringLayout declares multiple JSON fields named mPaint? -

can tell me in hell going on here? 02-06 09:51:41.609: e/acra(15955): com.goosesys.dta_pta_test fatal error : unable start service com.goosesys.dta_pta_test.bgcollectorproc@4232c178 intent { flg=0x4 cmp=com.goosesys.dta_pta_test/.bgcollectorproc (has extras) }: java.lang.illegalargumentexception: class android.text.boringlayout declares multiple json fields named mpaint 02-06 09:51:41.609: e/acra(15955): java.lang.runtimeexception: unable start service com.goosesys.dta_pta_test.bgcollectorproc@4232c178 intent { flg=0x4 cmp=com.goosesys.dta_pta_test/.bgcollectorproc (has extras) }: java.lang.illegalargumentexception: class android.text.boringlayout declares multiple json fields named mpaint 02-06 09:51:41.609: e/acra(15955): @ android.app.activitythread.handleserviceargs(activitythread.java:2515) 02-06 09:51:41.609: e/acra(15955): @ android.app.activitythread.access$1900(activitythread.java:133) 02-06 09:51:41.609: e/acra(15955): @ android.app.activitythread$h.handlemessage(act

OpenID realm field for user authentication in packaged chrome app -

if i'm using google openid authenticate users packaged app need fill in openid realm field. problem have no clue enter. documentation sais: in text field appears, enter realm app use query google's openid service. must same value of openid.realm field in authentication requests. what should enter? can see/get value? openid realm used when migrating openid 2.0 protocol openid connect. basically if don't know specify there may leave blank, in general field value must correspond openid.realm request parameter (optional) when building authentication request google. please, read migrating openid 2.0 openid connect , openid connect documents google identity platform section more details. p.s. please, tag openid related question google-oauth label response ;)

php - Push notification using Azure -

i want implement push notification service of azure. i need service functional on android , iphone , windows phone 8 . earlier have done using gcm-android , apns-iphone. i need implement same using azure only, , local server in php. when implementing code want separate devices on php server on random basis , categorized them in groups. notification should sent groups , users(devices). how can handle situation. have tried implementation of notification hub implementing group fails. have tried implement using mobile services , ends nowhere. have tried set tag on php server no positive output. i new this, great if can tutorial or sample.

join - mysql select multiple tables - return results eventhough the other tables is empty -

select * deliveries, remittance table 'deliveries' has 10 records while table 'remittance' has none. query returns no results. want mysql return 10 records table 'deliveries'. please me. this sample table deliveries -> trans_number to remittance -> trans_number to try like select * deliveries left join remittance on remittance.id = deliveries.remittance_id it bring data deliveries , matching data remittance update: if want show records in case if table has records looking full outer join but since full outer join not supported in mysql try query select * deliveries left join remittance on remittance.id = deliveries.remittance_id union select * deliveries right join remittance on remittance.id = deliveries.remittance_id

How to sign my android project in jenkins? -

Image
i using jenkins use build --> invoke ants --> targets --> clean debug debug build (apk) it. want signed apk jenkins. have added settings in build --> invoke ants --> targets --> clean release . know 1 not enough signed apk build out jenkins. else should add signed apk ? please me on this. give me detailed explanation because new this. these parameters have added. from jenkins documentation : running build in hudson part easy: create new freestyle job , let build ant. targets want execute clean release. release compile, package , sign apk . working right, custom properties should set (use advanced button). sdk.dir=/users/hugo/code/android-sdk-mac target=google inc.:google apis:7 key.store=certs/rd-release.keystore key.alias=rainydays key.store.password=thisisnotmypassword key.alias.password=thisisnotmypassword the sdk.dir should point android sdk root on hudson node. in case i'm running hudson locally o

php - codebird array showing tweets using api -

ok, using codebird read , write tweets using php. it's twitter account protected need use api display tweets on our private network. able make tweets without problem, it's retrieving our own tweets i'm struggling with. $reply = (array) $cb->statuses_hometimeline(); print_r($reply); this gives output of (this first 1 in array) array ( [0] => stdclass object ( [created_at] => thu feb 06 09:08:43 +0000 2014 [id] => 431353751824134144 [id_str] => 431353751824134144 [text] => test 3 [source] => web [truncated] => [in_reply_to_status_id] => [in_reply_to_status_id_str] => [in_reply_to_user_id] => [in_reply_to_user_id_str] => [in_reply_to_screen_name] => [user] => stdclass object ( [id] => 2292936619 [id_str] => 2292936619 [name] => jpress support [screen_name] => jpresssupport [location] => [description] => automated account letting know of issues. tweets made account not seen. thanks, johnston press it. [url]

Angularjs Html5 mode links doesn't work -

i using angularjs in parts of page , need html5 mode reading parameters url. problem whenever turn on html5 mode simple static links doesn't work, url being changed in navigation bar doesn't change page ? there way make simple html links work in html5 mode ? you have configure apache (or nginx, or node, or whatever server using) return index.html page when accessing domain. way, html5 mode in angular work regular page link

javascript - Why this window.opener.reload is not a function error? -

i have snippet this. if (window.opener != null) { window.opener.reload(); } when called, firebug shows, typeerror: window.opener.reload not function and chrome console says, uncaught typeerror: object [object global] has no method 'reload' what wrong? p.s: typeof window.opener "object" . reload method of location object, not window object. window.opener.location.reload();