Posts

Showing posts from May, 2015

c# - Multi-Threading in web service -

is possible created function in web service have multiple threads, 1 returns value user, , 1 continues process transaction? i've never used multithreading before , seems able running transaction asynchronously. no code has been written yet. trying see if possible before begin coding. although can fire off threads , like, other .net application have take account operating environment. any long running process should handed off process windows service web server worker processes can , recycled , goes threads. you're tying threads used further service requests web application. in regards paul abbot said, in principle if had way of returning kind of work id client poll status of processing in request, , can apply within same process or out of process in external service.

Flash REST woes: passing headers through php proxy -

i'm writing actionscript3 flash game, needs access rest services specified sponsor (buyer of game) - things highscores etc. know how use urlloader, urlrequest, set urlrequestheader. unfortunately sponsor on shared hosting , can't put crossdomain.xml in server root, can't connect localhost flash game ( same origin policy ). learned there way connect rest api proxying calls through php file on different server. so have proxy.php file on private server, , calling like: www.myserver.pl/scripts/proxy.php?url=http%3a%2f%2sponsorserver.hosting.com/api/init.json (url=urlencoded address) it connects (returns http 200), don't know yet how pass custom headers init.json script; tried combinations sending them through , post, calling script through , post (using restclient ff extension). this proxy.php: $getvars = 'myparam1=3;&myparam2=data;'; // test purposes $url = $_get['url'] . '?' . $getvars; $sessio

xml - Why my list view doesn't scroll in android? -

i have list view when populated data doesn't scroll. why happening think there's no problem java code. think problem xml. here's xml <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_main" tools:context=".ireportmain" > <relativelayout android:id="@+id/header" android:layout_width="match_parent" android:layout_height="83dp" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:background="@drawable/bg_nav" android:gravity="top" > <imageview android:id="@+id/logo1" android:layout_width="150dp" android:layout_height="80dp" android

ios - is it ok to copy and paste an adBanner i have on one screen to the next without changing code? -

i have adbanner on first screen , wondering if ok copy , paste onto other screens or require coding ? p.s having adbanner on more 1 screen make more revenue or 1 screen fine? having ad banner on multiple screens increase likelihood of user noticing ad , clicking through (which generates revenue you). make sense code against api ad , display on each screen api handle tracking click throughs , refreshing new ad after specified amount of time.

ruby on rails - Add multiple items to a cart at the same time -

i have following relations : class cartitem belongs_to :cart belongs_to :product class product (<=> category) has_many :cart_items class cart has_many :cart_items when adds product cart, creates line in cartitem table cart.id , product.id. can add et remove product cart on edit page, works. but add or remove more 1 product cart @ same time. need input number field when customer put number want add/remove. however, don't manage because in edit form, if put field called example "number" (for each product) error appear because there no attribute "number". should add "field_tag" how can work ? in advance i work on ecommerce gem written rails called spree . here's how we've solved problem. we have 4 models: variant , product , order , lineitem . these form basics of our ordering system. variant can considered "mutation" of product. have tshirt come in red, green or blue. product tshirt, while colours variant

android - Jerky scrolling when adding/removing views to ScrollView's child -

i hope can give idea on how improve performance of scrolling on app. basically have tiles/images being generated in secondary thread, , once ready add them relativelayout on specific position layoutparams. i'm setting size of relativelayout fixed avoid complexities. relativelayout 1 add scrollview. i listen scroll change event of scrollview, able request new tiles when scroll new position. when happens, new tiles generated on secondary thread, , @ same time information remove old tiles not necessary anymore (this helps keep quantity of tiles not blow out memory). but, main problem here while scrolling , adding/removing tiles (using addview() , removeview()) scrolling jerky. have same app in ios, using same approach , scrolling perfect. here's have: // main activity relativelayout tilecanvas = new relativelayout(this); tilecanvas.setlayoutparams(new layoutparams(800, 10000)); scrollview scroll = new scrollview(this). scroll.addview(tilecanvas); setcontentview(scrol

