Posts

Showing posts from February, 2015

concurrency - Java - notify() vs notifyAll() - possible deadlock? -

is there situation in notify() can cause deadlock, notifyall() - never? for example, in case of multiple locks. notify() notifies 1 thread run, checks lock object , becomes waiting again, though thread unlock object. in case of using notifyall() , threads notified run , 1 of them in turn unlock object sure. yes. imagine implement producer - consumer problem synchronize, wait, , notify . (edit) in 2 producers , 2 consumers wait on same object monitor (end edit) .the producer calls notify in implementation. suppose have 2 threads running producer's code path. possible producer1 calls notify , wakes producer2. producer2 realizes can not work , subsequently fails call notify . deadlocked. (edit) had notifyall been called, both consumer1 , consumer2 have woken in addition producer2. 1 of consumers have consumed data , in turn called notifyall wake @ least 1 producer, allowing broken implementation limp along successfully. here reference question base scenario

open source - Is one license file enough if I have subdirectories in my project? -

i want publish project under gnu general public license, version 3. i publish zip file, contains subdirectories code , data. have gpl license file in top-directory , refer in readme file. do have to, subdirectories, add license file? typically there 1 copying file @ root of project. can find guidelines on how free software foundation suggests apply gnu licenses (e.g. gpl, lgpl) software: how use gnu licenses own software for apache software license - have not asked give second example - little different due differences in license. it, typically there 1 license , if applicable notice file @ root of project. can find guidelines on how apache foundation here: assembling license , notice

Powershell add header/row to CSV -

i have piece of code generates csv of sharenames filer. its tab-delimited csv , sharenames, no other details included. i'd take output: 010 2012 comp 2012 comp plan team and replace this: \\<filer>\010 \\<filer>\2012 comp \\<filer>\2012 comp plan team right have following: $content = import-csv c:\temp\new.txt -delimiter "`t" can use add-member command add in new property/values array? or going wrong way? the comments have been great far, guys. forgot add point this. wondering how might add column csv? strictly filer names. i'm thinking of producing massive csv of share names , filer names. wanted know how add it? if you've shown content of file there's no need bother import-csv , use get-content : (get-content 'c:\temp\new.txt') -replace '^', '\\<filer>\' the above produces merely array of strings. make csv 2 columns several things, instance transform string array arra

Android NDK UnsatisfiedLinkError - a surprising reason -

