Posts

Showing posts from May, 2014

html - Based on selection, "mailto:" link changes to "mailto: variable" using javascript -

i'm trying make form. way work user chooses option drop-down list. click confirm location button. click send email link. when click confirm location button, changes mailto link in send email link, based on selection in drop-down list. however, cannot figure how change mailto link mailto variable t holds value of email address (based on selection.) (see 3rd last line in code) please help! <form>select place: <select id="myselect"> <option value="email@domain.com">location 1</option> <option value="email2@domain.com">location 2</option> <option value="email3@domain.com">location 3</option> <option value="email4@domain.com">location 4</option> </select> </form> <button type="button" onclick="displayresult()">confirm location</button> <a id="myemaillist" href="mailto:&qu

jquery - Display arrow-boxes in repeater control in asp.net -

![enter image description here][1] hi, i want display data in repeater control in below images. have attached outuput of screen shot. have searched lot of things in internet didnt find way develope. please how implement task. data comes database , bind repeater contol , display boxes , arrrow between them. how draw arrow-boxes , rectagnle in repeater control , how xy position of each row , each recrod cell data @ run time. ![enter image description here][2] you can that <asp:repeater id="repeater1" runat="server"> <headertemplate> <div> <div>dvd</div> <div> <img src="~/imagebox.jpg" /></div> <div>cd</div> <div> <img src="~/imagebox.jpg" /></div> <div>seller</div> </div> </headertemplate> <itemtempla

WooCommerce Hook to Trigger Email in Refund inside Email Class -