layout - 960gs grid Inside grid -

is possible have inside grid surrounded outer grid contents flows around inside grid happens in image float left/right. ---------------------------| | | | grid_8 | | | |------------| | | | | | grid_4 | | | | | |------------| | | | | | |--------------------------| thank try this http://jsfiddle.net/qcjef/2/ css .grid_8{ width:960px; background-color:red; border:#fff 1px dashed; padding:95px 0 110px; vertical-align:middle; } .grid_4{ width:480px; background-color:blue; border:#fff dashed 1px; padding:100px 0; margin:100px 0 0 0; }

javascript - text nodeValue containing HTML entity -

i'm creating real time html editor loads after dom has been rendered, , builds source looping through nodes. i've noticed when try read nodevalue of text node containing html entity, rendered unicode value of entity. how can read rendered text node, , keep html entity code? (using vanilla js) example: <div id="test">copyright &copy;</div> <script> var test = document.getelementbyid('test'); console.log(test.childnodes[0].nodevalue); // expected: copyright &copy; // actual: copyright © </script> unfortunately can't. text interface inherits characterdata , , both interfaces provide domstrings return value, contains unicode characters. furthermore, html5 parsing algorithm removes entity entirely. defined in several sections of 8.2.4 tokenization . 8.2.4.1 data state: describes ampersand puts parser character reference in data state 8.2.4.2 character reference in data state describes tokens followed

performance - Javascript nested function call optimization -

edit! changed answer own after lot of follow-up research showed there isn't simple answer question. see below! so, in followup last question, i'm trying better handle on best javascript practices optimize performance. following example, i'm testing in chrome 28.0.1500.70 using in-browser profiler. i've got math functions encapsulated in object getting called few hundred k-times second , trying shave bit of execution time. i've done optimization making local copies of parent objects locals locals in called functions , got decent (~16%) performance boost. however, when did same calling function parent object, got huge (~100%) performance increase. the original setup calcneighbors calling fellow parent object function cirind via this.cirind. making local var copy of cirind , calling instead gave huge performance gain, less half execution time before calcneighbors. however, making cirind inline function in calcneighbors caused return same slower per

javascript - Variable undefined when waking from sleep in Chrome -

using mac os x 10.8.4, chrome 27 (latest stable). i have script every x seconds (with setinterval() ) makes ajax call jquery see if there's still connection server (heartbeat). posts data , depending on if succeeded or not, calls other functions. it works fine until mac goes sleep (screen black, hdd powers down, etc.), wake , ajax call failed , tried call function (variable) apparently no longer exists: post http://mywebsite.com/index.php jquery.min.js:4 uncaught typeerror: cannot call method 'onlost' of undefined onlost function within other variables, such mylib , anotherlib . instantiated in loading page. code lot more complex, here's simplified version: var mylib = new mylib(); mylib.anotherlib = function() { this.onlost = function() { ... }} setinterval() { function() { $.ajax({ failed: mylib.anotherlib.onlost }); }, 10000); after error occurs, script behaves normal. can access mylib , onlost() fine. know browsers implement settimeout() , s

sql - Oracle case inside where clause -

this simple question, i've read details using case in where clause, couldn't able make clear idea how use it. below sample query: 1 select * dual 2 (1 =1) 3 , (sysdate+1 > sysdate) 4 , (30 > 40) 5 , (25 < 35); i have procedure i_value in parameter. need ignore 4th line if i_value 's' , need ignore 5th line if i_value 't'. thanks in advance. i think best way solve problem: select * dual (1 = 1) , (sysdate + 1 > sysdate) , case when i_value = 's' case when (25 < 35) 1 else 0 end when i_value = 't' case when (30 > 40) 1 else 0 end end = 1; of course, use dynamic sql, it'd more difficulty , less effectively.