update 8/7/2013: problem solved now, reason error quite unexpected, usual suspects such errors eliminated on start, , have learned new. see answer below. i'm pretty desperate here. have android app native library, call method. no problem on systems tested, , program out in google play without trouble reports, used thousands of users. now, apparently new rom - android version 4.2.2 - htc 1 phone out. users claim it's official build, upgraded form official channel. when try start app, crashes, , stack trace says: java.lang.unsatisfiedlinkerror: native method not found... and method name of know there , worked fine moment ago on same device when had android 4.1 installed. test under android 4.2.2 in emulators (don't have particular device) , there no problem. also, users tried uninstalling , reinstalling app same result. sending them private build, without proguard/dexguard protections not help. what else can cause java.lang.unsatisfiedlinkerror on android? or s

asp.net - {"Object reference not set to an instance of an object."} -

creating asp.net form c#, facing error don't know error it. doing fine when push save button gives me error: nulllrefrenceexception unhandled user code {"object reference not set instance of object."} object reference not set instance of object. code: protected void button8_click(object sender, eventargs e) { sqlconnection cnn = new sqlconnection(); cnn.connectionstring = system.configuration.configurationmanager.connectionstrings["sqladdsave"].connectionstring; cnn.open(); sqlcommand cmd = new sqlcommand(); cmd.commandtext = "select * displaypp"; cmd.connection = cnn; sqldataadapter da = new sqldataadapter(); da.selectcommand = cmd; dataset ds = new dataset(); da.fill(ds, " displaypp "); sqlcommandbuilder cb = new sqlcommandbuilder(da); datarow drow = ds.tables["displaypp"].newrow(); drow["website"] = web.text; drow["countr

graphics - Why is the transitive closure of matrix multiplication not working in this vertex shader? -

this can filed under premature optimization, since vertex shader executes on each vertex each frame, seems worth doing (i have lot of vars need multiply before going pixel shader). essentially, vertex shader performs operation convert vector projected space, so: // transform vertex position projected space. pos = mul(pos, model); pos = mul(pos, view); pos = mul(pos, projection); output.pos = pos; since i'm doing operation multiple vectors in shader, made sense combine matrices cumulative matrix on cpu , flush gpu calculation, so: // vertexshader.hlsl cbuffer modelviewprojectionconstantbuffer : register (b0) { matrix model; matrix view; matrix projection; matrix cummulative; float3 eyeposition; }; ... // transform vertex position projected space. pos = mul(pos, cummulative); output.pos = pos; and on cpu: // renderer.cpp // time update cummulative matrix m_constantmatrixbufferdata->cummulative = m_constantmatrixbufferdata->model *

Rails redirect with collection_select and javascript -

i have collection_select fires js set id in url when click occurs. here code. application.js $(document).ready(function(){ $("#org_id").on("change", function(){ val = $(this).val(); window.location = '/sessions?org_id='+ val; }); }); view <div id="org-select"> <%= collection_select :org, :id, org.all, :id, :name %> </div> rendered html <div id="org-select"> <select id="org_id" name="org[id]"><option value="1">bustas</option> <option value="2">wintas</option></select> what of give me url /sessions?org_id=2. the issue having select box in page defaults first org, , when user changes option in select, page fires/refreshes, page defaults first org, id in url not change. well, collection_select have option set default value. can see on last example provided user here: http://apidock.com/rai

box api - Box-api simple uploader -

i'm writing new apps run on windows (desktop mode, not store app/windows phone). i’d applications able upload files box anonymously, or single hard-coded username , password. there easy way box-api? have go through oauth2 simple uploading? you need use oauth 2, , additionally need box account every user of service.

windows 7 - Avoid UAC prompt in Qt 5.1 lupdate -

i using qt 5.1.0 bundled mingw 4.8 (32 bit) on win7 64. i want run lupdate.exe create , update translation files. however, every run of lupdate demands administrator access rights , windows uac prompt need accept. annoying. issue arises @ lupdate. lrelease other qt tools run expected. not sure whether relevant: lupdate.exe installed in default path, c:\qt\5.1.0\mingw48_32\bin\lupdate.exe. i not see reason why lupdate needs admin rights , not case in former versions. so, why installation prompt them? how can avoid it? this because windows checks file name , assumes containing "update", "install", or "uninstall" in file name installer, , requires administrative privileges run, regardless of whether has manifest or not. done old legacy installers created before uac existed continue work. rename "lupdate.exe" doesn't contain "update", , uac prompts stop.

changing/updating app with mouse click - kivy -

i'm working on mobile app first time kivy. i've made progress , have "main" page shows before else. user press button , page change little more useful. at moment giant button , when click on nothing happens... i'm new kivy , awesome. i've tried comment code "think" happening. from kivy.uix.widget import widget kivy.uix.boxlayout import boxlayout kivy.uix.gridlayout import gridlayout kivy.uix.carousel import carousel kivy.uix.label import label kivy.uix.button import button kivy.graphics import color kivy.app import app kivy.graphics.instructions import canvasbase carousel_output = [0,1,2,3,4,5,6,7,8,9] class myapp(app): def build(self): #for starters show big button call #showdata when clicked. b = button(text='click me!!!') self.layout = gridlayout(cols=1,rows=4,spacing=[2,0]) self.layout.add_widget(b) #i pass layout thinking can #not sure need change make work

java - Alternative locations for Hibernate mapping files? -

i read introductory tutorial on hibernate had mapping files inside same source directory of entities represented: testproject/ src/main/java/ com.hibernate.tutorial.entities student.java student.hbm.xml course.java course.hbm.xml etc. normally, place config files under src/main/config , , ideally i'd have following project directory structure: testproject/ src/main/java/ com.hibernate.tutorial.entities student.java course.java src/main/config hibernate/ student.hbm.xml course.hbm.xml is there way this, , if so, how? in advance! there 2 ways map pojo class hibernate entity: xml mapping using annotations annotations becomes more prevalent last years. examples find here: example1 example2

jpa - How can I create multiple composite foreign key constraints which reference the same table? -

i using eclipselink 2.4.0 , trying find way generate following ddl statements: alter table delta add constraint deltafk1 foreign key (appkey, newrevision) references revision (appkey, revision); alter table delta add constraint deltafk2 foreign key (appkey, oldrevision) references revision (appkey, revision); each row in delta table represents changes between 2 specified revisions , primary key made of appkey, newrevision, , oldrevision. first alter statement being generated following relationship annotations defined in delta.java class: public class delta { @embeddedid private deltapk deltapk; @manytoone @primarykeyjoincolumns({ @primarykeyjoincolumn(name="appkey", referencedcolumnname="appkey"), @primarykeyjoincolumn(name="newrevision", referencedcolumnname="revision") }) private revision newrevision; @manytoone @primarykeyjoincolumns({ @primarykeyjoincolumn(name="appkey", referencedcolumnname="

angularjs - ngHide and ngAnimate with max-width: transition property on the wrong class? -

i'm using nganimate animate max-height simple slide-toggle effect, , there's bit strange happening: when hiding , seems setting transition property on setup class ( .xxx-hide ) doesn't work--the height snaps 0 immediately: .controls-hide { -webkit-transition-duration: 1s; -moz-transition-duration: 1s; -o-transition-duration: 1s; transition-duration: 1s; max-height: 5em; opacity: 1; } .controls-hide.controls-hide-active { max-height: 0em; opacity: 0; } but setting on active class ( .xxx-hide.xxx-hide-active ), animation works fine: .othercontrols-hide { opacity: 1; max-height: 5em; } .othercontrols-hide.othercontrols-hide-active { -webkit-transition-duration: 1s; -moz-transition-duration: 1s; -o-transition-duration: 1s; transition-duration: 1s; max-height: 0em; opacity: 0; } (here's whole fiddle. ) even more strangely, opacity animates fine in both cases. what's going on here? i follow instructions @ site: h

forms - Change images from a select field using Javascript -

so i'm trying change image based on option user selects dropdown menu. images "cyan.png", "magenta.png", "yellow.png", "black.png", , "fuschia.png". my html <select name="color" multiple> <option>cyan</option> <option>magenta</option> <option>yellow</option> <option>black</option> <option>fuschia</option> </select> my javascript // part tries load images onto cararray variable var namearray = new array("cyan.png", "magenta.png", "yellow.png", "black.png", "fuschia.png"); var cararray = new array; for(var = 0; < cararray.length; i++) { cararray[i] = new image; cararray[i].src = namearray[i]; } // part tries (and fails) change image when user selects color dropdown menu window.onload = function() { var colorpicker = document.getelementsbyname("color").selectedindex;

server not parsing php file called from jquery ajax -

im using basic jquery ajax call. i make call php file without input parameters option datatype set json . i want server parse php queries table in mysql db, convert array , encode json , return . i tried test call browser copying php file url in address field, , shows works, since can see blank page rows of table in json formatting. instead, when calling javascript code $.ajax call fails error requested json parse failed which means ajax call expecting json (since set option datatype that) received format. so tried removing datatype option call, , lo , behold got response success , did received php file? well, whole code in file, server doesn't parse cause thinks it's plain text. is there way out of problem? thanks. send content header json data <?php header('content-type: application/json'); echo json_encode($data);

coldfusion - Is cfexecute timeout=0 as good as cfthread action=run if no output needed? -

looking @ legacy code , programmer in question uses: <cfthread action="run"> <cfexecute name="c:\myapp.exe" timeout="30"> </cfthread> can 1 safely replace code above this? <cfexecute name="c:\myapp.exe" timeout="0"> is cf going spawn thread in code above anyway? , thread going counted towards "maximum number of threads available cfthread"? if intent have non-blocking flow of code, can safely replace earlier code yours. in understanding, cf not creating thread when gets timeout="0". must calling exe (which creates new process on server) , never wait process reply. so, nothing added thread limit count.

android - QuickAction by Lorensius -

i'm attempting removed deprecated code getwidth(); code before going production. i've tried few of ways mentioned here @ stack other classes cannot seem work this. know can here? public class quickaction extends popupwindows implements ondismisslistener { ... public void show (view anchor) { int screenwidth = mwindowmanager.getdefaultdisplay().getwidth(); ... } i not sure have tried far, use this: final int version = android.os.build.version.sdk_int; display display = mwindowmanager.getdefaultdisplay(); int screenwidth; if (version >= 13) { point size = new point(); display.getsize(size); screenwidth = size.x; } else { screenwidth = display.getwidth(); } like javadoc says method display.getwidth() deprecated in api level 13 should use display.getsize(point) instead. in case don't "magic" numbers, instead of 13 can use android.os.build.version_codes.honeycomb_mr2 .

jquery mobile - More graceful way of releasing JQM page transition lock -

i'm adding exception handling jqm app , i'm having trouble page transitions. in nutshell, i'm doing this: window.onerror = function myerrorhandler(errormsg, url, linenumber) { // crap, bad happened somewhere. // tell user // report testflight // @ variables in memory , try determine how gracefully recover. } overall working - can return user main menu or "safe" recovery point, instead of app turning rock. the problem this: if exception happens during initialization of page, jqm's "ispagetransitioning" flag left true. thus, won't accept more $.mobile.changepage() calls. there function in jqm called releasepagetransitionlock() fixes problem. not exposed publically, however. i hacked jqm adding method: $.mobile.releasepagetransitionlock = function() { releasepagetransitionlock(); } works perfect - i'd rather not hack jqm file. is there reasonable way access releasepagetransitionlock() within jqm's pr

flash - AS2 Enemy 'sliding' off of each other -

what best way handle enemies 'sliding' off of each other , preventing them overlapping? used in 3d games. i'm not sure start, thoughts? first, may make sense use existing library such box2d. secondly, sliding problem caused hit testing code. more likely, wait 2 enemies hit each other, detect hittest, , move them little bit. sliding happens repeatedly hitting, moving back, moving forward, hitting, moving back, moving forward, hitting, moving back... basic solution problem detect enemies going hit in next iteration, , avoid actual hit. need work out enemies going in next iteration, , check if, in next iteration, bounding boxes going intersect. if going intersect on next iteration, need handle 'hit'. so basically, enemies never hit or overlap. prevent it.

php - Storing formatted text from tinymce in database -

i have tinymce textarea put in default text page loaded. text formatted bold faced , underlined. of works well. however, when go store text in mysql database, following error: error adding email database: have error in sql syntax; check manual corresponds mysql server version right syntax use near ... @ line 5 here how creating default text inside of textarea; window.onload = function formattext() { tinymce.get("results").setcontent("<b><u>results</b></u><br><br><br>"); tinymce.get("upcoming_races").setcontent("<b><u>upcoming events</b></u><br><br><br>"); tinymce.get("thisweek").setcontent("<b><u>this week's training</b></u><br><br><br>"); } when take code out , type text in manually (along formatting text using tinymce buttons), saves in database perfectly. don'

java - How can we merge elements from different look and feels? -

Image
i beginner in java gui, , want set looking , feel; problem don't of , feel completely. has , bad styles. being specific, using nimbus , feel, table , text area of liquid , feel. want use nimbus , feel default, use jtable , jtextarea of liquid , feel. possible? please answer using easy vocabulary, said beginner. ps: use netbeans. you may able use ad hoc approach shown here jtree icons. left: com.apple.laf.aqualookandfeel right: javax.swing.plaf.metal.metallookandfeel addendum: while not combinations compatible, can examine defined uimanager defaults keys common both. few jtable examples shown here .

how can I use multiple paths in php if statement -

<?php if (preg_match('/\/contact\//', $_server['request_uri']) === 1): ?> <a href="/">link</a> <?php endif; ?> i'm trying add multiple folders same statement /contact/ , /news/, content inside statement appear in both folders. i tried (preg_match('/\/contact\//', '/\/news\//', $_server['request_uri']) , returned errors. what doing wrong? you can use | (or) operator in regexp. <?php if (preg_match('/\/(contact|news)\//', $_server['request_uri']) === 1): ?>

Is there a CSS parent selector? -

how select <li> element direct parent of anchor element? in example css this: li < a.active { property: value; } obviously there ways of doing javascript i'm hoping there sort of workaround exists native css level 2. the menu trying style being spewed out cms can't move active element <li> element... (unless theme menu creation module i'd rather not do). any ideas? there no way select parent of element in css. if there way it, in either of current css selectors specs: selectors level 3 spec css 2.1 selectors spec in meantime, you'll have resort javascript if need select parent element. the selectors level 4 working draft includes :has() pseudo-class works same jquery implementation . of april 2017, this still not supported browser . using :has() original question solved this: li:has(> a.active) { /* styles apply li tag */ }

apache - Apache2::RequestRec doesn't have 'param' method for Session::Wrapper -

got error in mason handler on new web server migrated apache1 apache2: the 'param_object' parameter ("apache2::requestrec=scalar(0x7f6541b5af28)") apache::session::wrapper->new() not have method: 'param' the mason handler working apache1, apache2, looks object changed apache2::requestrec apache::request . apache2::requestrec has no method 'param'. is there work around this? in advance. yang i know late, try add args_method => "mod_perl" to args apachehandler object in: html::mason::apachehandler->new i believe cleared me.

Fluent nhibernate table-per-subclass want to return items of base class type without joining to child tables -

i have classes this: public class basicsearchresult { public virtual int itemid { get; set; } public virtual string name { get; set; } } public class advancedsearchresult : basicsearchresult { public virtual string detaileddata { get; set; } } public class basicsearchresultmap : classmap<basicsearchresult> { public basicsearchresultmap() { table("basic_search_view"); readonly(); id(x => x.itemid).column("item_id").generatedby.assigned(); map(x => x.name).column("product_name"); } } public class advancedsearchresultmap : subclassmap<advancedsearchresult> { public advancedsearchresultmap() { table("advanced_search_view"); keycolumn("item_id"); map(x => x.detaileddata).column("extra_data"); } } where both basic & advanced views have exact same items (but vastly more horizontal data behind advanced view).

c# - Using WebService to return list Windows Phone 7 -

i'm new windows phone 7. have following code windows phone , webservice, need return list textbox can display result. can me out? this xaml.cs code public list() { initializecomponent(); webservice.servicesoapclient ws = new webservice.servicesoapclient(); ws.retrieveallusercompleted += new eventhandler<webservice.retrieveallusercompletedeventargs>(retrievealluser); ws.retrievealluserasync(); } void retrievealluser(object sender, webservice.retrieveallusercompletedeventargs e) { //display result webservice using list //tb_user.text = ""; } this code webservice [webmethod] public list<userdal> retrievealluser() { list<userdal> ulist = new list<userdal>(); userdal user = new userdal(); ulist = user.retrievealluser(); return ulist; } this code userdal.cs public list<userdal> retrievealluser() { list<userdal> dal = new list<userdal>(); try { using (sqlco

Why do Eclipse plugin IHandler APIs return false by default? -

i new eclipse plugins , able use following links create eclipse plugin makes contribution default text editor. eclipse menu contributions eclipse commands tutorials eclipse official documentation the plugin works fine, have 2 questions regarding ihandler interface. long time realized plugin handler not called. saw default isenabled() returns false. after enabled true, saw handler called once. saw ishandled() set false. setting both true solved problems. so questions is: why both these apis default return false? (it seems strange me plugin developer want have default false.) i tried understanding descriptions in official documentation, still don't why should return false default. is there should aware of? for example, if have multi page editor, might have multiple tabs. each tab may have different actions. in case, may want handler associated tab return true , false other tabs. similarly explorer might want not nodes enable actions. example, click

python - when I try to run the code, it get the error:PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed -

what wrong code? thank import os import os.path import time global item_count #-*- coding: cp936 -*- import mysqldb import mysqldb.cursors import threading import multiprocessing time import sleep,ctime def qucun(): #connect mysql conn=mysqldb.connect(host="localhost",user="root",passwd="caihong") cursor=conn.cursor() try: cursor.execute("""create database if not exists quad""") except: print 'quad exist' conn.select_db('quad') conn=mysqldb.connect(host="localhost",user="root",passwd="caihong",db="quad") #get cursor cursor=conn.cursor() try: cursor.execute("""create table if not exists record(fn1 varchar(100), fn2 varchar(100),fn3 varchar(100),fn4 varchar(100), fn5 varchar(100),fn6 varchar(100),fn7 varchar(100),fn8 varchar(100))""") except:

java - is meta http-equiv value cache control is not supported? -

i have code here on page: <!-- no cache headers --> <meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="expires" content="0" /> <!-- end no cache headers --> when go other page , hit button of browser (back page code written), still had cache state of page. option is, add phaselistener told me adding phaselistener additional codes maintain. the question is: 1. meta tag attribute http-equiv value cache-control still supported in html in browser?? because when check in w3school, there no value cache-control, pragma, , expires attribute http-equiv. 2. if add phaselistener advantage against adding meta tags in every page.? thanks ahead the <meta http-equiv> tags used when html file in question been opened non-http resource such local disk file system (via file:// uri) , not when

php - how can is delete all session information? -

i'm getting ready upgrade website, , in new update, there need new session variable user_level. i'm wondering if there anyway server side can end sessions without having code anything. if not, intention test whether or not variable set, , if isn't destroy session forcing user relog. this.. if(!$this->session->userdata['user_level']) { $this->session->sess_destroy(); } userdata function not array read session docs try this, if(!$this->session->userdata('user_level')) { $this->session->userdata = array(); $this->session->sess_destroy(); } if want unset single session variable use like, $this->session->unset_userdata('user_level');// remove user_level session read http://ellislab.com/forums/viewthread/195025/

iphone - ToolBar between UINavigationBar and UITableView? -

Image
i have uitableviewcontroller embedded on uinavigationcontroller. tableview instance of nsfetchedresultscontroller. need add toolbar between navigationcontroller's top bar , tableviewcontroller, can't figure out how (i don't know if it's possible). want apple did wwdc app (except don't have tableviewcontroller embedded in navigationcontroller). need have controls on bar drive nsfetchedresultscontroller. some people suggested people similar problems use uitableview instead of tvc, need have tvc instance of nsfetchedresultscontroller. any ideas on how accomplish this? have programmatically? if so, how? btw, i'm targeting ios6+ storyboards , arc. the approach prefer use uiviewcontroller @ outer level, containing toolbar , container view holds table. build table in separate uitableviewcontroller , wire container view using embed segue. overall, think makes code more modular , easier follow because high-level structure laid out in storyboard.

How to get MCC and MNC in windows phone 8 -

mcc,mobile country code mnc,mobile network code there way mcc , mnc in windows phone 8? we can't mcc , mnc on windows phone 7 (and 8) devices. maybe windows phone 9 ? :d it's possible windows mobile (with radio interface layer) , it's not implemanted on windows phone... you can other network informations network information class. please read this msdn page more informations. also, can vote here improve features has want in windows phone plateforme... , here it's ril page ...

regex - Rename the text file -

i have multiple text files different names in directory. want search string in text files , if string found in text file , want rename text file abc.txt can me in doing perl script. this ought you're looking for. you should spend time , figure out how works. "i want rename text file abc.txt" hopefully aware can have one file named abc.txt in same directory. i'm making files: abc.txt abd.txt abe.txt , on... this untested btw... #!/usr/bin/perl use strict; use warnings; use autodie; use file::copy; $dir = "test-dir"; opendir(my $dh, $dir); chdir $dir; @files = grep { !-d $_ } readdir $dh; closedir $dh; $new = "abc"; $file (@files) { open $fh, "<", $file; while(my $line = <$fh>) { chomp $line; if($line =~ /something/) { move($file, "$new.txt"); $new++; last; } } close $fh; }

zend framework2 - PDF is upload with application/octet-stream -

i have upload in application, user can upload pdf, png, jpg , gif files maximum file size of 2mb. when upload pdf larger size of 2mb error file has incorrect mimetype of 'application/octet-stream' here can see filters validators: 'type' => 'zend\inputfilter\fileinput', 'name' => $name, 'required' => $required, 'filters' => array( array( 'name' => '\application\filter\file\renameupload', 'options' => array( 'target' => 'data/upload', 'use_upload_name' => true, 'count_up' => true, ), ), ), 'validators' => array( array('name' => '\zend\validator\file\uploadfile'), array( 'name' => '\zend\validator\file\extension', 'options' => array( 'extension' => array( '

scala - iterate over case class data members -

i writing play2.1 application mongodb, , model object bit extensive. when updating entry in db, need compare temp object coming form what's in db, can build update query (and log changes). i looking way generically take 2 instances , diff of them. iterating on each data member long, hard-coded , error prone (if a.firstname.equalsignorecase(b.firstname)) looking way iterate on data members , compare them horizontally (a map of name -> value do, or list can trust enumerate data members in same order every time). any ideas? case class customer( id: option[bsonobjectid] = some(bsonobjectid.generate), firstname: string, middlename: string, lastname: string, address: list[address], phonenumbers: list[phonenumber], email: string, creationtime: option[datetime] = some(datetime.now()), lastupdatetime: option[datetime] = some(datetime.now()) ) all 3 solutions below great, still cannot field's name, right? means can log change, not field affected...

awk - Getting substring using ksh script -

i'm using ksh script determine delimiter in file using awk . know delimiter in 4 position on first line. issue i'm having character being used in delimiter in particular file * , instead of returning * in variable script returning file list. here sample text in file along script: text in file: xxx*xx* *xx*xxxxxxx....... here kind of script looks (i don't have script in front of me jist): delimiter=$(awk '{substr $0, 4, 1}' file.txt) echo ${delimiter} # lists files in directory..file.txt file1.txt file2.txt instead of * desired result thank in advance, anthony the shell interpreting content of delimiter variable. need quote avoid behaviour: echo "${delimiter}" it print *

tinymce.ui simple text component -

i'm using tinymce trying extend plugin show dialog specific layout: editor.windowmanager.open({ title: 'title of dialog', body: [ {type: 'label', text: 'my label'}, { name:'my_input', type: 'textbox'}, // { type: 'text', html:'some content <b>bold</b> if posilbe!'}, // { type: 'html', value:'<div>with custom formating</div>'} ] } i checked documentation tinymce.ui several times can find way add html or text component in constructor of dialog (like comment rows in example). i know there option using ready html template dialog.. there lot of events , triggers using constructor , .ui components more suitable case. i used use jquery ui dialog ran issues after tinymce 4.0. i have tinymce plugin lets people fetch plain text version of post in wordpress editor. show them text using this: var pl

java - CDI: Injecting resources to beans from external libraries -

in spring have annotation-based , xml-based configuration. while first recommended quick development, second more flexible , able handle special cases. there 2: injecting mocks junit tests , configuring beans external libraries. i haven't found equivalent xml configuration cdi, question is, how handle dependency injection such beans? external libraries, need configured , there's no possibility add annotations them. you have 3 solutions need: use producer cdi provides way transform non cdi class in beans. called producer. if want create bean class named noncdiclass have create public class myproducers { @produces public noncdiclass producenoncdiclass() { return new noncdiclass(); }; } } you can @inject bean when needed. you can put many producer method want in class. if need simulate injection in produced bean can cdi injects parameters in producer methods calls. @produces public noncdiclass producenoncdiclass(myfisrtb

dapper - Performance of Insight micro-ORM -

i wondering if has metrics on insight micro-orm. new orm, dapper more stored procs. i ran benchmarks in february. latest version of insight should have same performance build. of popular orms have same speed. pick 1 suits style best. http://code.jonwagner.com/2013/02/05/micro-orm-benchmarks-february-2013/

ios - Validation for input string is Date or not? -

i have textfield user can enter date of birth, wants make sure whether input of date format before saving database. gone through , still didn't answer. can tell me how validate(is date) input. the date format mm/dd/yyyy note:i don't want user select date through date picker. try nsstring *datefromtextfield = @"07/24/2013"; // convert string date object nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"mm/dd/yyyy"];// here set format want... nsdate *date = [dateformat datefromstring:datefromtextfield]; [dateformat release]; and check //set int position 2 , 5 contain / valid date unichar ch = [datefromtextfield characteratindex:position]; nslog(@"%c", ch); if (ch == '/') { //valid date } else { //not valid date }

python - Matplotilb bar chart: diagonal tick labels -

Image
i plotting bar chart in python using matplotlib.pyplot . chart contain large number of bars, , each bar has own label. thus, labels overlap, , no more readable. label displayed diagonally not overlab, such in this image. this code: import matplotlib.pyplot plt n =100 menmeans = range(n) ind = range(n) ticks = ind fig = plt.figure() ax = fig.add_subplot(111) rects1 = ax.bar(ind, menmeans, align = 'center') ax.set_xticks(ind) ax.set_xticklabels( range(n) ) plt.show() how can labels displayed diagonally? the example in documents uses: plt.setp(xticknames, rotation=45, fontsize=8) so in case think: ax.set_ticklabels(range(n), rotation=45, fontsize=8) give angle still overlap. try: import matplotlib.pyplot plt n =100 menmeans = range(n) ind = range(n) ticks = ind fig = plt.figure() ax = fig.add_subplot(111) rects1 = ax.bar(ind, menmeans, align = 'center') ax.set_xticks(range(0,n,10)) ax.set_xticklabels( range(0,n,10), rotation=45 ) plt.show(

c# - Crystal reports Showing Multiple pages of records using ASP.Net -

i have crystal report having layout of payslip. crystal report has stored procedure recordsource. code follows. reportdocument reportdocument = new reportdocument(); reportdocument.load(server.mappath("crystalreport2.rpt")); reportdocument.setdatabaselogon("", "", @"biswa-pc\sqlexpress", "forum_mall"); reportdocument.setparametervalue("@compid", compid); reportdocument.setparametervalue("@deptname", dept); reportdocument.setparametervalue("@year_id", yearid); reportdocument.setparametervalue("@month_id", monthid); crystalreportviewer1.reportsource = reportdocument; the rows returned 200 report showing me first record , page link go next page. when link page clicked giving error message server error in '/forum' application. the system cannot find path specified. description: unhandled ex

asp.net mvc - How to retrieve a variable in jquery ajax .done() -

stackoverflow(ers), i have created javascript function in process data array of objects, , in function iterating through array calling ajax request each object in array. however, inside ajax.done() function, need pass in index of iteration, j. inside iteration, however, j stuck on 4, whereas outside iteration, j counts iteration. note iteration in code below loops through inside each ajax request pull out values form array, can ignored. can me in working out need make j iterate inside .done() block? thanks, jamie object passed code: var dataconfig = [ { targetdiv: "#chart", charttitle: "title", tooltipvisible: true, xaxislabel: "label", leftyaxislabel: "unit" }, { apiurl: "url", type: "column", yaxis: "right", visibleinlegend: false }, { apiurl: "url", type: "line", yaxis: "left", visibleinlegend: false }, { apiurl: "u

webharvest - IO error during HTTP execution -

i used web-harvest 5 month , tried content of webs syntax: <var-def name="raw"> <html-to-xml outputtype="pretty" usecdata="false"> <http url="${url.tostring()}" /> </html-to-xml> </var-def> i'd gotten content, error: error - io error during http execution url: http://google.com org.webharvest.exception.httpexception: io error during http execution url: http://google.com @ org.webharvest.runtime.web.httpclientmanager.execute(unknown source) @ org.webharvest.runtime.processors.httpprocessor.execute(unknown source) @ org.webharvest.runtime.processors.baseprocessor.run(unknown source) @ org.webharvest.runtime.processors.bodyprocessor.execute(unknown source) @ org.webharvest.runtime.processors.baseprocessor.getbodytextcontent(unknown source) @ org.webharvest.runtime.processors.baseprocessor.getbodytextcontent(unknown source) @ org.webharvest.runtime.processors.baseprocessor.getb

c# - tabcontrol in panel autoscroll does not working -

i have panel autoscroll = true . in panel have tab control , anchor property of tab control left, right, top, bottom. i want see scrollbars when window small when window size bigger tab control getting bigger , scroll-bars need hidened. but doesn't work. how do this?

sockets - Using PHP broadcast to detect Server IP address -

i want article: broadcast detect server ip address and transfer php, possible? the reason want send broadcast socket server, , server return message can determine message want or not detect true ip of message sender. the code like: <?php error_reporting(e_all); $address = "255.255.255.255"; $port = 10000; /* create udp socket. */ $socket = socket_create(af_inet, sock_stream, sol_tcp); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "<br/>"; } else { echo "socket created.<br/>"; } echo "attempting connect '$address' on port '$port'..."."<br/>"; $result = socket_connect($socket, $address, $port); if ($result === false) { echo "socket_connect() failed.\nreason: ($result) " . socket_strerror(socket_last_error($socket)) . "<br/>"; } else { echo "successfully connected $address

doctrine2 - fetch all data from table using doctrine in codeigniter -

i had integrated doctrine 2 in codeigniter 2. had database convert entity in store in models/entity my controller goes .. public function __construct() { parent::__construct(); $this->em = $this->doctrine->em; $this->load->model('doctrine_model'); } public function index() { $this->doctrine_model->get_object(); } } and model goes this.... class doctrine_model extends ci_controller { function __construct() { parent::__construct(); //$this->load->library('doctrine'); //$accounttable = doctrine_core::gettable('ss_class'); $this->em = $this->doctrine->em; } function get_object() { $records = $this->em->getrepository("entity\ssclass")->findall(); } } when run code error fatal error: cannot redeclare class ssclass in d:\xampp\htdocs\new_doctrine\applicati

Draw a dynamic graph? -

i have program wrote in java takes in set of actions , prints out graph after every action. way @ program prints out output of graph @ every time-step. need display dynamic graph visually , have been considering softwares gephi. know best way go doing , seems gephi not support feature. should build java applet , if java provide libraries. i want display entire graph nodes , edges between them. edges display actions between nodes , each action result in values being changed in nodes. nodes display value being changed , edges marked action. thanks. jfreechart supports dynamic graphs. there lot of tutorials on web well. think thread might helpful using jfreechart display recent changes in time series

android - optionsmenu both cases execute -

in login activity i've created 2 button s on options menu, login , change user. if user clicks change user data deleted phone. display dialog box asking user confirm action. it seems work fine until user logs out once doesn't enter credentials in username , password textviews. if these empty when user clicks login button toast message displays showing 'please enter valid name' dialog box displays asking if user wants change user. my question why dialog box display asks user confirm want change user when code not in login case within options menu? when user clicks login empty fields change user code executes. in advance matt. @override public boolean onoptionsitemselected(menuitem item) { cursor allfromcompidtable = nfcscannerapplication.loginvalidate.queryallfromcompanyidtable(); if(allfromcompidtable.getcount() > 0){ if(allfromcompidtable.movetolast()){ compid = allfromcompidtable.getstring(allfromcompidt

php - MySQL time-exceeded error -

i working on ajax testing platform. experiencing stupid errors in php programming. here code. error: maximum execution time of 30 seconds exceeded . <?php $resultfromjson; $databaseconnection = mysql_connect("localhost", "root", "password"); if($databaseconnection)mysql_select_db("fastdata", $databaseconnection); else echo mysql_error($databaseconnection); if(isset($_get['command'])){ switch($_get['command']){ case "loadpeople": { $sqlcommandstring = "select * `people` limit 0 , 30"; $people = array(); $index = 0; while($row = mysql_fetch_assoc(mysql_query($sqlcommandstring))){ $people[$index] = $row; $index++; } echo json_encode( $people ); } break; } } if(!isset($_get['command']))echo json_encode( "error#001" ); ?> what can

multithreading - Update value after passing pointer -

i using tcp server send char array. function send() takes char * , but, before that, has listen , accept connection. given that, want send recent data when incoming connection accepted. previously, used 2 threads. 1 updated value in buffer, other waited connections, sent data. i understand there can problems not locking mutex, aside that, same scheme work if passed char * send function, rather updating global variable? some code demonstrate: #include <pthread.h> char buf[buflen]; void *updatebuffer(void *arg) { while(true) { getnewdata(buf); } } void *senddata(void *arg) { //setup socket while(true) { newfd = accept(sockfd, (struct sockaddr *)&their_addr, &size); send(newfd, buf, buflen, 0); close(newfd); } } this send updated values whenever new connection established. i want try this: #include <pthread.h> char buf[buflen]; void *updatebuffer(void *arg) { while(true) { getnewdata

Node.js request directly to URL with options (http or https) -

i think i'm missing http , https requests i have variable contains url, example: http(s)://website.com/a/b/file.html i know if there's easy way make request uri data to make http(s)request, here's have now: test if url http or https make appropriate request remove http(s):// part , put result in variable (if specify http or https in hostname, error) separate hostname path: website.com , `/a/b/file.html put variables in options objects is must or easier solutions don't involve getting out hostname , path, , testing if site in http or https ? edit: can't use http.get need put specific options in order components out of url need parse it. node v0.10.13 has stable module it: url.parse