Posts

Showing posts from July, 2010

apache - Regex is deleting the last character -

in implementing clean urls wanted map http://www.pikspeak.com/iframe/3/bird?autoplay=true http://www.pikspeak.com/iframe.php?id=3&img=bird&autoplay=true using following regex rewriterule ^/iframe/([^/\.]+)/([^/\.?]+)\\?([^/\.]+) /iframe.php?id=$1&img=$2&$3 but problem last character of value of img parameter (in 'bird') deleted, i.e. 'bir'. can please out issue. other not able to 'autoplay' parameter in php. thanks in advance i think \\? mean \? . no need escape \. in character classes. instead of trying match query string, use [qsa] modifier. rewriterule ^/iframe/([^/.]+)/([^/.]+)$ /iframe.php?id=$1&img=$2 [qsa]

C# How do I export a MemoryStream's content to the console and write the stream's content onto the console? -

the title says pretty all. i making logging system using "debug" class (debug.writeline, etc.), , i've attached textwritertracelistener can log strings has been written using debug write functions. e.g: memorystream stream = new memorystream(); textwriter standardoutput = new streamwriter(stream); textwritertracelistener writer = new textwritertracelistener(standardoutput); debug.listeners.add(writer); debug.writeline("123 test"); console.writeline("hi there!"); //*here add existing data in stream ('stream')* any idea how achieve this? instead of manually created memorystream use console.out represents standard output stream: textwritertracelistener writer = new textwritertracelistener(console.out); debug.listeners.add(writer);

apache pig - Unable to specify schema during storage with pig scripts -

ignore above query. incorrect. i have following pig script = load 'textinput' using pigstorage() (a0:chararray, a1:chararray, a2:chararray, a3:chararray, a4:chararray, a5:chararray, a6:chararray, a7:chararray, a8:chararray,a9:chararray); describe a; store 'output2' using pigstorage(); this works fine. however when modify store statement store 'output3' using pigstorage() (a0:chararray, a1:chararray, a2:chararray, a3:chararray, a4:chararray, a5:chararray, a6:chararray, a7:chararray, a8:chararray,a9:chararray); it fails below error 2013-05-04 11:49:56,296 [main] error org.apache.pig.tools.grunt.grunt - error 1200: mismatched input 'as' expecting semi_colon you don't specify schema when storing output pig. schema of alias you're storing whatever when created it. if wished change way it's stored like b = foreach generate (insert transformation here); store b 'output3'; if wished change way pigstorage writes alia

Django: South did not pick up a manytomanyfield -

i'm in middle of process of delivering changes dev prod. everything works on dev. i'm using django 1.4 the problem i'm facing south did not pick , did not create table manytomanyfield i'm using. on dev see there 21 mysql tables , 1 tables missing on prod. i don't know how solve this. this first time south added dev , prod. any ideas how create missing table? this did , error received: ./manage.py schemamigration companies --auto --update + added m2m table companyjobs on companies.company migration updated, 0003_auto, applied, rolling now... previous_migration: 0002_auto (applied: 2013-05-04 06:19:38+00:00) running migrations companies: - migrating backwards after 0002_auto. < companies:0003_auto fatal error - following sql query failed: drop table `companies_company_companyjobs` cascade; error was: (1051, "unknown table 'companies_company_companyjobs'") ! error found during real run of migration! aborting. ! since hav

c - How to use fscanf to read a line to parse into variables? -

i'm trying read text file built following format in every line, example: a/a1.txt a/b/b1.txt a/b/c/d/f/d1.txt using fscanf read line file, how can automatically parse line variables of *element , *next , each element being path section ( a , a1.txt , b , c , d1.txt , on). my structure follows: struct mypath { char *element; // pointer string of 1 part. mypath *next; // pointer next part - null if none. } you better off using fgets read entire line memory, strtok tokenise line individual elements. the following code shows 1 way this. first, headers , structure definintion: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct smypath { char *element; struct smypath *next; } tmypath; then, main function, creating empty list, getting input user (if want robust input function, see here , follows below cut down version of demonstrative purposes only): int main(void) { char *token; tmypath

delphi - TwebBrowser Zoom/Gesture is not working for firemonkey/iOs in XE4 when open a pdf file -