file io - What is AVG I/O request for normal EC2 Instance with web server on Amazon AWS -

i have amazon ec2 instance ebs volume. standard ebs volumes billed $0.10 per 1 million i/o requests now not able guess how normal i/o request normal server. , in max case how large can be. how can metrics or stats somewhere can see how max busy server can see how max can get? i know can find way of controlling it. presently, have 1 public site not traffic want know if traffic increases how max can go. if you're worried price predictability may consider switching piops volume on standard ebs volume. ebs web site : with provisioned iops volumes, charged amount provision in iops (input/output operations per second) x percentage of days provision month. the predictable billing model of piops volume (not mention performance) can make them attractive workloads.

javascript - Insert data into database using ajax -

i using ajax insert data in database my default .aspx file below <%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>ajax demo</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#<%= btn_insert.clientid %>").click(function () { //var name = $('#<%=txt_name.clientid%>').val(); //var email=$('#<%=txt_email.clientid%>').val() var email = document.getelementbyid('txt_email').value; var name = document.getelementbyid('txt_name').value;

java - Notation of the Dynamic Querying Associations -

in latest documentation of grails , can read: querying associations. associations can used within queries: def author = author.findbyname("stephen king") def books = author ? book.findallbyauthor(author) : [] i'd know meaning of ? , : [] shorthand if statement in groovy (and java , see first comment). def books = author ? book.findallbyauthor(author) : [] is equivalent of: def books if (author) { books = book.findallbyauthor(author) } else { books = [] } see elvis operator ( groovy only, not java ) here .

coldfusion - Database migration issue -

my application supposed migrate new database. changed application.cfm set new password. nothing else. asked admin update dsn info , provided dsn entry details, says has updated. next tried log application. entering incorrect login/password giving expected error message. if login successful, instead of going welcome page showing: "internet explorer cannot display webpage" one issue admin told : "the site appears looping continuously until bombs out" can please me figure out going wrong here? issues login cookies? should start investigating? thanks in advance code snippet here : <cfparam name="dest" default="#desturl#"> <cfparam name="url.sfx" default=""> <cfif not isdefined("cookie.essec")> <cfset client.status="cookie not set"> <cfinclude template="deleteclientvars.cfm"> <cfmodule name=cspauth environment="prod"

jpa - Criteria Query with BigMoney from Joda Money (Multi-Column field in Entity) -

i have serious issue criteria query. my entity class looks this: class x { ... @columns(columns = { @column(name = "pricecurrency", nullable = false), @column(name = "priceamount", nullable = false)}) @type(type = "org.jadira.usertype.moneyandcurrency.joda.persistentbigmoneyamountandcurrency") @basic(fetch = fetchtype.eager) bigmoney price; ... } and have class y has list<x> xs . i have working normal jpa query: select y y y left join y.xs x group y order sum(y.price.amount) now i'd transfer criteriaquery. started with: criteriabuilder cb = entitymanager.getcriteriabuilder(); criteriaquery<y> q = cb.createquery(y.class); root<y> root = q.from(y.class); listjoin<y, x> j = root.join(y_.xs, jointype.left); q.groupby(root); i tried few things, none of them worked :( here few examples: path<bigdecimal> x = j.get("priceamount"); or: path<bigdecimal&

c++: override template member function in parent class -

let's suppose have such structure of classes: base class object , parent class bool , int , float , bytes , unicode classes. before had functions bool cast_bool() const , int cast_int() const , etc. virtual functions in object class , in child classes i've implemented these functions separately. it seems better solution implement template <typename type> type cast() const function instead. however, since c++ prohibits virtual template functions don't know how can complete task. need provide template <typename type> type cast() const object , childs. generic object::cast<type>() const throw casterror ; every type bool , int , etc. i'll implement functions bool::cast<bool>() const , int::cast<bool>() const , etc. i'm planning add cast builtin objects, though overload operator bool() const , operator signed short() const , etc. if there no implementation, template must switch generic form object class, throwing error. there w

