Posts

Showing posts from August, 2014

onclick - using c# in unity3D to open a window once the user clicked on a specific object -

i want write code in unity3d using c# whenever user clicked on object inside game window appears contain brief information (that retrieved database) object? can please me? i'm beginner =( here go, add script gameobject click using unityengine; using system.collections; public class onclick : monobehaviour { // use initialization private bool popup; public string info; void onmousedown() { popup = true; } void drawinfo() { rect rect = new rect (20,20, 300, 200); rect close = new rect (300,20,20,20); if (popup) { gui.box(rect, info); if (gui.button(close,"x")) { popup = false; } } } void ongui() { drawinfo(); } } this code should start.

serialization - Java can you make a predefined class in java serializable? -

i want send image object on network in java. im getting error. java.io.writeabortedexception: writing aborted; java.io.notserializableexception: sun.awt.image.offscreenimage the java image object doesn't implement serializable. there way around this? ive tried making subclass of image , implement got errors when using createimage method. help. edit* ok here code there kinda lot. idea of program pictionary game. can draw using basic tools , send on network , draw image on other clients screen. this basic draw area user , draw using line tool. on mouse released try , send image object on server. class paddraw extends jcomponent { image image; graphics2d graphics2d; int currentx, currenty, oldx, oldy; int linesize = 1; public paddraw() { setdoublebuffered(false); addmouselistener(new mouseadapter() { @override public void mousepressed(mouseevent e) { oldx = e.getx(); oldy =

regex - htaccess link redirect adds parameter -

i trying redirect old menu item new htaccess. works adds parameter not want. code is: redirect 301 /menu_cars_old.html http://www.domain.com/menu_cars_new.html rewriterule ^/?(menu_+[a-za-z._-]+)$ index.php?menu=$1 [nc,l] i not familiar htaccess asking help. redirect 301 statement should trick think has rewrite rule. redirected link looks http://www.domain.com/menu_cars_new.html?menu=menu_cars_old.html . if change redirect 301 /menu_cars_old.html http://www.domain.com/?menu=menu_cars_new.html it works don't want parameter in url. don't mix mod_alias , mod_rewrite rules. here how should have it: rewriteengine on rewriterule ^/?menu_cars_old\.html$ http://www.domain.com/menu_cars_new.html [r=301,nc,l] rewriterule ^/?(menu_+[\w.-]+)$ index.php?menu=$1 [nc,l,qsa] make sure place code in document_root/.htaccess

jsf 2 - JSF&primefaces after dialog closed background buttons don't work -

i have button open dialog: <p:commandbutton id="addbutton" value="Новая контрольная точка" oncomplete="dlg_add.show();" rendered="#{controlpointbean.selectedsubject != null}"/> and dialog wizard in it: <p:dialog widgetvar="dlg_add"> <p:wizard id="wizard" widgetvar="wizard"> <p:tab title="Тип контрольной точки"> <p:datatable id="cptypes" var="cptype" value="#{controlpointbean.cptypeslist}" rows="10" rowkey="#{cptype.id}" selection="#{controlpointbean.selectedcptype}" selectionmode="single" filteredvalue="#{controlpointbean.filteredcptypeslist}"> <p:column headertext="Тип контрольной точки" filterby="type" filtermatchmode="contains"> #{cptype.type} </p:column> </p:datatabl

Magento pass billing and shipping info to Sagepay module from IWD cart -