i want display pdf within ios application, far way find open in twebbrowser. a.it displaying in "fit page width" zoom default b.there no "zoom" function webbrowser1.navigate(file://mypdf.pdf') how to i want change zoom after open file (my solution encounter q#2) make zoom work (my solution encounter q#3) make gesture work web page for #1: i chagne webbrowser1.height/width in run-time, auto scale(zoom?) "fit width". yes works, , vertical scroll bar works flaw - not bounce on edge -> can scroll way down.. neither horizontal scroll, not reacting @ all.... *this because pdf a4, not sure happen landscape style for #2: beside using button clicks zoom, add gesturemanager. then add form1.ongesture "ios interactive gestures - image zoom" example. yes works, same thing - no vertical bounce, no horizontal scroll. *scrollbox not work, not work thing has build-in vert/hori scroll bars for #3 : go further, write c

javascript - Efficiently break an array every X number of values? -

i want split array group of values starting @ end , leaving beginning remander array. here's example of goal: arr = [0,1,2,3,4,5,6,7,8,9,10,11] interval = 5 #chop output = [[0,1],[2,3,4,5,6],[7,8,9,10,11]] what's efficient way of doing this? thanks help? var arr = [0,1,2,3,4,5,6,7,8,9,10,11], interval = 5, output = []; while (arr.length >= interval) { output.unshift(arr.splice(-interval, interval)); } output.unshift(arr); console.log(output);

c# - Multiple ASP timer not working under single update panel -

i have implement clock , 15 mins countdown ticker on aspx page. please not suggest me client side scripts not in requirement , knew load generating on server using asp ticker , update panel... knew flaws client requirements. aspx/html: <asp:scriptmanager runat="server" id="scr"/> <asp:updatepanel runat="server" id="up" updatemode="conditional" > <contenttemplate> <asp:timer runat="server" id="timer1" ontick="timer1_ontick" interval="1000"></asp:timer> <label id="lbltime" runat="server"></label> <asp:timer runat="server" id="timer2" ontick="timer2_ontick" interval="1000"></asp:timer> <label id="label1" runat="server"></label> </contenttem

linux - How to limit execution time on a php script -

i'm running php script via linux (not via browser) (php script.php). now, want limit execution time let's 10 seconds, means after 10 seconds process shutdown itself. how can that? tried set_time_limit. tried sleep(10); exit(); none of them made script shutdown. change maximum execution time (in seconds) in php.ini configuration file. max_execution_time = 7200 search in php.ini

mysql - Atomic in MongoDB with transfer money -

i'm new mongodb make simple application abount account in bank.an account can transfer money others design account collection that account { name:a age: 24 money: 100 } account { name:b age: 22 money: 300 } assuming user transfer 100$ user b , there 2 operations : 1) decrease 100$ in user // update document 2) increase 100$ user b // update document b said atomic applied single document no mutiple document. i have alter desgign bank { name: address: account[ { name:a age: 22 money: ss }, { name:b age: 23 money: s1s } ] } i have question : if use later way, how can write transaction query (can use findandmodify() function?) ? does mongodb support transaction operations mysql (innodb)? some pepple tell me use mysql project best way, , use mongodb save transaction information.(use collection named transaction_money save th

html - PHP Mail form not sending emails on Linux server -

this code , form... acts email sent, never arrives. i know possibly wrong... anyone? the website hosted on linux server, , don't know if server blocking emails because of kind of incompatibility... don't know be. <?php if($_post) { //check if ajax request, exit if not if(!isset($_server['http_x_requested_with']) , strtolower($_server['http_x_requested_with']) != 'xmlhttprequest') { die(); } $to_email = "myemail@gmail.com"; //replace recipient email address $subject = 'ah!! email out there...'; //subject line emails //check $_post vars set, exit if missing if(!isset($_post["username"]) || !isset($_post["useremail"]) || !isset($_post["userphone"]) || !isset($_post["usermessage"])) { die(); } //sanitize input data using php filter_var(). $user_name = filter_var($_post["username"], filter_sanitize_string); $user_email = filter_var($_post[&qu

c# - Issue with drag and drop -

i use following code drag , drop file c# winforms application. issue have dragdrop event handler takes while, , during time can't use window dragged file. how can fixed? private void formmain_dragdrop(object sender, drageventargs e) { string[] s = (string[])e.data.getdata(dataformats.filedrop, false); // long operation } private void formmain_dragenter(object sender, drageventargs e) { if (e.data.getdatapresent(dataformats.filedrop)) e.effect = dragdropeffects.all; else e.effect = dragdropeffects.none; } you may use backgroundworker operation need in different thread following : backgroundworker bgw; public form1() { initializecomponent(); bgw = new backgroundworker(); bgw.dowork += bgw_dowork; } private void form1_dragdrop(object sender, drageventargs e) { if (e.data.getdatapresent(dataformats.filedrop)) { string[] s = (string[])e.data.getdata(dataformats.filedrop, fals

ruby on rails - Updating database, what options do I have? -

i'm beginner in rails, , want know how can update database?(i'd know possible options it). i got simple table called users, got :name , :email attributes. as read can update :email by: user.find_by(:id => 1).update_attribute email, "sample@foo.bar" <- ok user.find_by(:id => 1).update_attributes :email => "sample@foo.bar" <- return me false and there way update by: @foo = user.find_by(:id => 1) foo.email = "sample@foo.bar" foo.save update_attribute skips validations. update_attributes returning false since it's not passing validation. double check user model validations , make sure under attr_accessible you've added email : class user < activerecord::base attr_accessible :email, :name # etc end also find don't have specify attribute, use integer: @user = user.find(24) # find user id of 24 @user.email = "sample@foo.bar" @user.save # or update_attributes can

dynamics crm 2011 - Applying Styles to rdl file -

is there anyway apply styles .rdl file imported microsoft dyanmics crm ? need apply custom font ssrs report without need install font clients machines any suggestions? you shouldn't need install font on client machines. font rendered on server long font installed on server hosting reports, should work. (i'm assuming you're using crm on-premise. if you're online think might out of luck)