Google App Engine Channel "Data Sent" daily quota for billing enabled app is 2GB. Is this correct? -

according docs: https://developers.google.com/appengine/docs/quotas#channel the daily quota billing enabled apps sending data through channel api capped @ 2gb. correct? i think it's small. if had app sent data every 5 seconds (at 32kb per message) hour, i'd on quota in hour 90 users. 2gb volume cap cloud solution seems bit small. am missing something? i don't think correct. billing enabled app shows in quota details: channel data sent 0% 0% 0.00 of 2,088.13 gbytes

c# - How to disable menu strip submenus -

Image
i need disable menu item's sub child dynamically. here in menu bar if clcik run @ startup, disable startup option should disabled how achieve this. have attached snapshot reference // run @ startup private void runatstartuptoolstripmenuitem_click(object sender, eventargs e) { rkapp.setvalue("timecalculation", "\"" + application.executablepath.tostring() + "\""); environment.getfolderpath(environment.specialfolder.startup); menustrip1.items["disablestartuptoolstripmenuitem"].enabled = false; } //disable startup private void disablestartuptoolstripmenuitem_click(object sender, eventargs e) { rkapp.deletevalue("timecalculation", false); menustrip1.items["runatstartuptoolstripmenuitem"].enabled = false; } snapshot: use flag: private bool flag = true; private void runatstartuptoolstripmenuitem_click(object sender, eventargs e) { //... flag = true; } private void

linux - Java - API support for traceroute? -

is there anyway can output of traceroute in java. know use exec want know if there api can fetch output me not worrying platform. can try using following api : http://jakewharton.github.io/pingdom-java/apidocs/com/jakewharton/pingdom/entities/traceroute.html github link: https://github.com/jakewharton/

asp.net mvc - Is there a performance sacrifice when calling a C# helper from razor? -

if (from razor view), call c# helper (i.e compiled dll). there performance loss here? e.g i use @model.user.getfriendlyname(); (calls method in model inside dll). or pass friendlyname razor view, (storing in viewmodel initially). is there speed difference between these 2 methodologies? calling user.getfriendlyname() isn't slower in view anywhere else. razor views compiled classes behind scenes. one thing keep in mind if method gets database cause queries , if using orm lazy loading context/session lost then.

java - Uploading mutiple videos by mutiple users on Server -

we have urgent functionality in our project, multiple users can ask questions , queries in form of videos files (pre-recorded or record application) , admin/sub admin can reply them in form of video file(recorded application). considering nature of application, there lot of data streaming on server , lot of storage required kept video files on server. planning store , kept videos files separately on centralized third-party server " youtube ". youtube api allows store , upload videos files on server account specific. there possibility can store our application video files on youtube server in 1 centralized account? i tried youtube data upload api 2.0, require authentication login (google account) form end-user uploading video files. don't want end-users know files going on. so, requirement have upload videos( without providing google account credentials ) in 1 centralized account(that kept @ property file). there possible solution scenario? if above solution fa

create a div dynamically for every row in database table ASP.Net -

i'm designing website fyp, have customerorder page, , vieworders page, customer places order in customerorder page. in vieworders want display result of sql query, in dynamically created "div" , "labels" css assigned them each row of table, in following sqldatareader.tnx protected void page_load(object sender, eventargs e) { string localcnnstring = configurationmanager.connectionstrings["lgdb"].tostring(); sqlconnection sqlcnn = new sqlconnection(localcnnstring); sqlcommand sqlcmd = new sqlcommand(); sqldatareader dreader; sqlcnn.open(); sqlcmd.connection = sqlcnn; sqlcmd.commandtype = commandtype.storedprocedure; sqlcmd.commandtext = "myrpoc"; dreader = sqlcmd.executereader(); while (dreader.read()) { //dynamic controls } dreader.close(); sqlcnn.close(); } } this scenario can sol