by default, woocommerce not send refund emails because refunding is, mike jolley says, "a manual process". however, need send one! my problem is: can't find hook fire inside extended email class this. i followed tutorial, wrote class extend wc_email , got working except need hook trigger class when order status changed , saved "refunded": http://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/ i tried various hooks woocommerce_order_status_refund in place of woocommerce_order_status_pending_to_processing_notification hook on line 39-40. the problem woocommerce_order_status_refund doesn't trigger inside email class. works fine elsewhere, not in context. i tried replacing hook woocommerce_order_actions_end sort of "generic". added if (! $order->status == 'refunded') filter "refunded" only. hook fired every time order status of 'refunded' loaded. (i tried adding custom action woocommerc

python - llvmpy on Ubuntu 14.04 -

i trying install llvmpy on ubuntu 14.04. uname -a linux -esktop 3.13.0-30-generic #55-ubuntu smp fri jul 4 21:40:53 utc 2014 x86_64 x86_64 x86_64 gnu/linux lsb_release -a lsb version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch:security-4.0-amd64:security-4.0-noarch:security-4.1-amd64:security-4.1-noarch distributor id: ubuntu description: ubuntu 14.04.1 lts release: 14.04 codename: trusty sudo pip install llvmpy fails. end of output is cleaning up... command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/llvmpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-7hvrcb-record/install-record.txt --single-version-externally-managed --compile failed error c

security - How to secure php scripts? -

if have ajax call php script, (using jquery) $.ajax(url: "../myscript.php"); and myscript looks this: <?php //code db ?> i want know how prevent user going example.com/myscript.php execute script. some answers here give overview of concepts behind question, let me give more pragmatic approach (you should @ least read , understand others matter though!). you need ask yourself: do app must enforce requests myscript.php should controlled? if so need use sort of token: create token , send client (browser), browser must send token , check if matches before doing action: <?php // somefile.php (this file serves page contains ajax call) session_start(); //... $_session['token'] = createnewtoken(); // creates unique tokens //add token js variable , send in ajax call // you'll have similar this: <script> var token = <?php echo $_session['token'] ?>; $.ajax({ url: "myscript.php", data: f

.net - Programmatically Automating Getting the Correct COM Port, based on the Serial Device, through C# -

i trying set program automatically detect com port connected device, end, have done far: i com ports using string[] comports = serialport.getportnames(); once have available com ports pc, create serialport instance inside foreach loop open , send string command through each available com port. device attached 1 of com ports respond string command, catch through serialport.datareceived event. foreach(string port in comports) { serialport sp = new serialport(port, 9600, parity.none, 8, stopbits.one); sp.handshake = handshake.none; sp.open(); sp.write("<id01>\r\n"); // command wakes device. device sends string "<id01>s" in 's' code success. } this works good, success string fine. reason want program automatically recognize com port device set on or not setup on. problem time datareceived event has returned success string program has gone past point me because main thread program running on seems have progressed on

javascript - How to communicate between servers (Google Cloud Engine -> Google App Engine) using oAuth2 -

first describe how our system looks like. have 2 servers. the first 1 on google app engine , has logic provides access database android application , has servlets written external communication (more later). the second 1 on google cloud engine . application written in meteor (to simplify, it's node.js). communicate between servers (gce -> gae). have rest api on servlet endpoint under address e.g. https://appname.appspot.com/admin/upload . when i'm making request without authentication, work fine: http.get(geturl, {}, getcallback); however, have no idea how using oauth2 authentication. when go address https://appname.appspot.com/admin/upload browser, redirects me google authentication , works fine (i have account added in google console). how send http request node.js server using oauth2 authentication? to give more details, here servlet configuration: <security-constraint> <display-name>securityconstraint</display-name> <web-res

c++ - How to raise double to array powers in Eigen -

i have simple problem should have simple answer well, far no luck. i need raise double value array of integer powers, in c++ like for (int = 0; < n; ++i) { y[i] = pow(delta, l[i]); } but in eigen have tried number of variants on theme, without success. i have eigen::arrayxi l_inte maps stl vector l_int . this doesn't work: eigen::pow(double, l_inte) since pow() function wants array first input, , raise array constant power. one nasty workaround able working (this can't right way) this: (log(delta)*l_doublee).exp() which conversion pow(delta,l) -> exp(l*log(delta)) and have convert integers doubles. can't performance either since pow(double, int) significantly faster pow(double, double) in general. although, maybe isn't true sse in eigen? anyway, clarity here appreciated. what multiplying each y[i] l[i] times? y.fill(1); (arrayxi e = l; (e>0).any(); e -= 1) y = (e>0).select(delta*y, y); note after ever

Questions about the different Scopes/Visibilities of variables in a Delphi Unit -

lets have delphi unit: unit unit1; interface uses winapi.windows, winapi.messages, system.sysutils, system.variants, system.classes, vcl.graphics, vcl.controls, vcl.forms, vcl.dialogs, vcl.stdctrls, vcl.extctrls; type tform1 = class(tform) private { private-deklarationen } public { public-deklarationen } end; var form1: tform1; implementation {$r *.dfm} var nummer:integer; i understood there public interface-section , private implementation-section. functions , procedures defined in public-section can used ohter units. functions , procedures defined in private-section can used in unit. but variables after var in interface-section global variables? if yes there difference global variables in public? , difference between variables defined after implementation , ones under private? the variables after var in interface section become accessible use global in unit 'uses' unit. the vars defined outside of class have 1 value

javascript - Trying to use Jquery hover to change font size -

im trying use jquery hover function change font size of tabs. think im having trouble targeting tabs. this html im trying target: <ul class="tabs" data-tab> <div class="tab"> <li class="tab-title"> <a href="#panel2-1">about me</a> </li> <li class="tab-title"> <a href="#panel2-2">portfolio</a> </li> </div> </ul> i tried wrapping both tabs in div tag , assigned div tag called "tab" this jquery code: $(document).ready(function() { $('.tab').hover(function() { $(this).css('font-size','60px') }); }); can tell me im doing wrong? thanks! div element not allowed inside ul that's first mistake, should be: <ul class="tabs" data-tab> <!-- no party div elements here --> <li class="tab-titl

java - Ice4j: Testing IcePseudoTcp - STUN server needed? -

does know process of testing icepseduotcp? self contained, or have point stun server work? it looks code states: stuncandidateharvester stunharv = new stuncandidateharvester( new transportaddress("sip-communicator.net", 3478, transport.udp)); stuncandidateharvester stun6harv = new stuncandidateharvester( new transportaddress("ipv6.sip-communicator.net", 3478, transport.udp)); so don't need own stun server points one.

MySQL Stored Procedure - how to reference internally created recordset -

i curious how reference existing stored procedure select statement secondary query or set call within same stored procedure. for example: create procedure 'mysp' (out sumvalue int) begin -- core recordset sp returns select * table -- want return value based on above recordset set sumvale = sum(previousselect.values) end essentially, have sp returns detailed recordset, , need return sum , custom values based on data within recordset. issue cannot figure out how reference data after select statement (e.g. create internal reference can use such @recordset1.x). any appreciated. try using cursor this link: as mysql not allow return recordset either store procedures or functions, try this: create definer=`root`@`localhost` procedure `some_procedure`(out some_id int) begin declare done boolean default false; declare id int; declare tot decimal(10,2); declare some_cursor cursor select id, total some_table id = some_id;

Having an issue with grid-based movement in Love2D/Lua -

using love2d lua framework, trying program basic game nintendo-era rpgs heroes' , npcs' movement restricted tiled grid. far i've found past problems, until hit tricky error player movement isn't functioning correctly. function love.load() love.graphics.setdefaultfilter('nearest', 'nearest', 1) love.keyboard.setkeyrepeat(true) font = love.graphics.newfont(14) -- number denotes font size win_size = 6 love.window.setmode(160 * win_size, 144 * win_size) true_sfc = love.graphics.newcanvas(160,144) view_sfc = love.graphics.newcanvas(160 * win_size, 144 * win_size) player = { grid_x = 3, grid_y = 3, act_x = 48, act_y = 48, transit = false, direction = {0, 0} } end function love.update(dt) if player.transit == true -- idea if player selects direction, player walk in direction until stops on grid. -- when press left or right, movements works intende

Android: How to get bitmap from HashMap object? -

i have hashmap in stored images bitmap format. problem how images again? in details, here in hasmap, stored bitmap image object. arraylist<hashmap<string,object>> mimglist = new arraylist<hashmap<string,object>>(); bitmap img = imgloader.decodesampledbitmapfactoryfromurl(x,x,x,x); hashmap<string, object> map = new hashmap<string, object>(); map.put(tag_img, img); map.put(tag_name, name); map.put(tag_id, cont_id); mimglist.add(map); i use hashmap in listview diplay img , text, everything's fine. need display of images in imageview, don't know how image bitmap in hashmap becoming object. i tried use: bitmap bmp = mimglist.get(x).get(tag_img); but got actualy object not bitmap. how should bitmap? or there other way can display picture on alertdialog? thanks! turns out no 1 answered question...but end converting bitmap drawable can save them hashmap , them when want.

Android - change device system locale programmatically -

i want change device locale (not application locale) app, user can in settings -> language & keyboard -> language. can please explain how it? i've been searching hours , can not find way. this app want want https://play.google.com/store/apps/details?id=org.gnvo.langpicker&hl=en here source code https://code.google.com/p/languagepickerwidget/ here main logic http://bin-liu.blogspot.in/2012/05/how-to-change-system-locale-calling.html edit after 4.2 new jelly bean, protection level definition of change_configuration has been changed,so app not work above 4.2, solution http://droider.eu/2013/07/22/morelocale-2-not-working-on-4-2-2-without-su-or-pm/

Scala's match/case for Option[classOf[...]] -

Image
i need check returned type method invoke different methods. code: class x ... class y ... ... def gettype(input:string) : option[class[_]] = { if ... return some(classof[x]) if ... return some(classof[y]) ... } gettype(input) match { case some(classof[x]) => ... // error case some(classof[y]) => ... case none => ... } however, got errors: what might wrong? i think can't use classof inside structural match. instead can add condition checks that. val opt: option[class[_]] = some(classof[int]) opt match { case some(c) if c == classof[string] => "string" case some(c) if c == classof[int] => "int" case none => "no class" case _ => "some other class" } //yields int

C++ memory issue with external library -

i worked commercial company, have lots of internal libraries can reused different project. encountered serious memory issue 1 of library strange. the source code confidential cannot put here, going mock code describe happened me, there classes defined in library: class classb { public: ... static classb* acquireinstance(); }; class classa { public: classb* getb() { return m_pb; } bool init(classb* pb); private: classb* m_pb; }; integrated library(static linked) in our project, our code looks this: void foo() { ... classb* pb = classb::acquireinstance(); classa a; a.init(pb); // step function, m_pb assigned pb, ok inside function. assert(pb == a.getb()); // failed } comments: the strange thing found: when step init function, address of m_pb (&m_pb) 0x0000ce08, address of m_pb (&a.m_pb) changed 0x0000ce00. i think byte alignment issue different config between our project , library. not sure, is there encountered kind of issue b

count how many of an object type there are in a list Python -

if have list in python: a = [1, 1.23, 'abc', 'abc', 6.45, 2, 3, 4, 4.98] is there easy way count amount of object type there in a ? simpler following produces same result: l = [i in if type(a[i]) == int] print(len(l)) hopefully made myself clear. a = [1, 1.23, 'abc', 'abc', 6.45, 2, 3, 4, 4.98] sum(isinstance(i, int) in a) which returns 4

jquery - realtime update value in form from table -

i have created table calculate grand total of few fields in real time .i have form after table input field named amount ,how can make value updated in real time same value grand total in table. meaning if grand total in table 10 value in form should change 10. see fiddle: http://jsfiddle.net/hsxkw/48/ html: <table> <thead> <tr> <th>variable</th> <th>qty</th> <th>price</th> <th>sum</th> </tr> </thead> <tbody> <tr> <td>millage</td> <td><input class='qty' size='1'/></td> <td class='price'>1.25</td> <td class='sum'>0</td> </tr> <tr> <td> number of vans</td> <td><input class='qty' size='1

android - When Fragment.onCreateView is complete and how to receive this event from the Activity? -

Image
this question has answer here: nullpointerexception accessing views in oncreate() 11 answers edit changed title. sdk guide document says, activity.oncreate complete after fragment.oncreateview , fragment.onacvitycreated. but if try findviewbyid view of fragment returns null. how can access contents of fragment? i'm new android ui dev. below sample code generated eclipse ide. public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); if (savedinstancestate == null) { getfragmentmanager().begintransaction().add(r.id.container, new placeholderfragment()).commit(); // null view rootview = findviewbyid(r.id.txtview); } } public static class p

asp.net - How to unit Test on aspx.cs -

i trying unit test on aspx partial class, example button_click event. i think task more suitable integration testing using "seleniumhq" or "watin". the other way can think of doing test extract business logic within eventhandler , put different class , perform unit test on that. what think? yes, you're moving in right direction. googling on "model-view-presenter" , "passive view". the idea move logic code-behind file presenter class easily-instantiated , not platform dependent poco. presenter testable then. code-behind code pretty "dummy", name "passive view" suggests. edit: here example winforms pattern works asp.net , android java well.

Must I escape every '\' to realize vim substitution of file path? -

this question has answer here: execute vim substitute command includes '/' characters 3 answers i need substitute long path brief new pattern. feel escape every \ dumb idea, looks like: :%s/\/my\/very\/very\/dumb\/long\/path\//new_pattern/gc is there smarter way that? must escape every '\' realize vim substitution of file path? no, don't. is there smarter way that? yes. can use different character after %s . :%s+/my/very/very/dumb/long/path+new_pattern+gc from :help :s instead of '/' surrounds pattern , replacement string, can use other single-byte character, not alphanumeric character, '\' , '"' or '|' . useful if want include '/' in search pattern or replacement string. example: :s+/+//+

HTML form name replaced with wrong symbols -

i have following form <form name="input" action="http://testdomain.com/search/?" method="get" autocomplete="off"> <input type="text" name="?wpv_paged_preload_reach=1&wpv_view_count=1&wpv_post_id=205499&wpv_post_search="> <input type="submit" id="searchsubmit" value=""> </form> however actual url displays following search query: /search/?%3fwpv_paged_preload_reach%3d1%26wpv_view_count%3d1%26wpv_post_id%3d205499%26wpv_post_search%3d=test it seems special symbols such ? , = getting replaced special encoding characters. my question is, how form not switch special symbols encoding characters? thanks the name of input element controls name of 1 field. browser doesn’t blindly mash , value , send server. request, can include each 1 hidden field: <form name="input" action="http://testdomain.com/search/" metho

java - Upload and display image in Javaweb -

my simple website using spring mvc. user uploads product images , thewebsite display image (with product name , price, etc..). database store details of image, , store image in directory. problem is, not sure image store should be. // creating directory store file file dir = new file(imagedirectory); if (!dir.exists()) dir.mkdirs(); // create file on server file serverfile = new file(dir.getabsolutepath() + file.separator + name); for example, when value of variable imagedirectory "\temp", application store image in "d:\temp" , don know how image url show on website when value of variable imagedirectory "temp", application store image in "d:\soft\sts-bundle\sts-3.5.1.release\temp" , dont know how image url show on website so should store upload image in , how uploaded image url (stored in database) ? in order show image end user, must store

ruby on rails - What am I missing to get a profile page to include additional fields such as address, avatar, phone number -

i using ruby on rails , utilized devise log in , registration. after signing up, error message: nomethoderror in devise::sessionscontroller#create undefined method profile_path' #<devise::sessionscontroller:0x007f9425b1f9c0> i used rails generate scaffold profile , have following code: profiles_controller.rb class profilescontroller < applicationcontroller before_action :set_profile, only: [:show, :edit, :update, :destroy] def profile end # /profiles # /profiles.json def index @profiles = profile.all end # /profiles/1 # /profiles/1.json def show end # /profiles/new def new @profile = profile.new end # /profiles/1/edit def edit @profile = profile.find_by user_id: current_user.id @attributes = profile.attribute_names - %w(id user_id created_at updated_at) end # post /profiles # post /profiles.json def create @profile = profile.new(profile_params) respond_to |format| if @profile.save

ios - nspredicate substitution not working -

hi trying use substitutions error nspredicate *pred = [nspredicate predicatewithformat: @"city $c $a or " " state $c $a or " " name $c $a "]; // <-- crashes here pred = [pred predicatewithsubstitutionvariables:@{@"a":self.searchbar.text, @"c":@"contains[c]"}]; this sample code apples documentation on subject nspredicate *predicate = [nspredicate predicatewithformat:@"date = $date"]; predicate = [predicate predicatewithsubstitutionvariables: [nsdictionary dictionarywithobject:[nsnull null] forkey:@"date"]]; i not sure doing wrong. simple want $a place holders replaced same string; in case self.searchbar.text can tell me why doesn't work? apparently can use substitution on variables.

asp.net - .NET MVC throws 500 Server Error instead of 404 Not Found when cannot match a Controller path -

Image
for reason, when entering dud url file/directory/controller not exist, following error thrown: system.web.httpexception controller path '' not found or not implement icontroller system.web.mvc.icontroller > getcontrollerinstance(system.web.routing.requestcontext, system.type) iis follows regular error handling , shows page appropriate 500 internal server error. 404 not found error handling logic should followed. another web application testing on not throw httpexception when can't find route, , returns 404 normally. triggeres httpexception? why , how follow 404 route type of error instead of 500? below configuration of error handling. no other code handling errors. why 500 error shown. it's if default handling handles 'can't find controller' exception error when in fact it's not-found. <system.webserver> <httperrors errormode="custom" existingresponse="replace" defaultpath="/staticerro

Upgrade existing Ghost installation on Openshift -

i'm running personal blog on openshift cloud (from redhat) running through ghost 0.4.2. i've used quickstart deployment of ghost: https://www.openshift.com/quickstarts/ghost now quickstart upgraded ghost 0.5 (latest release of ghost). there way can upgrade current ghost installation 0.5 0.4.2 without creating new app using upgraded quickstart? mean, don't want create new app using upgraded quickstart. want upgrade existing ghost installation, site's content, custom theme etc. intact. ghost version upgraded 0.5. openshift forum retires, asked support here. i'm asking question here. help? the best way upgrade git clone application local computer, add new updated repository here ( https://github.com/openshift-quickstart/openshift-ghost-quickstart ) or 1 if using mysql version ( https://github.com/openshift-quickstart/openshift-ghost-mysql-quickstart ) 'remote' , merge code existing code, , git add, git commit, , git push code openshift gear.

sql - PostgreSQL:how to update rows in CTE -

am running postgresql 9.2 . below given sample of huge , ugly query with cte as( select ....... atable ),cte1 ( select ..... btable inner join cte using(anid) ),update_cte as( update cte set afield=(select somthing cte1) ) select * cte need create view final result . while executing above getting error below. error: relation "cte" not exist i know doing bad. hope can understand trying achieve above query . so please suggest alternative method it. replies appreciated. note : the actual query with cte as( select ....... atable ),update_cte as( update cte set afield=(select somthing cte1) ) you can't that. an update may not reference cte term in postgresql, ctes materialized. aren't views on underlying data. (that's annoying, that's how is). you can: create temporary view someview select ... atable; update someview set afield = ... if want; that'll work on newer postgresql versions support automatically updatable vi

YQL showing results from multiple sources -

select * people <root> <row> <name>a</name> <address>address1</address> <loc_id>1</loc_id> </row> <row> <name>b</name> <address>address2</address> <loc_id>2</loc_id> </row> </root> select * locations <root> <row> <id>1</id> <name>location1</name> <details>locationdetails1</details> </row> <row> <id>2</id> <name>location2</name> <details>locationdetails2</details> </row> </root> is there anyway in yql can join both these data sources on people.loc_id<->location.id , return result includes values together. know there possibility of naming conflicts anyway of resolving too? yql query might return results below or similar. <root> <row> <name>a</name> <address>address1</address> <loc_id>1

c# - How to Pass Image to a Button in UserControl using Dependency Property -

i have created usercontrol. has button , textblock. want pass image button using dependency property. when try call usercontrol in other page, showing error. code.. user control.xaml: <usercontrol x:class="....usercontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" d:designheight="300" d:designwidth="300" > <grid> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="auto" /> </grid.rowdefinitions> <border grid.row="0" name="bormain" style="{staticresource butt

jquery ui - Google Sites HTML removes ID attribute -

i trying use jquery's accordion on google sites page. when trying assign id or class to, say, element, google site's html editor removes attributes. so, instance, type , click update. upon returning html editor, line of code reads . you can add jquery on google sites via app script ( html services ) https://developers.google.com/apps-script/guides/html/restrictions#jquery_and_jquery_ui

Using 'dart:io' in dartium ? Any work arounds? -

i new dart , trying read data file , use contents draw canvas. in doing running 'the built-in library 'dart:io' not available on dartium ' issue. i understand dart has limitations javascript in code running in browser cannot natively access file system of running client. at same time there tips on how read file , use contents write canvas? thanks in advance. what kind of application trying build? if runs in browser files on server. if normal web page can't access user files. there sandboxed space accessible used by code of webpage. if build chrome app have less limitations. you can't import 'dart:io' when should run in browser. apis available in browser can found in 'dart:html'. if want build chrome app package provides access extended api http://pub.dartlang.org/packages/chrome

wcf - Could not find default endpoint element that references contract 'SumServiceReference.IService1' in the ServiceModel client configuration section -

i want call service both code behind & ajax. able call client script using ajax getting exception, while calling code behind. here sample code, it's simple sum operation demo purpose. service contract: using system.servicemodel; using system.servicemodel.web; namespace sum_wcfservice { [servicecontract] public interface iservice1 { [operationcontract] [webinvoke(method = "post", responseformat = webmessageformat.json)] int addnums(int num1, int num2); } } service implementation: using system.servicemodel.activation; namespace sum_wcfservice { [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] public class service1 : iservice1 { public int addnums(int num1, int num2) { return num1 + num2; } } } added client app in same solution consume service , added service reference name "sumservicereference" client application: using system; using system.globalization; us

iphone - UITable view with customise section headers iOS -

Image
i have table view , want display events according time. suppose have 2 events @ 3 pm need section header 3 pm , in 2 rows event title. in above dummy image there 2 sections (3:00 pm , 7:00 pm)with respective events. , table header date. i have worked on table view without sections. please me achieve this. - (nsinteger)numberofsectionsintableview:(uitableview *)tableview{ return how many section need } //set section header height - (cgfloat)tableview:(uitableview *)tableview heightforheaderinsection:(nsinteger)section{ return 40.0f; } //set section view - (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section{ uiview *vw = [[uiview alloc] initwithframe:cgrectmake(0, 0, self.tblimagelist.frame.size.width, 40)]; [vw setbackgroundcolor:[uicolor clearcolor]]; uilabel *lbl = [[uilabel alloc] initwithframe:cgrectmake(0, 0, self.tblimagelist.frame.size.width, 40)]; [lbl settext:@"your text"]; [lbl se

angularjs - Bootstrap Switch stops working with Angular Routing -

i have started learning angular , have set angular routing first app. i have shell page , sub pages, example products.html, help.html etc the sub pages contains forms bootstrap switches , validation, reason stops working (the switch rendered regular checkbox , validation not run - please note not using angular js). however, if place same code directly in shell page works fine. how sub pages behave code in shell page? basically, if have following code in form in 1 of subpages help.html: <div class="form-group"> <label for="active">my checkbox<br /> <div class="switch"> <input type="checkbox" value="1" id="active" name="active"> </div> </div> ...the switch not render correctly, if move code directly shell page renders correctly. so difference in happens in sub page (which shown in on shell

java - How to make checkbox in alert dialog align left? -

it possible modified checkbox align left in alert dialog? this activity.java file alertdialog dialog; final charsequence[] items = {" easy "," medium "," hard "," hard "}; // arraylist keep selected items final arraylist seleteditems=new arraylist(); alertdialog.builder builder = new alertdialog.builder(this); builder.settitle("select difficulty level"); builder.setmultichoiceitems(items, null, new dialoginterface.onmultichoiceclicklistener() { // indexselected contains index of item (of checkbox checked) @override public void onclick(dialoginterface dialog, int indexselected, boolean ischecked) { if (ischecked) { // if user checked item, add selected items // write code when user checked checkbox seleteditem

php - Return values for appropriate arguments -

is here possible write single return both $strvalues , $strthumbimages need return $strvalues every time returning $strthumbimages when available.. function doselectbranchrecords($objarray,$imageid = null) { global $global_config; $strwhereclause = ''; if ($objarray['frmnamesearch']) { $strwhereclause.= " , a.branch_ident = '".$objarray['frmnamesearch']."' "; } if ($objarray['frmloansearch']) { $strwhereclause.= " , a.loan_ident = '".$objarray['frmloansearch']."' "; } if ($objarray['frmbeneficiarysearch']) { $strwhereclause.= " , a.beneficiary_idents = '".$objarray['frmbeneficiarysearch']."' "; } if ($objarray['frmdatesearch']) { $strdate = explode("-

opengl - Converting 2D Noise to 3D -

Image
i've started experimenting noise (simple perlin noise), , have run slight problem animating it. far come i've across awesome looking 3d noise ( https://github.com/ashima/webgl-noise ) use in project understood nothing of, , bunch of tutorials explain how create simple 2d noise. for 2d noise, used following fragment shader: uniform sampler2d al_tex; varying vec4 varying_pos; //actual coords varying vec2 varying_texcoord; //normalized coords uniform float time; float rand(vec2 co) { return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453); } float ease(float p) { return 3*p*p - 2*p*p*p; } float cnoise(vec2 p, int wavelength) { int ix1 = (int(varying_pos.x) / wavelength) * wavelength; int iy1 = (int(varying_pos.y) / wavelength) * wavelength; int ix2 = (int(varying_pos.x) / wavelength) * wavelength + wavelength; int iy2 = (int(varying_pos.y) / wavelength) * wavelength + wavelength; float x1 = ix1 / 1280.0f; float y1 = iy1 / 720.0f; flo

java - how to create multiple JSON Object dynamically? -

i trying insert data multiple json objects don't know how create them dynamically in android. in hard coded way like:- jsonarray pdoinformation = new jsonarray(); jsonobject pdetail1 = new jsonobject(); jsonobject pdetail2 = new jsonobject(); jsonobject pdetail3 = new jsonobject(); pdetail1.put("productid", 1); pdetail1.put("qty", 3); pdetail1.put("listprice", 9500); pdetail2.put("productid", 2); pdetail2.put("qty", 4); pdetail2.put("listprice", 8500); pdetail3.put("productid", 3); pdetail3.put("qty", 2); pdetail3.put("listprice", 1500); pdoinformation.put(pdetail1); pdoinformation.put(pdetail2); pdoinformation.put(pdetail3); but want create these jsonobject dynamically don't know how many of them going needed while coding , in dynamically created jsonobject data filled 3 arraylist of productid , qty , listprice . so obvious number of dynamically created jsonobject

Looping through Python string in search for keywords -

i have created little program counts kewords in string. see, keywords stored in txt file. today realized if word in string repeats keyword counter wont increase value. particulary in case "wrong" keyword in txt file , in result count variable wil 1 not 2. how make work, repeating words counted too? source_text = 'this wrong. wrong you?' source_words = source_text.split() count = 0 word_list = [] open('pozit.txt') inputfile: line in inputfile: word_list.append(line.strip()) word in word_list: if word in source_words: count += 1 you can use .count() : with open('pozit.txt') inputfile: count = 0 line in inputfile: count += line.count('wrong') if want words in linguistic sense, have @ nltk's tokenizer module .

hamcrest - Android - espresso - clicking on a listview entry based on custom objects -

espresso used automatic testing app. edit: below find number of answers! how can click (within automated espresso test script) on entry in long list of custom objects? in espresso documentation there example of longlist. working list of objects do. trying many options step map object didn't yield results far. the espresso documentation says 'ondata' should used. so, like: ondata( myobjecthascontent("my_item: 50")).perform(click()); onview(withid( r.id.selection_pos2)).check(matches(withtext("50"))); my questions (and think helpful learning community): - can write matcher this? - how can use in 'ondata' ? what situation? on screen have listview of objects like: public class myojbect { public string content; public int size; } the adapter use populate populated list is: public class myobjectwithitemandsizeadapter extends arrayadapter<myobjectwithitemandsize> { private final context context; pri

android - Change Activity design programmatically -

this question has answer here: switching application-wide theme programmatically? 2 answers i'm encountering issue. i'm developping android application contains several activities. , want let user choose black or white design dynamically. issue don't know how must change design activites when they're on backstack. though 2 options : change programmatically color of each view on each activity. do 2 versions of each activity. black 1 , white 1 , switch beetween them according user color choice. which 1 better way ? there way achieve ? regards. you want use themes , , can apply theme before calling super.oncreate()

c# - Button Click to Swtich -

can give me helping hand convert sequence switch. tried tries fails. private void buttontouch ( edittext x) { if (i==2) { button1.click += delegate { x.text = x.text + "1"; }; button2.click += delegate { x.text = x.text + "2"; }; button3.click += delegate { x.text = x.text + "3"; }; button4.click += delegate { x.text = x.text + "4"; }; button5.click += delegate { x.text = x.text + "5"; }; button6.click += delegate { x.text = x.text + "6"; }; button7.click += delegate { x.text = x.text + "7"; }; button8.click += delegate { x.text = x.text + "8"; }; button9.click += delegate { x.text = x.text + "9"; }; button0.click += delegate {

angularjs - Angular $compile template for dynamic email -

i trying load html template ng-repeats in , use $compile service compile , use compiled html in email. the problem.... ok before asking let me set terminology... binding placeholder: {{customer.name}} binding value: 'john doe' using $interpolate actual binding values not work ng-repeats. example: var html = $interpolate('<p>{{customer.name}}</p>')($scope) returns: '<p>john doe</p>' ng-repeats not work using $compile bindings placeholders ie {{customer.name}} need binding value 'john doe' . example: var html = $compile('<p>{{customer.name}}</p>')($scope ) returns: '<p>{{customer.name}}</p>' once append page see binding values. email not page plus has ng-repeats $compile can compile how can create dynamic email template after compiling it, returns html binding values , not binding placeholders can send email? using $compile right way go. however, $compile(

bash - Adding text to a bunch of files -

i needed append text bunch of files in directory, thought i'd clever , try this: find . -name "*.txt" -exec cat source >> {} \; which did not work, of course, because redirect gets picked shell calling find, , not exec. i ended using bbedit , multi-file find/replace it, sure there's way make find command line, what? well, ok, can think of 1 solution, don't it: have exec spawn shell each result. might work. what : find . -name "*.txt" -exec dd if=source of='{}' oflag=append conv=notrunc ';' you should able use files spaces , special characters.

how to stop application asp.net with global.asax -

i want stop application asp.net mvc in session_start after test , show user isn't authorized application protected void session_start(object sender, eventargs e) { if (test) { //stop application // user : not authorized } } finally send response , close session , works protected void session_start(object sender, eventargs e) { if (test) { asciiencoding encoding = new asciiencoding(); string postdata = "<h2 style=\"color:red;\">vous n'avez pas l'authorisation pour utiliser application!!</h2>. "; byte[] data = encoding.getbytes(postdata); char[] buf = postdata.tochararray(); httpcontext.current.response.write(buf, 0, buf.count()); httpcontext.current.response.flush(); httpcontext.current.applicationinstance.completerequest();

Embarcadero c++ Cannot save text to .pdf -

i using embarcadero c++ , reading text file. want save text .pdf document. appreciated! in advance... see code below! memtext ->clear(); ansistring oneline; ansistring wordsfile = "orcle_daily_14aug12.txt"; tstreamreader *stread = new tstreamreader(wordsfile); while (!stread->endofstream) { oneline = stread->readline(); memtext->lines->add(oneline); } stread->close(); ansistring twoline; ansistring wordsfile2 = "daily_report.pdf"; tstreamwriter *stwrite = new tstreamwriter(wordsfile2, false); (int ln = 0; ln <= memtext->lines->count-1; ln++) { oneline = memtext->lines->strings[ln]; stwrite->writeline(oneline); } memtext->scrollbars = ssvertical; stwrite->close();