web scraping - Scrape a Google Chart script with Scraperwiki (Python) -

Image
i'm getting scraping scraperwiki in python. figured out how scrape tables page, run scraper every month , save results on top of each other. pretty cool. now want scrape page information on android versions , run script monthly. in particular, want table version, codename, api , distribution. it's not easy. the table called wrapper div. there way scrape information? can't find solution. plan b scrape visualisation. need, codename , percentage, that's sufficient. information can found in html in google chart script. but can't find information 'souped' html. have a public scraper on here . can edit make work. can explain how can approach problem? working scraper comments on what's going on awesome. this difficult case, because kisamoto mentioned, data inside embedded javascript , not in seperate json file expect. possible beautifulsoup involes ugly string processing: last_paragraph = soup.find_all('p', style='clear:b

javascript - referencing multiple values inside an option element -

similar question can option in select tag carry multiple values? - except want reference values in javascript to recap: want return more 1 value selected item in selectbox - thinking this: <select id='selectlist'> <option value1="a" value2="b" value3="c">option 1</option> <option value1="d" value2="e" value3="f">option 2</option> </select> i want values of selected item: var sel = document.getelementbyid('selectlist'); selvalue1 = sel.options(sel.selectedindex).value1; selvalue2 = sel.options(sel.selectedindex).value2; selvalue3 = sel.options(sel.selectedindex).value3; currently can pull value='x' option need more values associated option. delimit 3 values 1 , later use string functions split them out, seem nasty. i think looking attributes property: var sel = document.getelementbyid('selectlist'); selvalue1 = sel.options[se

wso2 - How can i get HEADER in my ESB i am using following property, its not not working -

i getting data mobile client sending data in json sending values header wso2esb getting normal values using property <property name="asset" expression="//asset/text()" scope="default"/> but how can header in esb using property not not working <property name="username" expression="get-property('transport', 'accept')"/> how work revert me thanks in advance if trying access 'username', configuration should be: <property name="some_name_here" expression="get-property('transport', 'username')"/>

php - how to pass value from dynamic combo box into textbox? -

i working php. when user selects item combo box, corresponding item display in second combo box. need store second combo box value textbox further use. <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript"> $(function(){ $('#combo').change(function(){ console.log($(this)); $.get( "abc.php" , { option : $(this).val() } , function ( data ) { $ ( '#combob' ) . html ( data ) ; } ) ; }); }); </script> </head> <body> <form> <select name="combo" id="combo"> <option value="">-- select</option> <option value="1"> personnel</option>

css - jquery change image src and div positions onselect -

i have select box, want onchange image have change, , other divs change thier (css:top,right values) how jquery? i have code right (not in jquery , not change top,right of other divs..) <script type="text/javascript"> function swapimage(){ var image = document.getelementbyid("img"); var dropd = document.getelementbyid("text"); image.src = dropd.value; }; </script> <select id="text" onchange="swapimage()" style="width:70px;"> <option value="images/1.jpg">1</option> <option value="images/2.jpg">2</option> <option value="images/3.png">3</option> </select> here html working (you can inspect image element see src changing): http://jsfiddle.net/69gnc/1/ $("#text").on("change", function() { $("#img").prop("src", $(this).val()); //

Socket c bytes received but I can't print the String -

i use code receive string java server in c client. if( recv( to_server_socket, &reply, sizeof( reply ), msg_waitall ) != sizeof( reply ) ) { printf( "socket read failed"); exit( -1 ); } printf( "got reply: %d\n", ntohl( reply ) ); char buf[512]; ssize_t nbytes=0; int byte_count; byte_count = recv(to_server_socket, buf, sizeof buf, 0); printf("recv()'d %d bytes of data in buf\n", byte_count); buf[byte_count] = '\0'; printf("string : %s\n",buf); for example, when java server sends string bzzrecyvemjmif i got result recv()'d 16 bytes of data in buf string : so received 16 bytes printf("string : %s",buf); don't show me anything. the server sent string tyvudbbkalp3scp i tried code int i=0; while(i<byte_count){ printf("string : %c\n",buf[i]); i++; recv()'d 17 bytes of data in buf and result have string : string : stri

java - How to catch remote input using JSch ChannelExec -

i wrote program runs command on remote machine , halts. there program: import com.jcraft.jsch.*; import java.io.*; public class jschtest { private static string readstring(string prompt) { if (prompt != null) { system.out.println(prompt); } bufferedreader in = new bufferedreader(new inputstreamreader(system.in)); string input = null; try { input = in.readline(); } catch (ioexception e) { system.err.println(e); } return input; } private static boolean readboolean(string prompt) { while (true) { string input = readstring(prompt); if (input.equalsignorecase("y") || input.equalsignorecase("n")) { return input.equalsignorecase("y"); } else { system.out.println("enter y or n."); } } } public static void main(string[]

c++ - How to process command line arguments? -

yesterday made simple program in c++ uses arguments passed through command line. e.g. mydrive:\mypath\myprogram.exe firstword secondword the program run fine , has to, there's little curiosity have: had write argc --; before use well, otherwise have run-time crash [the compiler won't speak!]. in particular argc gives me bad time when don't give word argument program when run it... now works, isn't bad @ all, wonder why happening! [p.s. making argc --; , printing it, gives 0 value!] edit: here istructions use argc int main(int argc, char *argv[]) { [...] argc --; if(argc > 0){ if(firstarg.find_last_of(".txt") != string::npos){ reading.open(argv[1], ios::binary); [...] } } if ((!(firstarg.find_last_of(".txt") != string::npos)) && argc > 0){ [...] for(int = 1; <= argc; ++){ [...] totranslate = argv[i][j]; [...] tot

magento - Methods to automate magmi -

can tell me how automate magmi perform import on scheduled time every day. i have heard can done via cli dont know how use cli. please give me step wise procedure how cli , commands use automating imports. i saw magmi wiki site not understand how use cli. please give me proper solution how can automate magmi. i tried use below link working wget "http://user:password@example.com/magmi/web/magmi_run.php?mode=create&profile=default&engine=magmi_productimportengine:magmi_productimportengine&csv:filename=/magmitest.csv" -o /dev/null if can go system cron (cli version problem) here's complete solution i'm using in 1 of project (simplified version). i using company vendor name , module name magmi . first step install magmi usual. , think have installed. next, create app/etc/modules/company_magmi.xml following content <?xml version="1.0"?> <config> <modules> <company_magmi>

java - Started Process error stream is empty -

i'm trying control external process java code this: string[] args = { mpath, "\"" + filepath + "\"" }; processbuilder pb = new processbuilder(args); mprocess = pb.start(); then want read stderr : merror = new bufferedreader(new inputstreamreader( mprocess.geterrorstream())); if (merror.ready()){ //read } and ready() returns false. but after this: pb.redirecterror(redirect.to(new file("c:\\err.log"))); all error messages can found in err.log file. doing wrong ? try below code worked me. processbuilder builder = new processbuilder(args); builder.redirecterrorstream(true); // setting true

android - Using .split and getting content -

i have group of numbers divided comma(4 numbers in it) , groups divided ":". example(you see 3 groups): 2,0,6,46:3,14,22,12:0,45,65,12: ..... i want take numbers; mean : num[3][2] -> choose group which's first value 3 , 2 means take 2.value of group -> in example give 14 i want exist values: num[0][0,1,2,3,4]; num[1][0,1,2,3,4].... how can take group count? what kind of loop statement can use every value? i think cant go code further: int[][] num = new int[count of groups ][4]; // 4 number count in group string[] separated = stringtime.split(".|\\:"); num[0][0]= integer.parseint(separated[0]); num[0][1]= integer.parseint(separated[1]); num[0][2]= integer.parseint(separated[2]); num[0][3]= integer.parseint(separated[3]); string[] parts = string.split(":"); // split ':' groups int[][] num = new int[parts.length() ][4]; // make integer 2d array did (int i=0; < parts.length(); i++){ // run loop each outer/la

html - Image preload jquery -

i'm looking best way preload images jquery. i tried using code doesn't seem work: function preload(arrayofimages) { $(arrayofimages).each(function(){ $('<img/>')[0].src = this; // alternatively use: // (new image()).src = this; }); } // usage: preload([ 'img/preload.jpg' ]); this markup: <div class="item"> <img src="img/lookbook_item1.jpg" alt="lookbook_item1" width="187" height="259"> </div> <div class="item"> <img src="img/lookbook_item1.jpg" alt="lookbook_item1" width="187" height="259"> </div> <div class="item"> <img src="img/lookbook_item2.jpg" alt="loo

graphics - How to query GPU Usage in DirectX? -

how query gpu usage in directx? directx 11. if ever did it, provide me code snippet? process hakcer able this. see here: http://processhacker.svn.sourceforge.net/viewvc/processhacker/2.x/trunk/plugins/extendedtools/gpumon.c?revision=4927&view=markup a similar question has been asked here: how calculate load on nvidia (cuda capable), gpu card?

Gradle: 'clone' original jar task to create a new task for a jar including dependencies -

i create new task in project creates jar archive class files of project , class files of dependencies (also called 'shaded jar' or 'fat jar'). the solution proposed gradle cookbook modifies standard jar task of javaplugin: jar { { configurations.compile.collect { it.isdirectory() ? : ziptree(it) } } } however, keep original jar taks , have additional task shaeded jar, i.e. task behaves jar task, includes additional files according to from { configurations.compile.collect { it.isdirectory() ? : ziptree(it) } } and has classifier ('shaded'). i tried take on configuration of jar task copying properties this: task shadedjar(type: jar, dependson: configurations.compile) { dependencies = tasks.jar.taskdependencies source = tasks.jar.source manifest = tasks.jar.manifest includes = tasks.jar.includes classifier = 'shaded' { configurations.compile.collect { it.isdirectory() ? : ziptree(it) } } } but resulting tasks

How to fix undefined method error with nested resources in rails app? -

i error saying "undefined method `verses' nil:nilclass" when visit /books/1/chapters/1/verses/new my routes.rb: resources :books resources :chapters resources :verses end end verse_controller.rb: class versescontroller < applicationcontroller before_filter :find_book before_filter :find_chapter, :only => [:show, :edit, :update, :destroy] def new @verse = @chapter.verses.build end private def find_book @book = book.find(params[:book_id]) end def find_chapter @chapter = chapter.find(params[:chapter_id]) end end any adviceo on how fix this? the problem @ before_filter before_filter :find_chapter, :only => [:show, :edit, :update, :destroy] now hit new , there no before_filter triggered new , @chapter nil. solution: add :new array. update way ids using params not correct, params query string or post. need bit effort params path. before_filter: get_resources

haskell - What am I doing wrong with this meant-to-be-trivial higher rank polymorphism exercise? -

over year ago, asked question how use proxy in haskell , , since have small amount of use of rankntypes ghc extension. trouble every time try work it, end bizarre error messages , hacking around code until go away. or else give up. obviously don't understand higher rank polymorphism in haskell. try resolve that, decided right down simplest examples could, test assumptions , see if myself eureka moment. first assumption - reason higher rank polymorphism isn't standard haskell 98 (or 2010?) feature that, provided accept not-that-obvious restrictions lot of programmers wouldn't notice, isn't needed. can define rank 1 , rank 2 polymorphic functions are, @ first sight, equivalent. if load them ghci , call them same parameters, they'll give same results. so - simple example functions... {-# language rankntypes #-} rank0 :: [int] -> bool rank0 x = null x rank1a :: [a] -> bool rank1a x = null x rank1b :: forall a. [a] -> bool rank1b x = null x rank2

Clear text but keep image inside <a> hyperlinks using jQuery -

how can remove "product x" , keep images using jquery? <span class="product-field-display"> <a href="/products/product-a-detail" original-title="product a"> <img alt="product-a" src="/images/resized/product_a_180x180.png">product a</a> </span> <span class="product-field-display"> <a href="/products/product-b-detail" original-title="product b"> <img alt="product-b" src="/images/resized/product_b_180x180.png">product b</a> </span> i tried with: $j('span.product-field-display a').html(''); and with: $j('span.product-field-display a').text(''); but gets cleared , not text you can grab image, clear out anchor, , put image back: $j('#gkcomponent .productdetails-view .product-related-products .product-field-type-r span.product-field-display a').eac

standards - Where can I find the C specification? -

i in situation may have opportunity teach c students. university wants teach them pure c, not c++, keep advanced c++ course separate. since c++ derived c, there official "c rulebook" contains features of c, none of c++ features? reason want know can need teach students. i once saw (2000 page?) manual on c++ standard. such thing exist c, if 20/30 years old now? regards, ed edit: should point out know c/c++ quite having been teaching myself 3 years. thing don't know things "officially" c , things "officially" c++. aim learn can give other students better education give myself. you're looking c standard. since standards bodies fund through sale of standard publications, can't final version. however, there many copies of c draft standards out there enough purposes. https://www.google.com/search?q=c+draft+standard+pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf

css - How to align contents of <p:panel> vertical-align to center -

Image
in jsf-primefaces webapp having , need vertical-align contents center. how can that? <p:panel id="businesses_panel" header="#{business.businessname}" styleclass="mini-panel panel-grid tr panel-grid td panel-hover panel-header-title-small"> <div align="center"> <p:panelgrid columns="1"> <div class="component-spacing-top"/> <h:graphicimage alt="#{business.businessname}" value="#{business.logofullpath}" class="small-panel-image" /> <div class="component-spacing-top"/> </p:panelgrid> </div> <p:panel style="height:500px;position:relative;"/> <p:panelgrid columns="1" styleclass="centered"> <div class="component-spacing-top"/> <h:graphicimage alt="#{business.businessname}" value="#{business.logofullpath

Algorithm that costs time to run but easy to verify? -

i designing website experiment, there button user must click , hold while, release, client submits ajax event server. however, prevent autoclick bots , fast spam, want hold time real , not skip-able, e.g. doing calculation. point waste actual cpu time, can't guess ajax callback value or turning faster system clock bypass it. are there algorithm that fast & easy generate challenge on server costs time execute on client side, no spoof or shortcut time. easy & fast verify response result on server? you're looking proof-of-work system . the popular algorithm seems hashcash (also on wikipedia ), used bitcoins, among other things. basic idea ask client program find hash number of leading zeroes, problem have solve brute force. basically, works this: client has sort of token. email, recipient's email address , today's date. this: bob@example.com:04102011 the client has find random string put in front of this: asdlkfjasdlbob@example.

html - Regarding the absolute positioning property -

i have div have positioned using absolute positioning property of css. , want know whether there way allow div showing in exact same position seeing right in screen when screen smaller or larger without changing absolute positioning property of div? this rough example: <div class="name"> somewhere in body </div> ................... ..................so , codes... .................. <div class="display">i want stand beside class called name </div> if write css display, comes beside class name .display { position: absolute; width: 200px; top : 132px; [assume] left : 200px; [assume] border: #d3d3d3; -webkit-box-shadow: 5px 5px 15px #888; -moz-box-shadow: 5px 5px 15px #888; box-shadow: 5px 5px 15px #888; } it displaying correct screen. if screen size varies no longer showing correct position since have used absolute positioning property. want find whether there way or trick solve without changing ab

.net - specified cast from a materialized 'System.String' type to the 'CityType' type is not valid. - enum support in entity framework -

i have class: class citydetails { id int, //other attributes citytype type; } i using ef. trying data view , populate in list of citytype . citytype class has property name "type" of type citytype enum. view in sql server has column same name "type" , has values correspond enum element names. following code giving me error: list<citydetails> l = dbcontext.database.sqlquery<citydetails>(view_query).tolist(); error: the specified cast materialized 'system.string' type 'domain.models.views.citytype' type not valid. enum support has been available since ef 5.0. using ef 6 alpha 2.

pygtk - With GTK+ 3, how can I make a GtkScale trigger "value-changed" on mouse release? -

i have gtkscale , i'd fire value-changed events when mouse button release, i.e. not while you're dragging scale around. in gtk+ 2, there function called gtk_range_set_update_policy called with: gtk_range_set_update_policy(scale, gtk_update_discontinuous) but function has been removed. idea on how gtk+ 3? (the project i'm working on in python pygobject, answers in c or (most) other languages ok.) oh, got now. pretty obvious know do. anonymous pointed in right direction! on button-press-event , set flag avoids value-change code (actually switched use change-value event instead). on button-release-event unset it. obvious. :-)

php - Preventing CSRF and XSRF Attacks for jQuery $.post -

i hit simple csrf attack , realized lot of ajax scripts open. these accessed on site $.post(). is there way automatically add php token of these or need go through , one-by-one? using bwoebi's answer, found better solution. jquery has built in setup function ajax. <script>var token ="<?= $_session['token'] ?>";</script> <script> jquery.ajaxsetup({ data: { token: token } }); </script> this add token every jquery request!

java - How to fetch the records of last 24 hours or 7 days from today's date using Joda-Time API -

i trying out hand in finding out records have been updated in oracle 11g db in last 24 hours or 7 days or 30 days. able desired functionality using "java.util.calendar" date today = new date(); calendar cal = new gregoriancalendar(); cal.settime(today); //for last 7 days cal.add(calendar.day_of_month, -7); however wondering if has done joda-time api? you need define exactly mean "last 24 hours" , "last 7 days". really mean last 24 hours, or "since same local time yesterday"? latter mean 23 hours or 25 hours, due daylight saving transitions. if really, want 24 hours , 7 * 24 hours, use instant : instant = new instant(); instant nowminus24hours = now.plus(durations.standardhours(-24)); instant nowminus7days = now.plus(durations.standarddays(-7)); note instant has no concept of time zone or calendar - it's just point on timeline; it's appropriate data type use timestamps , like.

data structures - Secure usage of Cell_handle in a CGAL Delaunay triangulation after point insertion -

i'm planning write algorithm use cgal delaunay triangulation data structure. need insert point triangulation, save reference cells, , make other insertion. i'm wondering how can store reference cells not invalidated after insertion of new points in triangulation? it's seems me cell_handle pointer internal structure, it's dangerous store due reallocation of internal container. in other hand can see no way in triangulation_3 interface store index cell_handle. typedef cgal::exact_predicates_inexact_constructions_kernel k; typedef cgal::triangulation_vertex_base_3<k> vb; typedef cgal::triangulation_hierarchy_vertex_base_3<vb> vbh; typedef cgal::triangulation_data_structure_3<vbh> tds; typedef cgal::delaunay_triangulation_3<k,tds> dt; typedef cgal::triangulation_hierarchy_3<dt> dh; typedef dh::vertex_iterator vertex_iterator; typedef dh::vertex_handle vertex_handle; typedef dh::point

android - SimpleCursorAdapter crashing -

android keep crashing hits line "simplecursoradapter notesadapter = new simplecursoradapter(this, r.layout.manage_notes_noteitem_layout,) i've tried changing sorts of things, creating separate class adapter, adapter class proves problematic. either it's "this"/context or custom layout. i'm unsure , have been looking around answers. thanks in advance. string[] columns = new string[] { notesadapter.key_notetitle, notesadapter.key_created, notesadapter.key_notetext, }; // xml defined views data bound int[] = new int[] { r.id.note_title, r.id.note_datedcreated, r.id.note_details, }; // create adapter using cursor pointing desired data //as layout information simplecursoradapter notesadapter = new simplecursoradapter( this, r.layout.manage_notes_noteitem_layout, c, columns, to, 0); update notesadapter class:

SQL Server 2008 R2 table query -

i have 2 tables. need execute query gets name of product has letter m in , sort these products in descending order number of ingredients have. product table has name , product number in it, while table madefrom has ingredient number , product number in it. something this: select name, count(madefrom.id) product inner join madefrom on madefrom.productid = product.id name '%m%' group name order count(madefrom.id) desc

Most efficient way to handle HTTP POST REQUEST in Java -

i have respond.php returns json data each http post different header data. efficient way generate roundly 30 requests @ once , handle responded data? needs efficient since hardware rather limited in performance. it not clear mean "generate roundly 30 requests @ once , handle responded data" . but efficient use of >>your<< time (and our time) implement in straight-forward fashion, , see if performance enough. pointless spend many hours coding ultra-efficient solution when simple solution going enough. the simple solution create 30 client threads , have each 1 send single post request using httpurlconnection. whether "efficient" depends on resources bottleneck. (and of course, same applies ideas on how make more "efficient".) saying hardware "rather limited in performance" doesn't give of clue ... once have simple solution, , you've identified actual bottleneck areas (client-side cpu? thread stacks?

namespaces - Any notes or rules for naming ruby gems with '-' or '_'? -

this question has answer here: should 1 use dashes or underscores when naming gem more 1 word? 2 answers when create ruby gem , name it, paying attentions name '-' or '_' ? there differences use between '-' , '_'? $ gem list|egrep "\-|_" actionmailer-with-request (0.4.0, 0.3.0) activerecord-deprecated_finders (1.0.2, 0.0.3) activerecord-import (0.3.1) : : i feel there rules not sure @ moment. take learn rules or guidances if exist. , want take @ code of gems (near-)perfectly compliant roles if know gems named '-' or '_', please give answers well. there examples of gems don't follow convention. convention have come best using - denote namespace ( :: ) boundary , _ word separator within class name. examples: | main class | gem name | require | |-----------------

ruby - Trying to add validation to rails devise sign-up page -

kinda noob rails programmer, save me ton of headache. currently, i'm trying add validation devise sign on page, such allowing sign complete if email ends extension. know file location stands overlooks sign on page? i've looked on models , views can't seem find it. thank you! i think can use validates_format_of in user.rb model. can use rubular.com create regex. validates_format_of :email, :with => /myregexhere/

hibernate - java.lang.IllegalStateException: Could not locate SessionFactory in JNDI -

good evening, above exception when using hibernate jsf, saw many times in past , root cause <session-factory name="sessionfactory"> removed name , change generated code creating sessionfactory that: protected sessionfactory getsessionfactory() { try { return (sessionfactory) new initialcontext() .lookup("sessionfactory"); } catch (exception e) { log.error("could not locate sessionfactory in jndi", e); throw new illegalstateexception( "could not locate sessionfactory in jndi"); } } to that: protected sessionfactory getsessionfactory() { try { return new configuration().configure("hibernate.cfg.xml").buildsessionfactory(); } catch (exception e) { log.error("could not locate sessionfactory in jndi", e); throw new illegalstateexception( "could not locate sessionfactory in jndi"); } }

Static Initialization in Go? -

i'm working on go lang tutorial, ran problem 1 of exercises: https://tour.golang.org/methods/23 the exercise has me implement rot13 cipher. decided implement cipher using map byte rotated value i'm not sure of best way initialize map. don't want initialize map using literal, prefer programmatically looping through alphabet , setting (key, value) pairs within loop. map accessible rot13reader struct/object , have instances(?) share same map (rather 1 copy per rot13reader). here's current working go program: package main import ( "io" "os" "strings" ) type rot13reader struct { r io.reader } var rot13map = map[byte]byte{} func (rotr *rot13reader) read(p []byte) (int, error) { n, err := rotr.r.read(p) := 0; < n; i++ { if sub := rot13map[p[i]]; sub != byte(0) { p[i] = sub } } return n, err } func main() { func() { var uppers = []byte("abcdefghijklmnop

php - Is is possible to store a reference to an object method? -

assume class code: class foo { function method() { echo 'works'; } } is there way store reference method method of foo instance? i'm experimenting , fiddling around, goal checking whether php allows call $fooinstance->method() without writing $fooinstance-> every time. know write function wrapper this, i'm more interested in getting reference instance method. for example, pseudo-code theoretically store $foo->method in $method variable: $foo = new foo(); $method = $foo->method; //undefined property: foo::$method $method(); apparently, method method , i'm not calling () interpreter thinks i'm looking property doesn't work. i've read through returning references examples show how return references variables, not methods. therefore, i've adapted code store anonymous function in variable , return it: class foo { function &method() { $fn = function() { echo 'works&