nunit - Do the SetUp and TearDown methods need [RequiresSTA] if tests have it? -

i can run watin tests resharper without issues. each test has requiressta attribute , runs fine. when try run tests in class (testfixture) following error: one or more child tests had errors exception doesn't have stacktrace <testname> ignored: invalid signature setup or teardown method: testsetup <testname> ignored: invalid signature setup or teardown method: testsetup <testname> ignored: invalid signature setup or teardown method: testsetup the error doesn't indicate need change make work. if select tests have been ignored in unit test sessions window, can run them without problems. what must change allow me run tests in testfixture? i have met same problem. changed setup() , teardown() methods public, worked.

hp ux - Hp-Ux.Shell.Using variables in "if" -

recently i've got confused following situation. difference between 2 if usage: case 1 amount=10 if [[ $amount -eq 10 ]] echo "something" fi script output: $ ./1.sh case 2 if [[ amount -eq 10 ]] this works (note variable name doesn't contain $ ). so question how work without dollar sign in variable name. p.s. i'm using posix shell on hp-ux. man bash arithmetic evaluation ... shell variables allowed operands; parameter expansion per‐ formed before expression evaluated. within expression, shell variables may referenced name without using parameter expansion syntax. in context shell not expect numerics, expands strings variables. makes sense me.

How to convert special symbols in web scraping with R? -

i learning how scrape web xml , rcurl packages. goes except 1 thing. special characters ö or č read in differently r. instance í read in í. assume latter sort of html coding first. i have been looking way convert these characters have not found it. sure other people have stumbled upon problem well, , suspect there must sort of function convert these characters. know solution? in advance. here example of code, sorry did not provide earlier. library(xml) url <- 'http://en.wikipedia.org/wiki/2000_wimbledon_championships_%e2%80%93_men%27s_singles' tables <- readhtmltable(url) sec <- tables[[6]] pl1r1 <- unlist(strsplit(as.character(sec[,2]), ' '))[seq(2,32, 4)] enc2utf8(pl1r1) # not seem work try parsing first while specifying encoding, reading table, here: readhtmltable , utf-8 encoding . an example might be: library(xml) url <- "http://en.wikipedia.org/wiki/2000_wimbledon_championships_%e2%80%93_men%27s_singles" doc &

security - need to develop utility independent of technology used for website development -

i need utility given customer having site name a.com can decry-pt messages passed own site (i.e. b.com), build in java technology. utility should independent of technologies used customer web site development. question: technology should used developing such utility ? note: have read javascript not cryptography. the best option use existing, tried-and-tested protocol. tls choice securing communication between 2 parties. if, reason, cannot use existing protocol, you'll have design own, , describe in such detail others can implement on platforms. far ideal several reasons. designing cryptographic protocols hard, , experts regularly wrong. implementing cryptographic protocols hard too, , experts wrong. there no way non-cryptographer design or implement secure protocol.

sed - find specific names in unix -

i want print cities fulfill 3 conditions: capital , clean , big . input: london big city london capital london clean city ohio big city sydney big city sydney clean city canberra capital canberra big city canberra clean city newyork big city newyork clean city output: london canberra i need names fulfill 3 conditions: capital, clean , big. i tried cut first column in separate file each city grep name file|wc -l , take have count more 3. how can done in unix using sed or awk . just fun. the shell hacker's solution: sort -u input.txt | cut -d' ' -f1 | uniq -dc | egrep '^\s+3\s' the perl hacker's solution: #!/usr/bin/perl use strict; use warnings; use constant { capital => 1, clean => 2, big => 4, }; %table; while(<>) { print stderr "unparsed: $_" unless m/^(\w+)\s+is a\s+((big city)|(clean city)|(capital))\s*$/gio; $table{$1} |= defined($3) * big + defined($

java - Generate more than one random numbers using native or built-in function -