i using magento 1.7 iwd onepage checkout sagepay payment module. ( http://www.interiorwebdesign.com/magento/magento-one-step-checkout-module.html & http://www.magentocommerce.com/magento-connect/ebizmarts-sage-pay-suite-ce-sage-pay-approved.html ) the sagepay module works fine standard checkout, onepage checkout shipping , billing not pass , there enter shipping info error, or enter billing info. the validation script looks shipping 1st, shipping 1st error. shipping can passed unchecking ship address, , rechecking it. there error enter billing address. the billing address gets passed if page loads fields filled, cache etc. so seems data can passed, if there in right order/time. is there code add duplicate check/uncheck ship address or code pass billing info? best place out code? find checkout button , add: billing.save(); to onclick="checkout.save(); return false;" to onclick="billing.save(); checkout.save(); return false;&quo

Sencha touch nested navigation view -

Image
in app, have home page has following menu buttons: 1. button1 2. button2 3. button3 4. button4 now when tap button1 , app navigates page1 . (page1 navigation view). problem here is, default page1 not have button move home page. have manually add button. question 1 : there way push page1 view home view button auto generated? ok, manually added button on page1 . page1 navigation view having list. on clicking list item, moves subpage1 . now problem here is, there default button generated + manual button added. 2 buttons !! to solve this, hide manually added button on push. , show button on pop. again issue is, there slight delay in hide/show , visible in app. problem is, in older models of blackberry, manually added button not hidden !!! question 2 : better way handle !? finally, if want nested navigation view? say, have store 10 records. in page 1, display 3 records list - record1 - on tap of this, show detailed view record2 - on tap of this, show detail

android - closing sqlite in listview database with onclick method -

first of new developer of android learing please bear me. making app related book chapters , displaying content, got working listview populated database, facing bugs :- on leaving application having force close see log cat. in list view getting new data being appended in database. want 1 time only. chapter names constant book on chapter click, selected chapter list should open. please let me know how correct them mainactivity public class mainactivity extends activity { dbadchapter mydb; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); opendb(); registerlistclickcallback(); } @override protected void ondestroy() { super.ondestroy(); closedb(); mydb.deleteall(); } private void opendb() { mydb = new dbadchapter(this); mydb.open(); mydb.insertrow(999, "title 1&quo

Programmatically lock iPhone screen in iOS 7 -

i know can call gseventlockdevice (); graphicsservices.framework lock screen in ios 6 , older version, explained h2co3 here . unfortunately it's not working in ios 7 . my question : how lock iphone screen programmatically in ios 7 ? note : i don't want appstore. hi it's not possible in ios7. need special entitlement until there jailbreak out of luck

wpf - Access objects dynamically set / created by Templates -

Image
i began question here , doesn't seem concise enough. i have datagrid bound object (job): private string resultimagepath; // image shown in datagrid showing status private string name; // job container's name private string jobdescription; // sub task // , corresponding public properties implementing ipropertychange public int sequence; // sorting purposses // paths icons public string errorpath = "pack://application:,,,/resources/flag_red.ico"; public string successpath = "pack://application:,,,/resources/flag_green.ico"; public string warningpath = "pack://application:,,,/resources/flag_yellow.ico"; public string runningpath = "pack://application:,,,/resources/flag_running.ico"; public string historypath = "pack://application:,,,/resources/history.ico.ico"; when job object created gets resultimagepath set runningpath. jobs grouped using: collection = new listcollectionview(jobdata); collection.groupdescriptio

web services - Write full HTTP POST request packet -

i need write full http request invoke soap service. don't have libraries soap request need write full http packet. how i've proceeded (i'm programming arduino board): string body = httprequestbody("33", "77%"); client.println("post /dataserver http/1.1"); client.println("accept: text/xml, multipart/related"); client.println("content-type: text/xml; charset=utf-8"); client.println("soapaction: \"http://example.com/functions/senddatarequest\""); client.println("user-agent: arduino wifishield"); client.println("content-length: "+body.length()); client.println("host: arduino-data-server.appspot.com/dataserver"); client.println("connection: keep-alive"); client.println(); client.println(body); client represent connection webservice. httprequestbody function: string httprequestbody(string v1, string v2) { serial.println("generating xml message..."); s

surprising behavior in scala when using iterator over characters in file -

i'm getting inconsistent behavior when iterating on characters of text file. the following script import io.source val source = source.fromfile("blah") val iter = source.buffered iter.dropwhile(_.iswhitespace) for( c <- iter ) { println("""char="%c", byte=%d, iswhitespace=%b""".format(c, c.tobyte, c.iswhitespace)) } source.close() reads following file (begins 3 spaces, 'a' , second line of text) bc de outputs following char=" ", byte=32, iswhitespace=true char=" ", byte=32, iswhitespace=true char=" ", byte=32, iswhitespace=true char="a", byte=97, iswhitespace=false char=" ", byte=10, iswhitespace=true char="b", byte=98, iswhitespace=false char="c", byte=99, iswhitespace=false char=" ", byte=32, iswhitespace=true char="d", byte=100, iswhitespace=false char="e", byte=101, iswhitespace=false char="

html - Bootstrap Grid allows Vertical Scroll -

i have designed "coming soon" template has 1 little issue. have discover bootstrap grid in template allows "vertical scroll" , doesn't make sense me. have noticed in first part <!-- part1 --> , not know how prevent it. have applied css overflow-x: hidden (deleted demonstration), still want fix it. scrolling pressed mouse wheel (to right) still possible, please try. demo here . thanks in advance. i think mean horizontal scroll. issue don't have .container element in part 1 causes .row (with default margin of -15px on sides) grow outside of window, can either add container element markup or add css remove negative margins: #home > .row { margin-left: 0; margin-right: 0; } sidenote: may want remove left padding countdown list ul.cd have center correctly

excel - Replace values between range to single value -

i have column numerical data in cells ranging 1 500. want replace numbers 1,2,3,4,5,6,7,8,9 string "1-9". meaning if cell has 1 replace "1-9". if cell has 22 replace "20-29" , on. what formula this? please help. here crude way: =if(len(a1)=1,"1-9",if(len(a1)=2,left(a1,1)&"0-"&left(a1,1)&"9",if(len(a1)=3,left(a1,2)&"0-"&left(a1,2)&"9"))) examples 1 1-9 22 20-29 488 480-489 assumes values listed in column a.

c# - sending email from asp.net -

iam using asp.net , trying allow users send me email via website contact page , keep receiving following error server error in '/webcontactform' application. configuration error description: error occurred during processing of configuration file required service request. please review specific error details below , modify configuration file appropriately. parser error message: error use section registered allowdefinition='machinetoapplication' beyond application level. error can caused virtual directory not being configured application in iis. source error: line 44: asp.net identify incoming user. line 45: --> line 46: <authentication mode="windows"/> line 47: <!-- line 48: <customerrors> section enables configuration

jquery - Typescript: What is the best way to handle async requests -

in c# have await statements. handle async requests. using typscript because find hard work javascript now when using typescript dont know rigth way handle requests when posts have been processed. what best way handle that. both async keyword (1.7) , backwards-compilation ecmascript 6 (2.0) planned typescript. in meantime, both q , rsvp follow promises/a+ standard - , both have typings available typed. in depth there proposal introducing async keyword typescript . this feature scheduled part of typescript 1.7 (no guarantees). the news there will , in fact, backwards compile es5 (this scheduled typescript 2.0). not backwards compile typescript does, don't take notice of people typescript doesn't add javascript except types - there polyfills many ecmascript 6 features either available or planned, example (but not limited to): import * 'module'; let generators async / promises destructuring there occasional ecmascript 7 features landing

c - Trouble storing a struct in an array -

i want create database sort of, stores list of 5000 names , 5000 coresponding salaries array, can't find problem since console either crashes or compiler gives me following error: "cannot convert 'char* ( )[30]' 'char ' argument '1' 'char*' fgets(char*,int,*file)". edit: changed whatever figure out in code, , seem have issue line in particular: person* tab = calloc(n, sizeof(struct)); i can't spot other errors(lack of experience), , don't know use instead of fgets put in line. #include <stdio.h> #include <stdlib.h> #define n 5000 typedef struct { char name[30] int salary; } person; int main() { person* tab = calloc(n, sizeof(struct)); file * input; input = fopen("in.txt","r+"); int nr=0; int r; while(nr<5000) { fscanf(input,"%s",tab[nr].name); fscanf(input,"%d",tab[nr].salary); nr++; } printf("%s %d",tab[1].name,tab[1].salary

encoding - unicode:characters_to_list seems doesn't work for utf8 list -

i trying convert utf-8 string unicode (code point) list erlang library "unicode . input data string "АБВ" (russian string, correct unicode representation [1040,1041,1042]), encoded in utf-8. when running following code: 1> unicode:characters_to_list(<<208,144,208,145,208,146>>,utf8). [1040,1041,1042] it returns correct value, following: 2> unicode:characters_to_list([208,144,208,145,208,146],utf8). [208,144,208,145,208,146] does not. why happens? read in specification , input data either binary or list of chars, so, me, doing right. the signature of function unicode:characters_to_list(data, inencoding) , expects data either binary containing string encoded in inencoding encoding or possibly deep list of characters (code points) , binaries in inencoding encoding. returns list of unicode characters. characters in erlang integers. when call unicode:characters_to_list(<<208,144,208,145,208,146>>, utf8) or unicode:cha

c++ - libxml2 sax parser - extracting text nodes -

i wanted extract values text nodes xml input. have got following code web official documentation of libxml has many broken links of sax parser one. please me obtain value of text node. in startelementns when tried text node, null. appreciate here. my xml looks this: <a> <b> <c> text values </c> </b> </a> my code looks this: #include <stdio.h> #include <assert.h> #include <memory.h> #include <libxml/xmlmemory.h> #include <libxml/parser.h> #include <string> class parsefsm { public: /** sax2 callback when element start has been detected parser. provides namespace informations element, new namespace declarations on element. ctx: user data (xml parser context) localname: local name of element prefix: element namespace prefix if available uri: element namespace name if available nb_namespaces: number of namespace definitions on node namespaces: pointer

flash cs5 - Brightness from Image Difference? -

Image
i have 2 images same, except 1 has adjustment in brightness. is there way compute difference of these images in photosshop somehow see has changed 1 image another? image 1 image 2 (with brightness adjustment) you use blendmode difference. place first image on top of second , change blendmode of first 'difference'. the darker pixel less changed.

configuration - Salt-Stack / Vagrant : php 5.5 on ubuntu 12.04 -

by using file below, able 'php 5.3.10-1ubuntu3.8'. need @ least php 5.4 , php 5.5. can me out? i've been looking around hours , seems if not topic talked lot. thanks in advance. php.sls php5-fpm: pkg: - installed service.running: - enable: true - watch: - file: /etc/php5/fpm/pool.d/www.conf - require: - pkg: php5-fpm - pkg: php5-mcrypt - pkg: php5-curl - pkg: php5-mysql - pkg: php5-cli file.managed: - name: /etc/php5/fpm/pool.d/www.conf - source: salt://packages/php/www.conf - user: root - group: root - mode: '0640' - require: - pkg: php5-fpm just figured out can use repos! php5_ppa: pkgrepo.managed: - ppa: ondrej/php5 php5-fpm: pkg.latest: - refresh: true - require: - pkgrepo: php5_ppa service.running: - enable: true - watch: - file: /etc/php5/fpm/pool.d/www.conf - require: - pkg: php5-fpm - pkg: php5

java - why consumer thread is starting first? -

package producerconsumer; public class queue { int item; boolean isempty=false; public int put(int item) { this.item=item; return this.item; } public int get() { return item; } } package producerconsumer; public class producer extends thread{ queue q; public producer(queue q) { this.q=q; } @override public void run() { synchronized (q) { for(int i=1;i<=5;i++) { if(q.isempty==false) try { q.wait(); } catch (interruptedexception e) { // todo auto-generated catch block e.printstacktrace(); } system.out.println("producer produced = "+q.put(i)); q.isempty=false; q.notify(); try { thread.sleep(2000); }

c - Hexadecimal conversion from a file -

what wrong code? trying read in file line line , convert numbers in form of 0x"hex numbers" integers. returning 1 line , ends, input this 0x9c40 0x3b9ac9ff 0x754893gf 0x754893gf 0x754893gf 0x754893gf #include <stdio.h> #include <stdlib.h> #include <stdio.h> #define maxchar 1000 int main() { file *fp; char str[maxchar]; char* filename = "c:\\test.txt"; int number; fp = fopen(filename, "r"); if (fp == null){ printf("could not open file %s",filename); return 1; } while (fgets(str, maxchar, fp) != null) number = (int)strtol(str, null, 0); printf("%d\n", number); fclose(fp); return 0; } you forgot enclose while block in curly braces: while (fgets(str, maxchar, fp) != null) { number = (int)strtol(str, null, 0); printf("%d\n", number); } your code equivalent while (fgets(str, maxchar, fp) != null) {

session - PHP: session_status being bypassed? -

this question has answer here: how fix “headers sent” error in php 11 answers i'm getting error "cannot send session cache limiter" funny thing check status of session before called session_start(). if (session_status() == php_session_none) { session_start(); } is there circumstances session_status bypassed? don't print outputs or write html before using sessions.

unit testing - Manage transactions within a spring transactional test case. -

i have test case insert domain object. within domain object 1 of fields "deploymenttype" if not set postgres has default populate production. i want test in spring unit test of default set when insert deploymenttype set null , postgres taking care of it. my test case extends abstracttransactionaltestngspringcontexttests , has been annotated @transactional(propagation = propagation.nested) @transactionconfiguration(transactionmanager = "transactionmanager", defaultrollback = true) the unit test case follows. @test public void createcustomerwithsite() { this.customerservice.createcustomersite(testdata.makecustomersite(this.customer, "test-alias")); final list<customersite> list = this.customerservice.findcustomersites(this.customer.getid()); assertthat(list.size(), is(1)); final customersite cs = list.get(0); assertthat(cs.getclusterdeploymenttype(), is(clusterdeploymenttype.production)); } now since test transactio

ios - How to find the first index in array of dictionaries whereby the 'name' key begins with a certain letter? -

ok ones had me stumped while. how can find first index in array of dictionaries whereby key begins letter provided? my array contains 2500 dictionaries, each have name, longitude , latitude key. have letter @"s" how find index first dictionary in array whereby value key 'name' begins s? you use indexesofobjectspassingtest: (it provides stop bool can stop iteration). inside block, name dictionary. assuming want exact match source string against start of name, use hasprefix: check. set stop flag when match.

excel - How do I graph a value for a time range (without repeating time on the x axis) -

Image
i trying graph following information using bar graph: drift density time 0,23048397 12:00 15:00 0,053393365 15:00 18:00 0,433287679 16:00 19:00 0,129268147 17:00 20:00 0,656067688 18:00 21:00 0,356133746 19:00 22:00 0,083351634 20:00 23:00 0,167938106 21:00 00:00 the values on first column = y-axis 12:00 - 15:00 first value on x axis plotted against y-axis value 0,23048397 (as bar). the problem is: don't want next y-axis value 0,053393365 (as bar) represent 15:00 - 18:00. why? because time '15:00' show twice. in other words, have managed x-axis be: 12:00-15.00 ... 15:00-18:00....18:00-21:00 how can make 2 of x-axis 3 hour intervals share 1 common hour? 12:00-15:00-18:00-21:00 (and have pertaining y axis values side-by-side each other?) i hope description wasn't complicated. of great help! i don't think there way want in portable manner (i.e. without creating box of names , adjust position , size) using exc

Regex to Match word in brackets with mysql and keyword -

i'm having problems matching word or group of words in mysql query. for example. in database have sentences like: (just example...) john fast. sussy [fast]. peter tied jim first place. jim tied peter [first] place. $_query = $_link->prepare("select sql_calc_found_rows * tblpeople `text` regexp concat('[[:<:]]',:keyword,'[[:>:]]') limit :start,:count"); so user enters search term this: "was fast" or "for first" and results #1 first search or #3 second search. however want query match words inside brackets, searching was fast match #1 , 2, , searching for first match #3 , #4 . any appreciated.

shell - Bash. Get intersection from multiple files -

so let me explain bit more: i have directory called tags has file each tag, like: tags/ t1 t2 t3 in each of tag files structure like: <inode> <filename> <filepath> of course, each tag file have list of many files tag (but file can appear in 1 tag file once). , file may in multiple tag files. what want able call command like tags <t1> <t2> and have list files have both tags t1 , t2 in nice way. my plan right make temp file. output entire file of t1 it. run through each line in t2 , awk on file. , keep doing that. but wondering if has other ways. not overly familiar awk, grep etc. can use sort t1 t2 | uniq -d this combine 2 files, sort them, , display lines appear more once: is, ones appear in both files. this assumes each file contains no duplicates within it, , inodes same in structures particular file.

string - Random Number Gen to give out a word with a button click -

i have been working on code so, once button clicked random word string shown in place of textview. have forgotten how it! have far. button genbnt = (button) findviewbyid(r.id.genbnt); genbnt.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { random randomgenerator = new random(); int randomint = randomgenerator.nextint(100); string wordlist[] = new string[30]; wordlist[0] = "word one"; wordlist[1] = "word two"; wordlist[2] = "word three"; int text = randomgenerator.nextint(30); string wordtodisplay = excues[randomint]; } }); } } so have got string done, have forgotten go there, have gotten of code online. thanks

jquery javascript concatenate/variable issue -

i have html table inside of form tags. when click on cell inside of table jquery gives me “id” attr of cell. save “id” attr variable called id. when alert “id” id shows: alert(id); //outputs 39 however on next line have term1 = $form.find( "input[name='firstoneinput_" + id +"']").val(); alert(term1); //outputs undefinined // should output input value name attribute of "firstoneinput_39" why alert outputting undefined. btw put real values in text fields also. html <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jquery.post demo</title> <script src="http://code.jquery.com/jquery-1.9.1.js"></script>

powershell - In C# running the PoweShell script first and then invoke Get-Process returns 0 result -

in c# code have: powershell ps = powershell.create(); ps.addscript(". ...\\windowspowershell\\microsoft.powershell_profile.ps1"); foreach (psobject result in ps.invoke()) { console.writeline(result.tostring()); } ps.addcommand("get-process"); icollection<psobject> results = ps.invoke(); console.writeline(results.count); foreach (psobject result in results) { console.writeline("---" + result.tostring()); } if run get-process without running script before hand (by commenting out ps.addscript part , loop), get-process returns results; code provided return 0 get-process. any idea why 0? after each invoke, if want start new command instead of passing command pipeline previous command, should clear first: ps.commands.clear(); the complete code is: powershell ps = powershell.create(); ps.addscript(". ...\\windowspowershell\\microsoft.powershell_profile.ps1"); foreach (psobject result in ps.invoke()) { console

css - Multiple divs for a hover, changes color at end of webkit color transition -

i have css file separate main css file page. there 3 hyperlinks each own p tags, 1 under other, , each has own divs specifying webkit transition color when highlight. colors work great until end of webkit transition, @ point 3 links change color color specified in last class on css (gray). tried excluding last class, , sure enough, final color links became color specified in new "last class" (blue). this happens when have visited link, works fine when clear cookies , don't click on of links. seems a:visited, can see, have covered (i think...). here's css: .orangelink a:link:hover,a:hover,a:visited:hover { color: #cc7839; text-decoration:none; /* font-weight:bold; */ -webkit-transition:color 0.5s ease-in; -moz-transition:color 0.5s ease-in; } .bluelink a:link:hover,a:hover,a:visited:hover { color: #7290a4; text-decoration:none; /* font-weight:bold; */ -webkit-transition:color 0.5s ease-in; -moz-transition:color 0.5s ease-in; } .graylin

node.js - how best to 'tail -f' a large collection in mongo through meteor? -

i have collection in mongo database append logging-type of information. i'm trying figure out efficient/simplest method "tail -f" in meteor app - new document added collection, should sent client, should append end of current set of documents in collection. the client isn't going sent nor keep of documents in collection, last ~100 or so. now, mongo perspective, don't see way of saying "the last n documents in collection" such wouldn't need apply sort @ all. seems best option available doing natural sort descending, limit call, what's listed in the mongo doc on $natural db.collection.find().sort( { $natural: -1 } ) so, on server side afaict way of publishing 'last 100 documents' meteor collection like: meteor.publish('logmessages', function () { return logmessages.find({}, { sort: { $natural: -1 }, limit: 100 }); }); now, 'tail -f' perspective, seems have right effect of sending 'last 100 documents&#

Bash : Get the bytes at offset for length -

i wondering how retrieve bytes files given offset , length. i came following line : hexdump -n 4 -s 0x11c myfile i following : not enough, don't need offset. 000011c 00 00 8c d0 second try : hexdump -n 4 -s 0x11c -e '"%x\n"' myfile i following : better wrong endianness. d08c0000 so how can ? know parse sed, isn't there «cleaner» solution that ? hexdump -n 4 -s 0x11c -e '4/1 "%x " "\n"' myfile (my version of hexdump not produce one-byte hex output in first example. did use other command option?)

jquery - Javascript: Show XML If Word Is In URL -

i'm wanting make changes page. "preview" page in blogger when go preview post. far know there no conditional statement it. the preview page url looks this: http://mydomain.com/b/post-preview?token=############### so i'm trying use javascript "hey, if /b/post-preview in url, show hide element". i have been unsuccessful. attempt(and there others): $(document).ready(function() { if ((window.location.href) === '/b/post-preview') { $('homepage-slider-section').css('display', 'none'); } }); html: <div id="tobeornottobe">to or not be, question</div> javascript: $(document).ready(function () { console.log(window.location.href); if (window.location.href.indexof('fiddle') !== -1) { $('#tobeornottobe').css('display', 'none'); } }); fiddle

java - Reducing downtime to zero on jetty server with Chef -

so started deploying web app jetty server, noticed there 10 second downtime whenever redeploy web app after making changes. know there solution out there, have found leads such one . since using chef not sure how implement this. the link have provided bash script. check out chef's own bash resource . using bash resource, can run shell script via chef. this handy have script want do. run script via chef. of course, there might chef specific cookbook/recipe/attribute lying somewhere written. bash resource quickest possible way in regard want (presuming bash script referred need job done). update: check out my answer got done chef resource not exists

c# - What kind of the Content-Type will this request use? -

i trying access data service through http request using c# httpwebrequest. when contenttype x-www-form-urlencoded, works. need transfer files in request, used multipart/form-data , ran 401 error service. looks need somehow put files in x-www-form-urlencoded, how? i have working code in php. can explain, contentype uses in generated request and, thereafter, how files encoded? <?php function encode($str) { return iconv("windows-1251", "utf-8", $str); } function decode(&$resp) { if (is_array($resp)) { foreach ($resp $key => $value) { if (is_string($value)) $resp[$key] = iconv('utf-8','windows-1251', $value); else decode($value); } } } $url = "https://demo.krate.ru/api/v1/reports.json"; $api_key = "zzvahvcj6rg1dazaxo_c"; $request = array( 'request[acceptance]' => '@d:/users/rangerx/downloads/yvfurusnvwk.jpg', 'request[passport_scan]' =&g

c# - How to get a DataGrid column name when the header is clicked, WPF -

i trying determine column name of clicked column using following event handler. here xaml: <datagrid name ="loggedgrid" horizontalalignment="left" margin="-3,288,0,0" verticalalignment="top" height="198" width="973"> <datagrid.columnheaderstyle> <style targettype="datagridcolumnheader"> <eventsetter event="click" handler="columnheader_click" /> </style> </datagrid.columnheaderstyle> </datagrid> and here event handler, cannot figure out how determine column name after column has been clicked, ideas? private void columnheader_click(object sender, routedeventargs e) { } why not cast sender datagridcolumnheader , gets content this. private void columnheader_click(object sender, routedeventargs e) { string header = ((datagridcolumnheader)sender).content.tostring(); }

php - how to add this jquery to mysite -

i have jquery made in jsfiddle http://jsfiddle.net/8cfk6/ how go getting on site.... http://pcrepairs.tk/services.php i have : <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script> in head tags andthen <script language="javascript" type="text/javascript"> mycode </script> just before html in body. it isnt working :/ putting javascript code in wrong place? this should work ... $(document).ready(function() { $("#web").click(function () { $("#contweb").stop().slidetoggle(); return false; }); $("#web").hover(function () { $(this).stop().css({ "cursor": "pointer" }) }); $("#screen").click(function () { $("#contscreen").stop().slidetoggle(); return false; }); $("#screen").hover(function () { $(this).stop().css({

java - My custom textview too long when call in xml layout -

i created custom textview use custom font folder assets, class writed : public class textviewbold extends textview { private void init() { typeface face = typeface.createfromasset(getcontext().getassets(),"fonts/droid-sans.bold.ttf"); settypeface(face); settextsize(14); settextcolor(getcontext().getresources().getcolor(r.color.black)); } public textviewbold(context context) { super(context); init(); } public textviewbold(context context, attributeset attrs) { super(context, attrs); init(); } } i create 2 other class extends textview call in xml layout : <com.cmc.xcharge.widget.textviewbold android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ff00ff" android:text="hello" /> i build , run success, line: com.cmc.xcharge.widget.textviewbold long use , want u

Android: Camera Asynctask with Preview Callback -

i've managed camera preview custom filter (grayscale, hue, etc) working. custom filter applied preview callback manipulating array of rgb , drawing canvas display @ surface view. the drawback low fps. low fps, it's doing work in ui thread if don't in background thread using asynctask. tried use asynctask camera operation (my main purpose ui still working heavy work camera preview callback). but after used asynctask, didn't much. wondering implementation wrong or because asynctask ui thread still affected? snippet of code below: cameraactivity.java public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); log.d("activity_lifecycle","cameraactivity: oncreate"); setcontentview(r.layout.camera_layout); } @targetapi(build.version_codes.honeycomb) @override protected void onresume() { log.d("activity_lifecycle","cameraactivity: onresume"); if(preview == null){ previe

xml - Section must only appear one per config file. See the help topic <location> for exceptions. what's wrong? -

i couldn't figure out what's wrong configuration file here's configuration file <!-- more information on how configure asp.net application, please visit http://go.microsoft.com/fwlink/?linkid=169433 --> <configuration> <system.web> <httpruntime targetframework="4.5"/> <sitemap defaultprovider="main"> <providers> <add sitemapfile="mainmenu.sitemap" name="mainmenu" type="system.web.xmlsitemapprovider"/> <add sitemapfile="favourite.sitemap" name="favourite" type="system.web.xmlsitemapprovider"/> <add sitemapfile="mostview.sitemap" name="mostview" type="system.web.xmlsitemapprovider"/> <add sitemapfile="recentview.sitemap" name="recentview" type="system.web.xmlsitemapprovider"/> </providers> </sitemap> </system.web> <system.webse