i know generating random number there random function in java for example int randomnumber = ( int )( math.random() * 9999 ); which generate randomnumber [0,9999] returns 1 number given range. but want know if there built in function or can native function generate more 1 random numbers , should not match each other suppose above example if want generate 4 number it return 1,10,50,5544 here can see there 4 random number , not matching each other . try create arraylist , add random number , while adding check if arraylist contains number or not. eg: arraylist<integer> numbers = new arraylist<integer>(); while (numbers.size()<=your_max_size) { int randominteger = ( int )( math.random() * 9999 ); if (!numbers.contains(randominteger)) { { numbers.add(randominteger); } }

jquery - How can i retrieve an image of <img> tag into the variable in javascript? -

how can image of <img> tag , store in variable in javascript (or equivalently jquery) ? (actually want swap images between 2 <img> tags). jquery has specific uses .prop() vs .attr() make sure read on that: http://api.jquery.com/attr/ but once assigned src of 1 image variable: var img1_src = $("img#image1").attr("src"); you can take variable , shove source of image: $('img#img2').attr('src', img1_src);

asp.net mvc 4 - Roles with Profie Principal like in Stackoverflow -

i have implement membership role profile . what means: role profile ? example have manager role want give him special permissions, example read special documents or add data. or have member agent role able readonly . i using membership & roles providers. can give suggestion how implement kind of role profile or principal on application ? here article how configure membership provider (and role provider) in mvc. note: need membership provider in order role provider work. otherwise, have manually create principal object (i not recommend it) . then add rolemanager tag in web.config. <rolemanager defaultprovider="defaultroleprovider"> <providers> <add name="defaultroleprovider" type="system.web.providers.defaultroleprovider" connectionstringname="defaultconnection" applicationname="/" /> </providers> </rolemanager> then use authorize filt

php - save session of page redirect in ie -

i create login page. when user submit "username" , "password" if username , password true page redirect header("location:home_page.php"); code work in firefox in ie8 doesn't work. search , understand ie has problem session(that sent page, iframe , popup) found solution told me set header privacy policy (p3p). , set header problem not solve. please me. i use echo '<script type="text/javascript">window.location.href="home_page.php";</script>'; problem not solved some time can not discover why header errors appear use javascript header instead php like: echo '<script type="text/javascript">window.location.href="redirectpage";</script>'; you can use html meta tag php redirection.

javascript - Unable to get property 'then' using promises -

i want have clear code app. decided separate xhr call , parsing view.js. added : in view.js this._pagepromises.push(myapp.services.foo.getfoo() .then( function success(results) { var x = results; }, function error() { // todo - handle error. } )); and in services.js foo: { getfoo: function () { winjs.xhr({ url: "http://sampleurl.com" }).done( function completed(request) { //parse request var obj = myapp.parser.parse(request); return obj; }, function error(request) { // handle error conditions. } ); } } but have exception : 0x800a138f - javascript runtime error: unable property 'then' of undefined or null reference what want there : start promise in view.js stuff , update view when getfoo() completed. i'm not doing right way c# developper have difficulties understand pattern

php - Error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean give -

this question has answer here: mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 33 answers can me code please, <link rel="shortcut icon" href="<?php echo url_global; ?>graficos/logoicon.jpg" /> <?php $listaaj = mysql_query("select * ajuste limit 0,1"); $rowaj = mysql_fetch_array($listaaj); ?> <title><?php echo $rowaj['titulo']; ?><?php if($activaseo=="si"){ echo " - ".$inctitle;}?></title> error: error: warning: mysql_fetch_array() expects parameter 1 resource, boolean given in /incluir/seo.php on line 5 how can solve error? thanks. your query cannot execute. suggest pop in error-reporting, full sql-error message: $listaaj = mysql_query("select * ajuste limit 0,1") or

ubuntu - How much memory Java needs to start? -

this script (i'm trying experiment fix bigger problem): #!/bin/bash java_opts="-xms64m -xmx64m" in 1 2 3 4 5 6 7 8 9 10 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -version & done in nutshell, i'm trying start 10 java processes @ same time. server has 512mb of ram , 4gb of swap. should more enough ten processes 64mb each. however, see in output 2 of them: error occurred during initialization of vm not reserve enough space card marking array error occurred during initialization of vm not reserve enough space code cache why happening? how resolve? crashed processes created files start: # there insufficient memory java runtime environment continue. # native memory allocation (malloc) failed allocate 160088 bytes hashtablebucket in /build/buildd/openjdk-7-7u21-2.3.9/build/openjdk/hotspot/src/share/vm/utilities/hashtable.inline.hpp # possible reasons: # system out of physical ram or swap space # in 32 bit mode, process size limit hit # possible

Search by part of word with solr dismax -

how can search part of word dismax? example when query "wor" want results " wor d" " wor ld" "ad wor ds" etc. fields values. possible? check edgengramfilterfactory filter <filter class="solr.edgengramfilterfactory" mingramsize="3" maxgramsize="25" side="front"/> edgengramfilterfactory generates edge grams token e.g. word generate -> wo, wor, word ..... you can use @ index time generate tokens. when search wor , documents word match however, if want search in mid of words check ngramfilterfactory

c# - Why does sitecore ignores default value 0 by type integer? -

i'm using sitecore. project have created template simple type integer field. integer field has default value of 0. when create new item based on template value 0 (default value), not displayed. changing default value 1 (for example) displayed. there knows how fix issue? thanks lot. jordy sitecore not ignore default value 0 . value '0' stored in sitecore integer field it's not displayed field default value int type (or maybe long cause know value parsed long ). if change show raw values value displayed. and if access field value code, 0 .

c# - Where is the place to add custom arguments to button click? -

this can seems simple question ... crux how match button delegate signature void, object, eventargs method or use event delegate. as example, have code button changes color when it's clicked. however, button1.click += new eventhandler(kk.changecolor); carries eventargs button changecolor(object sender, eventargs e) method, meaningless rest of code use coloreventargs; , button1.click += delegate(object sender, eventargs e){ kk.changecolor(sender); }; doesn't allow later removal of delegate later in code. so better? adding unnecessary parameters methods match button delegate or suffering not being able remove delegate later ? or how change delegate signature of button? it seems there must 'cleaner' way this? will appreciate advice. " it seems there must 'cleaner' way this? " in opinion, better design depends on changecolor method do. if doing specific operation closely related event button clicked, leave real even

jquery - JavaScript Statements in Global Scope -

i've written if statement in .js file outside function means in global scope, right? here code snippet:- if ((window != window.parent) && (document.referrer.indexof("facebook") != -1)) { window.fbasyncinit = function() { fb.init({ appid : '...', status : true, xfbml : true }); }; (function(d, s, id){ var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) {return;} js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/all.js"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk')); } is better write statement in following manner:- (function() { if ... })(); what benefit of doing so? , these type of functions called? they called immediately-executed functions (ief). hear them called self-executing functions, of misnomer; not

How to hold ConEmu window from exiting? -

gurus i using using conemu command line run shell script in conemu. conemu exits after script completes. there way make conemu work "mintty -h always" keeps window open? conemu cli: conemu.exe /cmd c:\mybin\sh.exe my_script.sh i wish holds window like: mintty.exe -h -e c:\mybin\bash.exe my_script.sh thanks you may use following syntax conemu.exe /cmd c:\mybin\sh.exe my_script.sh -cur_console:c

javascript - Refreshing an ad-banner in a div container -

got webpage used voting on different pictures (voting-tool). on page there 2 different ad-banners stored in div containers. the ads loaded script fills divs ads. (just regular). now problem ads should reload after 5 pictures clicked or after amount of time. option of page reload not possible. if page refreshed pictures start @ picture 1 again, not useful if viewer @ picture 10. how can reload script / single div container on page page stays same , ads reload , show banner? any appreciated. note: i've tried with document.getelementbyid("addboxone").innerhtml it works fine text or pictures not script , with document.write("") while using document.write whole page gets overwritten , not div itself. , cant figure out how rewrite / refresh adbox edit: script of ad-banner <div class="superbanner"> div ad-banner in , want reload <script language="javascript"> if (typeof (wlrcmd) == "undefined&qu

c - Tick time calculation with signed values -

how can rid of potential overflow check if use signed integers? unsigned long ticks1 = gettickcount(); if (semaphoretake(_sema, to)) // taken { unsigned long ticks2 = gettickcount(); // take care of potential overflow unsigned long elapsed = ticks2 > ticks1 ? (ticks2 - ticks1) : (ticks1 - ticks2); // return rest time return elapsed < ? - elapsed : 0; } else // timed out return 0; no need overflow check. should ticks2 < ticks1 , unsigned math subtraction defined in c result mathematically same elapsed = (ulong_max + 1) + ticks2 - ticks1 . not want ticks1 - ticks2 . // unsigned long elapsed = ticks2 > ticks1 ? (ticks2 - ticks1):(ticks1 - ticks2); unsigned long elapsed = ticks2 - ticks1;

c - How to use fgetpwent()? -

i trying list of users in system (linux, fedora). , i've heard function: fgetpwent 1 need mission. sad part didnt find documentation or example of how use function. if give me example, great, in advance. no idea why ever have used it: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <crypt.h> #include <pwd.h> #include <sys/types.h> char *testentry = "testread"; static void read_etc_passwd (void) { struct passwd *pwd_entry = null; int found = 0; setpwent(); // go top of /etc/passwd while (!found && (pwd_entry = getpwent())){ if (0 == strcmp (testentry, pwd_entry->pw_name)){ found = 1; } } if (found) { printf ("name = %s\nhome = %s\n", pwd_entry->pw_name, pwd_entry->pw_dir); } else { puts("could not find entry looking for, or" "some error occurred"); } } void change_etc_passwd (void){ stru

javascript - JS unit test with Jasmine -

i new jasmine, infact started today , don't have prior knowledge writing js unit test cases. trying write simple test case in jasmine in order test basic js code. have added necessary scripts , libraries in project. so here piece of js code. fetching local australian date , time , arranging them in particular format. var date = { formatfulldate: function(date) { var localdate = this.getlocaltimefromaustraliatime(date), month = this.addzerotofront(localdate.getmonth() + 1), hour = this.addzerotofront(localdate.gethours()), minute = this.addzerotofront(localdate.getminutes()); return localdate.getdate() + '/' + month + '/' + localdate.getfullyear() + ' ' + hour + ':' + minute; }, formattime: function(date) { var localdate = this.getlocaltimefromaustraliatime(date), hour = this.addzerotofront(localdate.gethours()), minute = this.addzerotofront(localdate.getmin

java - How to make a program that will download xml data? -

i need make program download xml data website using java program not javascript , put android app. can me this? btw next step parse it. you can use method of read , write ! here code write xml file: final string xmlfile="userdata"; string username="username"; string password="password"; try { fileoutputstream fileos= getapplicationcontext().openfileoutput(xmlfile, context.mode_private); xmlserializer xmlserializer = xml.newserializer(); stringwriter writer = new stringwriter(); xmlserializer.setoutput(writer); xmlserializer.startdocument("utf-8",true); xmlserializer.starttag(null, "userdata"); xmlserializer.starttag(null, "username"); xmlserializer.text(username_string_here); xmlserializer.endtag(null,"username"); xmlserializer.starttag(null,"password"); xmlserializer.text(password_string); xmlserializer.endtag(null, "password"); xmlserializer.endtag