Posts

Showing posts from September, 2010

python - Suspend the formatting of the logger, then go back to it -

i have logging configuration log file , console: logging.basicconfig(filename=logfile, filemode='w', level=numlevel, format='%(asctime)s - %(levelname)s - %(name)s:%(funcname)s - %(message)s') # add console messages console = logging.streamhandler() console.setlevel(logging.info) consoleformatter = logging.formatter('%(asctime)s - %(levelname)s - %(message)s') console.setformatter(consoleformatter) logging.getlogger('').addhandler(console) at point in script, need interact user printing summary , asking confirmation. summary produced prints in loop. suspend current format of console logs, can printout 1 big block of text question @ end , wait user input. still want of logged file! the function in module, tried following : logger = logging.getlogger(__name__) def summaryfunc: logger.info('normal logging business') clearformatter = logging.formatter('%(m

jquery - Validating Checkboxes in javascript -

hi new javascript , don't know how validate check-boxes have looked many examples still don't understand can please tell me how validate , drop down menu inst validating @ in advance appreciated. my java script , html function validateform(){ var fname, lname, sex, address, email, length, songs, a, i, check, error; a=0; check=false; error=false; fname=document.getelementbyid("firstname").value; lname=document.getelementbyid("lastname").value; sex=document.getelementsbyname("sex"); address=document.getelementbyid("address").value; email=document.getelementbyid("email").value; length=document.getelementbyid("len").value; // songs=document.getelementbyname("f_song"); if(fname=="" || fname==null){ alert("please input first name"); error=true; return false; } if(lname=="" || lname==null){

c - What is the relationship between #include <stdio.h> and printf()? -

#include <stdio.h> main() printf(); what connection between preprocessor , function? when c preprocessor reads line #include <stdio.h> , literally reads file stdio.h system directory , replaces line contents. stdio.h contains declarations of printf , other functions, tells c compiler these functions exist in file or library . when use printf() in code, compiler knows function , knows doesn't have worry it. (if didn't include stdio.h , however, compiler wouldn't have known function looked @ all, have been troublesome , compiler complain this.) an example stdio.h file printf this: /* stdio.h */ // declaration of printf int printf(const char *format, ...); // , bunch of other function declarations...

ruby on rails - How to flatten the json produced by Rabl -

i'm starting out rabl , trying include parent attribute @ same level child. this have far.. class usertag < activerecord::base belongs_to :tag attr_accessible :user_id, :tag_id end my index.json.rabl object @usertag attributes :id child :tag attributes :name end produces [{"usertag":{"id":1,"tag":{"name":"dolor et non."}}}, how flatten child node in template produces [{"usertag":{"id":1,"name":"dolor et non." thanks!

php - WooCommerce Featured Product Code Modification -

there 2 parts question: where featured products code in woocommerce plugin? have seen previous posts suggest \wp-content\plugins\woocommerce\classes\widgets\class-wc-widget-featured-products.php, doesn't exist in current version 2.1. can here? by default, featured products on homepage aligned left. want edit code align center. may obvious when can see code, idea how this? thanks help! if you're looking woocommerce widget classes, it's in \wp-content\plugins\woocommerce\includes\widgets it seems featured products widget has been removed. can use woocommerce products replacement configuring show featured products. and file widget class-wc-widget-products.php . you copy widget class , make featured products widget , modify center aligned or create entirely different template display widget wc_get_template( 'content-widget-featured-product.php', array( 'show_rating' => $show_rating ) ); files located in \wp-content\plugins\woocomm

Pass file name to perl from R -

i want pass file name perl r. example, system command r execute perl works well system("perl file.pl name.txt") name.txt existing in r working directory. now, a<-"name.txt" how pass perl? if understand correctly think may work: a <- "name.txt" system(sprintf("perl file.pl %s", a))

RegEx vs. Manually Parsing String (PHP Performance) -

is there problem (performance-wise) manually parsing string follows, opposed using regular expressions or built in string replacement functions? for ($i=0;$i<strlen($string);$i++) { $thischar = $string[$i]; //do more stuff } thanks! there things done more efficient custom code regex. as long both have same o complexity , not handling humongous strings, readability , maintainability should equally or more important argument. for actual performance benchmark compare 2 solutions.

android - How can I implement Long Click Listener for listview -

this question has answer here: how implement long click listener on listview 6 answers i searched on various forums right answer nothing works me. moment have code in private class mydiary: listview list = new listview(monday.this); list.setonitemlongclicklistener(new adapterview.onitemlongclicklistener() { public boolean onitemlongclick(adapterview<?> parent, view view, int position, long id) { new editlistitemdialog(view.getcontext()).show(); return true; } }); it doesn't return errors editlistitemdialog not open. missing here? edit code editlistitemdialog: package com.example.classorganizer; import android.app.dialog; import android.content.context; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.editt

symfony - sonata media bundle error -

this error occurs when add new image gallery. the filter "number_format_decimal" not exist in sonatamediabundle:mediaadmin:edit.html.twig @ line 54 my config //app/conf/config.yml sonata_media: # if don't use default namespace configuration #class: # media: myvendor\mediabundle\entity\media # gallery: myvendor\mediabundle\entity\gallery # gallery_has_media: myvendor\mediabundle\entity\galleryhasmedia default_context: default db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr contexts: default: # default context mandatory providers: - sonata.media.provider.dailymotion - sonata.media.provider.youtube - sonata.media.provider.image - sonata.media.provider.file formats: small: { width: 100 , quality: 70} big: { width: 500 , quality: 70} cdn: server: path: /uploads/media # http://media.sonata-project.org/ filesystem: local:

asp.net - How to set starting point for a webpage in C# -

my question how set starting point webpage when loaded. have information in content placeholder, when form containing content placeholder loaded instead of displaying information in content placeholder goes top , have scroll down every time. there way can make content place holder starting display point webpage?? in advance. add html anchor in view want scrolled down to. on page load use java script move anchor. see how scroll html page given anchor using jquery or javascript? here example assuming using razor section render <a href="#contentanchor"> @rendersection("content") </a> <script type="text/javascript"> $(function() { location.hash = "#contentanchor"; }); </script>

facebook - Pulling a <h1> from other sites -

i artist new zealand. media(news) header "puller", i'm not sure how work. understand place answering questions directly related code, here go. there way pull <h1> headers news sites? through sort of google api system... i'm not sure i'm talking about. thats why need you- master of code. but ideally cool, show sort of timeline of news headers in visual way. example, news headers different sources arranged on page search term. http://www.zealmilitia.com/list.html 1 keyword ukraine(all done atm) hopefully sees potential in , wants come on board (obviously sharing in treasures). cool way share news stories on facebook etc. i'm not coding master understand some. my question is, possible? thanks jo you cannot pull element other site due cross origin policy : https://developer.mozilla.org/en-us/docs/web/security/same-origin_policy in more simple words , cannot pull not yours , may consider using iframes , monitor or view not yours.

how to upload image using ajax in php -

<div class="control-group"> <label class="control-label" for="inputemail">image</label> <div class="controls"> <input type="file" value="browse" name="image" id="image" /> <span style="color: #61625f; font-weight: bolder;" class="sixth"></span> </div> </div> ajax code below $("#reg").click(function() { $.ajax({ url: "process_service_person_register.php", type: "post", data: "image": $("#image").val()}, }); how send image "process file" you have use formdata object. <script> if ("formdata" in window) { var fd = new formdata(); fd.append('file', $('#image')[0].files[0]); $.ajax({ url: "process

python - Numpy Namespace Issue -

i have following function: def add_bch(compressed): k = 16 #input blocks of 16 bits. prim_poly = poly([1, 0, 1, 0, 0, 1]) # x^5+x^2+1 prim_poly_3 = poly([1, 0, 1, 1, 1, 1]) #prim_poly^3 -> x^5+x^4+x^3+x^2+1 prim_poly_5 = poly([1, 1, 1, 0, 1, 1]) #prim_poly^5 -> x^5+x^4+x^2+x+1 gen_poly = npp.polymul(npp.polymul(prim_poly, prim_poly_3), prim_poly_5)[0] compressed = add_padding(compressed, k) compressed_with_ecc = [] in range(len(compressed)/k): block = compressed[(k*i):(k*(i+1))] block_poly = bitstr_to_poly(block) quotient, remainder = npp.polydiv(block_poly, gen_poly) compressed_with_ecc.append(poly_to_bitstr(block. remainder)) return bits().join(compressed_with_ecc) where relevant import statements are: from bitstring import bitarray, bits import numpy.polynomial.polynomial npp numpy.polynomial import polynomial poly when run code, error: bash-4.2$ python send_mess < pg2600.txt traceback (m

csv - reading a table/data frame into R that has both x and y axis labels -

i'm new r, , don't know if possible. i've been using read.csv() read table r comma separated. i keep getting error message telling me: "more column column names" i believe issue involves fact files have both x , y axis labels. so this: ,y1,y2,y3, x1,data,data,data, x2,data,data,data, x3,data,data,data, the y , x different labels depending on actual file, demonstration. is there way read r? or have remove x axis labels files... thanks you getting error because r sees 4 columns, , 3 column names. the argument row.names = 1 tell r first column of file vector of row names, , apply them accordingly. > read.csv(text = ",y1,y2,y3, x1,data,data,data, x2,data,data,data, x3,data,data,data,", row.names = 1)[-4] ## results in ## y1 y2 y3 ## x1 data data data ## x2 data data data ## x3 data data data the [-4] removes na column gets added using process (due comma in column names, think). diff

Building Android hybrid mobile application from iOS hybrid mobile application -

we have ios mobile application built using native tabbar design, 1 tab consist web view display cordova view. other 2 tabs purely native. now planning build same application android mobiles. please guide how , start migration. do require update cordova code supporting android or same code work? how support various number of android screen sizes? adding comment answer future readers. no need update cordova code have create native code andorid other tab for web view have use bootstrap of responsive design framworks support mutilple screes sizes

How to read the Section from Config file from c# code -

while reading config section through c# , getting error in line 1. the application relative virtual path '~' not allowed here. system.configuration.configuration config = system.web.configuration.webconfigurationmanager.openwebconfiguration("~"); systemwebsectiongroup grp = (systemwebsectiongroup)config.getsectiongroup("system.web"); my guess value of "~" not allowed when calling openwebconfiguration, that's guess reading error message. documentation openwebconfiguration ( http://msdn.microsoft.com/en-us/library/ms151456(v=vs.110).aspx ) says pass null if want root web.config.

html - Straight line with bottom arrow - possible in CSS only? -

Image
is possible achieve (straight line "cut" kind of arrow / triangle 30 pixels left) in css? (did using adobe fireworks want rid of images as possible on website). here have tried without success: http://jsfiddle.net/u8af6/ many thanks css body { background: red; } .arrow_box { position: relative; background: #88b7d5; border: 1px solid #c2e1f5; } .arrow_box:after, .arrow_box:before { top: 100%; left: 10%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(136, 183, 213, 0); border-top-color: red; border-width: 16px; margin-left: -16px; } .arrow_box:before { border-color: rgba(194, 225, 245, 0); border-top-color: #c2e1f5; border-width: 22px; margin-left: -22px; } you can use pseudo elements that. please see nicolas gallagher's experiment more: http://nicolasgallagher.com/pur

php - Is there a way to use the WPDB class into a non-wordpress project? -

because wordpress wpdb class easy use, want try using non-wordpress project. tried copy wp-db.php working directory , tried following script on separate file <?php require_once("wp-db.php"); $mydb = new wpdb('myuser','mypassword','mydatabase','myhost'); $rows = $mydb->get_results("select column1 table1"); foreach ($rows $obj) echo $obj->column1."<br/>"; endforeach; ?> but couldn't make display data. is there way use wpdb class on non-wordpress project? test code(test.php): <?php require_once("wp-db.php"); $mydb = new wpdb('root','','mysql','localhost'); $row = $mydb->get_results("select * user limit 1"); var_dump($row); ?> modified wp-db class(wp-db.php): http://codepad.viper-7.com/coonyj

c# - Select nonNullable values of nullable property from collection of objects with PLINQ -

why when use plinq in query such as var notnullparametervalues = (from operation in operations.asparallel() operation.nullableparameter.hasvalue select operation.nullableparameter.value) .distinct().tolist(); resharper warn me 'possible system.invalidoperationexception'? for simplicity operations ilist<operation>; public class operation { public int? nullableparameter {get; set;} } update: thank answers. maybe because resharper not perfect? i sure suggesting check if operation null. take jetbrains issue tracker

apache - RewriteRule / RewriteCond help when two "keywords" show in the one query string -

currently have in .htaccess file: <ifmodule mod_rewrite.c> options -multiviews rewriteengine on rewritebase /forum/ rewritecond %{request_filename} !-f rewriterule \.(jpeg|jpg|gif|png)$ /forum/public/404.php [nc,l] rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=register(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/register.php? [nc,l,r=302] rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=login(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/login.php? [nc,l,r=302] rewritecond %{query_string} (?:^|&)app=core(?:&|$) [nc] rewritecond %{query_string} (?:^|&)section=lostpass(?:&|$) [nc] rewriterule ^index\.php$ http://www.mysite.com/retrieve_password.php? [nc,l,r=302] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /forum/index.php [l] </ifmodule> the 1 ne

Does Sublime Xaml works for Windows Phone? -

i installed https://github.com/maslbl4/sublime-xaml but when open windows phone xaml file nothing highlighted. as can see on page, sublime xaml has lot of missing files called library windows phone. going deeper in contents of files can read xml header <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> investigating little bring understand repository ios only, can't if works since i'm not ios developer. but answer question: no library doesn't work in windows phone project neither in windows 8 project or .net

sql - Averaging the result of a subquery in mySQL -

i'm building query searches through medicare database listing how doctors charge various procedures. ideally, query would: return every record, meaning every procedure every doctor. (i'll add filtering where clauses later) return average amount doctors charge each procedure return percentage difference between average cost , each individual doctor charges return average of percentage differences each doctor, generating meta cost-differential score. with query below, i've been able achieve last goal. select medicare.*, peeraverage.average charge_average, ( medicare.average_submitted_chrg_amt - peeraverage.average ) / peeraverage.average * 100 difference_from_average, avg( ( medicare.average_submitted_chrg_amt - peeraverage.average ) / peeraverage.average * 100 ) total_difference_from_average medicare join (select avg(average_submitted_chrg_amt) average, procedure_code medi

c - Get address of system function manually? -

how obtain address gdb gives when "print system"? supposedly, if start program , pause it, in /proc/$pid/maps , base address of library. need find offset of system() in libc.so.6 , add these 2 together. however, when try in practice, end address different 1 gdb gives. what's best way obtain system() address? please note i'm trying obtain address of program, not 1 compiled myself. what's best way obtain system() address? #include <stdio.h> // printf() #include <stdlib.h> // system() ... ... { int rcode=0; int (*system_ptr)(const char *command) = system; ... rcode=(*system_ptr)("echo \"hello\""); ... printf("address of system(): %p\n", system_ptr); ... } ...

jpanel - How to add a button to freeze and resume the bouncing ball JAVA -

i want add 2 buttons following code let me "freeze" , "start" ball move bounces on window. i've been trying last hour cant figure out. did work crap, if wants please let me know post it(avoided in order not extend coding). can me this? open suggestions. thanks import java.awt.*; import javax.swing.*; public class ballmoves extends jpanel implements runnable { color color = color.red; int dia = 30; long delay = 40; private int x = 1; private int y = 1; private int dx = 3; private int dy = 7; protected void paintcomponent(graphics g){ super.paintcomponent(g); graphics2d g2 = (graphics2d)g; g2.setrenderinghint(renderinghints.key_antialiasing, renderinghints.value_antialias_on); g.setcolor(color); g.filloval(x,y,30,30); // adds color circle g.setcolor(color.red); g2.drawoval(x,y,30,30); // draws circle } public void run() { while(is

html - CSS Pseudo Classes apply with external CSS, Regular class won't -

i'm attempting stylized buttons together, , keep classes i'm using in external css sheet. problem when attempt reference class in html code, pseudo classes apply , standard class not. my html code is <body> <button class="buttonmodifier"></button> <div class="buttonmodifier"></div> </body> and within external .css sheet have: <style> .buttonmodifier{ background-color:rgba(102,102,102,.6); height:50px; width:50px; border-radius:3px; background-image:url(images/playerbutton.png); } .buttonmodifier:hover{ background-color:rgba(102,102,102,1); background-image:url(images/playerbutton.png); } .buttonmodifier:active{ position:relative; top:1px; background-color:rgba(102,102,102,.6); } </style> when go html page, class .buttonmodifier isn't applying html elements specified class, yet ":hover" , ":active" prop

tsql - From a table of made up of rows of dates, how to count the number of rows where the date is in a certain date range -

i have table dbo.mydates : date -------- '08/28/2012' '01/10/2013' '02/05/2013' and table dbo.people : id name daterangestart daterangeend --- ------ -------------- ------------ 100 mike '08/01/2012' '11/15/2012' 101 john '08/01/2012' '02/01/2013' 102 claire '12/01/2012 '03/15/2013' 103 mary '03/01/2013' '05/01/2013' what i'm trying check if each of dates in rows 1 -3 within specific date range total number of dates within range: id name totaldayswithinrange --- ------ -------------------- 100 mike 1 101 john 2 102 claire 2 103 mary 0 so can use totaldayswithinrange in simple math calculation. know how use while loops other languages java , php, based on research seems in t-sql it's better use recursive cte. i've used ctes in past know how work i've never

date - sub query causing issue with INTERVAL 90 DAY -

$query = mysqli_query($connect,"select * `posts` `name` '%$search%' or (number in ( select number `posts` `name` '%$search%' , `number` !='') ) order date asc limit 100"); where should plug in line? haven't been able work above query. thx. && date>=date_sub(curdate(), interval 90 day) (all rows returned must interval 90 day...including subquery part) $query = mysqli_query($connect,"select * `posts` `name` 'adam' && date>=date_sub(curdate(), interval 90 day) or (number in ( select number `posts` `name` 'adam' , `number` !='') ) this not return results if adam row older 90 days. however, when adam row less 90 days, results subquery rows can expired. so tried still bypassing date check subquery: $query = mysqli_query($connect,"select * `posts` `name` 'adam' && date>=date_sub(curdate(), interval 90 day) or (

asp.net web api - Difference between the two Web API headers response.Content.Headers and response.Headers -

i find webapi separate http response headers different places, 1 in response.headers, other in in response.content.headers. example, etag in response.headers while lastmodified in other. reason behind that? there couple of answers question. 1 because that's way http spec defines headers. rfc 2616 content header fields here http://tools.ietf.org/html/rfc2616#section-7.1 request header fields here http://tools.ietf.org/html/rfc2616#section-5.3 response header fields here http://tools.ietf.org/html/rfc2616#section-6.2 the other more practical reason separating out content headers is easier write code processes data http payloads , sets related headers, independent of request/response objects. unfortunately, more recent httpbis specification did reorganization of think headers should go , lastmodified , allow considered response fields, not content fields. means headers defined in system.net.httpheaders no longer match spec, sucks. means stuck lastmodified

How can I add user First Name and Last Name to an ASP.NET Identity 2? -

i changed on use new asp.net identity 2. i'm using microsoft asp.net identity samples 2.0.0-beta2. can tell me , how can modify code stores user first , last name along user details. part of claim , if how add ? i assume need add here register method in account controller: if (modelstate.isvalid) { var user = new applicationuser { username = model.email, email = model.email }; var result = await usermanager.createasync(user, model.password); if (result.succeeded) { var code = await usermanager.generateemailconfirmationtokenasync(user.id); var callbackurl = url.action("confirmemail", "account", new { userid = user.id, code = code }, protocol: request.url.scheme); await usermanager.sendemailasync(user.id, "confirm account", "please confirm account clicking link: <a href=\"" + callbackurl + "\">link<

Need help displaying a JSON file in HTML -

i received vps digitalocean , have been trying make page display status of vps. digitalocean has api dont know started. my json file goes this: {"status":"ok","droplets":[{"id":00000,"name":"jamieduke","image_id":0000,"size_id":00,"region_id":4,"backups_active":false,"ip_address":"0.0.0.0","private_ip_address":null,"locked":false,"status":"active","created_at":"2014-04-21t23:45:51z"}]} update: havent tried code. have been looking high , low works. also, json code showed there pulled webpage , has to live update 2: total newb when comes css , javascript. language can html. can please me other parts needed? need script project. also, need pull script pulled url. it's simple var data = json.parse(jsonstring); var html = [], =0; ln = data.droplets.length; html.push('<div class=&

java - Which mysql timeout do I must modify? -

i've set on raspberry pi glassfish server (4) , mysql, launch webservices android application. okay after lot of problems ! 1 question stay in mind me, why every day i'm trying execute query app, must restart glassfish have result (i have 500 internal server error). i've searched on net, , think it's timeout mysql, close connection between him , glassfish, want know must doing solve problem ? thanks advance ! edit stack trace : example.webservices.exceptions.serviceexception: l'appel au webservice rencontré une erreur 500 : not execute query @ example.webservices.accessservice.useraccessservice.isuserexists(useraccessservice.java:52) @ example.androidapp.asynctasks.verifyusertask.doinbackground(verifyusertask.java:38) @ example.androidapp.asynctasks.verifyusertask.doinbackground(verifyusertask.java:20) @ android.os.asynctask$2.call(asynctask.java:288) @ java.util.concurrent.futuretask.run(futuretask.java:237) @ android.os.asynctask$serialex

javascript - Un-Defined index with $http. -

not sure reason got undefined index below code. checked can't find what's wrong. $http({ url: "php/mainload.php", method: "get", data: {"userid":"1"} }).success(function(data, status, headers, config) { console.log(data); }).error(function(data, status, headers, config) { // $scope.status = status; alert(status); }); php echo $_get['userid']; parametere data on ajax expecting method post , if need $_get , use params instead : $http({ url: "php/mainload.php", method: "get", params: {"userid":"1"} // change `params` `data`. }).success(function(data, status, headers, config) { console.log(data); }).error(function(data, status, headers, config) { // $scope.status = status; alert(status); });

ios - AVAssetWriter Writes Video but does not record AUDIO -

i have been successfull in making viedo (though blur) but have been unsuccessful in recording audio please help. i using following code pls go through ans suggest solution or working tutorial. i appending sample buffer using [encoder._writerinput appendsamplebuffer:samplebuffer]; , app crashes when following statement called [encoder.audiowriterinput appendsamplebuffer:samplebuffer]; - (void) initpath:(nsstring*)path height:(int) height andwidth:(int) width bitrate:(int)bitrate { self.path = path; _bitrate = bitrate; [[nsfilemanager defaultmanager] removeitematpath:self.path error:nil]; nsurl* url = [nsurl fileurlwithpath:self.path]; //initialize video writer _writer = [avassetwriter assetwriterwithurl:url filetype:avfiletypempeg4 error:nil]; //initialize audio writer // audiowriter = [avassetwriter assetwriterwithurl:url filetype:avfiletypecoreaudioformat error:nil]; // nsdictionary* settings = @{ // avvideocodeckey: a

android - How to slice sprites into multiple sprites in AndEngine -

i'am newbie andengine. have situation wherein have slice/cut particular sprite multiple sprites, how can achieve that? you won't able using andengine functionalities. have implement such thing yourself. let's talk , on slicing fruit (like in fruit ninja;) ) should have 3 sprites watermelon. 2 halves , whole fruit. after slicing should hide whole watermelon , show 2 halves @ place setting it's x, y , rotation. (you have read , calculate slice position , direction somehow. more realistic) why 2 halves instead of 1 if same? shouldn't same if want 3d effect. 1 of sprite show of watermelon inside (you know, red thing eat;) ) the other possibility similiar instead of attaching , detaching sprites can have 2 sprites attached togheter in way whole watermelon. ps if remember fruit ninja has 3d fruit models objects won't cool in 2d (they won't rotate in z-axis). used fruit ninja example want similiar effect. don't know other possibility in an

android - How to delete all arcs drawn on a Bitmap -

i have declared bitmap this. mbitmap = bitmap.createbitmap(width, height, bitmap.config.argb_8888); mcanvas = new canvas(mbitmap); now after drawing arcs on it, how clear bitmap in same state when app started you can use mcanvas.drawcolor(color.transparent, mode.clear); here documentation.

php - .htaccess URL rewrite subfolder $_GET -

i trying create htaccess file website. got subfolders called admin. in subfolder index.php , content pages. want rewrite url's domain.com/admin/page1 example. everything working main index files can't $_get['page'] working in admin folder. url: http://techniekquiz.schl.nl/ http://techniekquiz.schl.nl/admin/ htaccess code: rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ ?page=$1 rewriterule ^admin/(.*)$ admin/index.php [nc,l] rewriterule ^(.*)admin/(.*)$ ?page=$1 my index.php (admin/index.php) file (only $_get part of it) $page = (isset($_get['page']) ? $_get['page'] : ''); if (!empty($page) && file_exists(''.$page.'.php')) { require (''.$_get['page'].'.php'); } elseif ( ( (!file_exists(''.$page.'.php')) or (!file_exists(''.$page.

sql - mysql query - credit debit-> calculate balance (complex tables structure) -

Image
i have tables structure: the "plati" table = credit. the "suma" column = amount. sample debit data: sample credit data: and want result: plati.id debite.iddosar debite.suma plati.suma plata (debite.suma - previous plati.suma order plati.data) restplata like excel: is possible sql query not variable, because want split query's create 1 view on finally?

javascript - Safari does not trigger form Submit -

for project got 2 select-formfields sent via jquery trigger("submit"); works in firefox und chrome, in safari nothing happens. this html-code: <body> <form action="http://google.de" target="_blank" style="display: inline;" method="get"> <select class="bstarch2" data-role="none" name="q"> <option value="none">please choose</option> <option value="a: worked">a</option> <option value="b: worked">b</option> </select> </form> <select class="bstarch" data-role="none"> <option value="none">please choose</option> <option value="http://google.de">google</option> <option value="http://en.wikipedia.org">wikipedia</option> </select> <form action="" method="

qt5 - Signal/Slots with VIsual studio and Qt plugin -

i have issue slots , signals in visual studio 2012 qt plugin. when compile qt project, shows error: moc_mainwindow.obj : error lnk2019: unresolved external symbol "public: void __thiscall mainwindow::onupdate(class qstring)" (?onupdate@mainwindow@@qaexvqstring@@@z) referenced in function "private: static void __cdecl mainwindow::qt_static_metacall(class qobject *,enum qmetaobject::call,int,void * *)" (?qt_static_metacall@mainwindow@@caxpavqobject@@w4call@qmetaobject@@hpapax@z) these classes: mainwindow.h #ifndef mainwindow_h #define mainwindow_h #include <qmainwindow> #include <qtextedit> #include <qstring> namespace ui { class mainwindow; } class mainwindow : public qmainwindow { q_object public: explicit mainwindow(qwidget *parent = 0); ~mainwindow(); public slots: void onupdate(qstring info); private: ui::mainwindow *ui; qtextedit *textedit; }; #endif // mainwindow_h mainwindow.cpp

Print if origin in tuple is [0] (python) -

i format code print the word river , sand if value[0] called. datafile.txt river, 4 -5, 6 -6, 8 6, 9 sand, 10 6, 7 -6, 76 -75, 75 my code textfile =open("datafile.txt", "r") datastring = textfile.read() value=[] split in datastring.split('\n\n'): split = ','.join(split.split('\n')) split = ''.join(split.split(' ')) split = split.split(',') x in range(0, len(split)-1): if (x == 0): value.append(split[x]) value.append((0, split[x+1])) else: temptuple=(split[x], split[x+1]) value.append(temptuple) print(value[0]) datafile.close() the above code prints "river", (0,4),(-5,6),(-6,8),(6,9), "sand", (0,10), (6,7),(-6,76),(-75,75) . it print river , sand when value[0] called. how change code that? data comes text file. the expected output when value[0] called should print "river" , "sand"

mongodb - Connections pool in Go mgo package -

in article running-mongodb-queries-concurrently-with-go said mgo.dialwithinfo : create session maintains pool of socket connections mongodb, when looking in documentacion of function dialwithinfo not find talk me pool connection, find in dial function dial function said : method called once given cluster. further sessions same cluster established using new or copy methods on obtained session. make them share underlying cluster, , manage pool of connections appropriately. can me how works pool connections on mgo , if possible set pool? is true dialwithinfo create pool connection or dial function create pool? thanks in advance looking source code dial function calls , can see dial function calls dialwithtimeout function calls dialwithinfo function. answer question differences between functions, seems dial convenience wrapper dialwithtimeout , in turn convenience wrapper dialwithinfo , result in same connection pool. as how manage connection po

c# - EntityState clarification with SaveChanges -

i used technique shows in answer ( https://stackoverflow.com/a/6282472/2045385 ) create trackingdbcontext inherit many of contexts now, , entity needs createdate/lastmodified properties inherits trackingbase entity. has worked far. until today. ultimately fixed problem changing way add new entity collection, don't understand why original isn't working... , i'd understand figure going come bite me again , again until understand it. originally adding new status record orderitem creating new status object , adding collection of statusitems of order object, so. var newlypaidorders = shopdb.shoporders .where(o => o.status == "new" && o.payment >= o.cost) .tolist(); (int = 0; i< newlypaidorders.count; i++) { var paidorder = newlypaidorders.elementat(i); foreach ( var paiditem in paidorder.orderitems ) { shoporderi

.htaccess - htaccess search and replace plus sign with dash -

i have form 2 parameters city,keyword passed search.php ,after submitting redirects url website.com/search/lenovo+laptop+dealers/delhi but need url parsed without plus signs dash in url example: website.com/search/lenovo-laptop-dealers/delhi code in htaccess file rewriteengine on rewritebase / rewritecond %{the_request} \s/+search\.php\?keyword=([^&]+)&city=([^\s&]+) [nc] rewriterule ^ /search/%1/%2? [r=301,l,ne] rewriterule ^search/([\w-]+)/([\w-]+)/?$ /search.php?keyword=$1&city=$2 [l,qsa] you can have rules this: rewriteengine on rewritebase / rewriterule "^(search)/([^+]*)\++([^+]*\+.*)$" /$1/$2-$3 [l,nc] rewriterule "^(search)/([^+]*)\+([^+]*)$" /$1/$2-$3 [l,r=301,ne,nc] rewritecond %{the_request} \s/+search\.php\?keyword=([^&]+)&city=([^\s&]+) [nc] rewriterule ^ /search/%1/%2? [r=301,l,ne] rewriterule ^search/([\w-]+)/([\w-]+)/?$ /search.php?keyword=$1&city=$2 [l,qsa]

Inside celery Task Class run method get task_id -

i trying run following code: class mytask(task): def run(): print mytask.request.id but code giving none request_id. please explain me why not able read id in side celery task class you trying access request object on class not object instance. try this: class mytask(task): def run(self, *args, **kwargs): print self.request.id you can use @task decorator: app = celery('tasks', broker='amqp://guest@localhost//') @app.task(bind=true) def mytask(self): print self.request.id

RegEx Find/Replace in Dreamweaver - Paste HTML as variable? -

i have convert spreadsheet data (name, image name, & bio) html, use regex find/replace variables in dw easy enough. issue 1 column contains bio html (paragraphs , italics mainly) , regex ignores "row" reasons beyond researching capabilities. i don't want strip manually add html again, show me way! tl;dr: there way paste html regex variable? here's example table data paste/format excel dw: <tr> <td>james brian hellwig</td> <td>james_brian_hellwig</td> <td><p>lorem ipsum dolor sit amet, <em>consectetur adipisicing</em> elit. sunt, ut iste tempore laborum aperiam nostrum obcaecati neque natus adipisci fugit. </p> <p>dolores, eligendi animi ea totam nobis cumque ullam eveniet accusamus!</p></td> </tr> <tr> <td>jiminy cricket</td> <td>jiminy_cricket</td> <td><p>lorem ipsum dolor sit amet, <em>consectetur adipis

c# - Override a method in the third party -

i have third party party class log . contains methods public void write(string s, params object[] args) { monitor.enter(this); try { string logentry = string.format(s, args); this.write(logentry); } { monitor.exit(this); } } and public void write(string logentry) { this.write(0, logentry); } i defined property outlog in own class public static log outlog {get;set;} i want use feature "callermembernameattribute" etc. in .net 4.5 , override write method like: public void write(string s, [callermembername] string membername = "", [callerfilepath] string sourcefilepath = "", [callerlinenumber] int sourcelinenumber = 0) { monitor.enter(this); try { string logentry = string.format(s, membername, sourcefilepath, sourceline

python - Using protocol buffer in Windows -

Image
i trying use google protocol buffer in windows python binding, meet problem during install step. follow instruction, have compile pb myself using vs, have no vs installed on machine, found window binary @ download page. also download full source code package , put protoc-2.5.0-win32.zip\protoc.exe c:\windows\system32 . then go protobuf-2.5.0.zip\python , run python setup.py install install python binding. however error this: and when check directory, file google\protobuf\compiler not exist. what's problem? is possible use without compiling? i suffering same problem. solution explicitly build step before. python setup.py build python setup.py install that worked me.

android.os.Process.killProcess(pid) did restart the processes again -

killprocess method kill processes why processes restart again , suppose not restarting process again. here goes code. activitymanager manager = (activitymanager) getsystemservice(context.activity_service); list<runningappprocessinfo> services = manager.getrunningappprocesses(); (runningappprocessinfo info : services) { int service1name = info.pid; android.os.process.killprocess(service1name); } thanks concern. actually process kill through killprocess restart process because android os assume process has been shutdown due crashing , restart again. find can use higher priority (activity manager) kill process. example can find here : try { log.d("application process", "killing++"); string killcommand = "am force-stop com.nil.android.ssd"; runasroot(new string[]{killcommand},true); } catch (exception e) { e.printstacktrace();

java - Eclipse shows source folders twice when importing Maven project -

on simple application, valid maven pom file compiles expected (e.g., when running mvn install) , works fine intellij idea, eclipse insists on displaying source code twice. assuming top level package of project com.example.app , source code placed in path ending in pro/java/ , structure of project like pro/java/main/com/example/app... pro/java/test/com/example/app... after importing maven project in eclipse , nested src forder created in workspace, below there nested versions of actual source folders, e.g. src/java/main/com/example/app src/java/main/com/com/example/app in addition that, there 2 "valid" source folders in workspace, i.e. src/main/java... src/test/java... excluding 2 folders source path leaves nothing compiled , keeping nested src folder causes sorts of weird problems in compilation within eclipse . any clues? thanks.

magento - Enable/disable cash-on-delivery only for some specific products -

i want disable cash on delivery payment method option specific products. want show cash on delivery method specific products , need hide other payment options. how can this? read this other question did not solve problem. you can use following free extension solve problem http://www.magentocommerce.com/magento-connect/shipping-and-payment-filters.html

java - annotation mapping using hibernate select data from database and display on jsp page but error is below -

severe: servlet.service() servlet [jsp] in context path [/konzern] threw exception [org.hibernate.hql.internal.ast.querysyntaxexception: attendance not mapped [from attendance a.status=:status]] root cause org.hibernate.hql.internal.ast.querysyntaxexception: attendance not mapped @ org.hibernate.hql.internal.ast.util.sessionfactoryhelper.requireclasspersister(sessionfactoryhelper.java:189) it simple problem, forgot map entity 'attendance' use @entity @table(name="table_name",catalog="dbname") on top of entity(pojo class) , add <mapping class="package.attendance"/> in hibernate configuration file. problem solved.

asp.net web api - Cross Domain Web API: Install-Package Microsoft.AspNet.WebApi.Cors Not Working -

as cross domain call web api project not working asp.net web forms client in ie (working in other browsers). guess need install following nugget pakage. install-package microsoft.aspnet.webapi.cors but when try install got following error. install failed. rolling back... install-package : not install package 'microsoft.aspnet.webapi.client 5.1.2'. trying install package project targets '.netframework,version=v4.0', package not contain sembly references compatible framework. more information, contact package author. @ line:1 char:16 + install-package <<<< microsoft.aspnet.webapi.cors -pre -project webapi + categoryinfo : notspecified: (:) [install-package], invalidoperationexception + fullyqualifiederrorid : nugetcmdletunhandledexception,nuget.powershell.commands.installpackagecommand i trying install in: visual studio 2010 targets .net 4.0. does package not supported in .net 4.0 ? best regards hardeep .net 4.5 min

java - What is the advantages of using Dozer in Spring Hibernate project? -

i want know benefit of using dozer in project. here confuse how use ? , why use ? please me. want map entity classes dto classes , want data flow on gui through dto classes. , when saved data gui db want convert dto class dao class. dozer mapping a java bean java bean field based value propagation , in memory objects. while hibernate mapping pojo (domain objects) relational database . so can see, not apparentely related 1 other, , need use both of them should upon personal choice. as question has been edited: a basic conceptual architecture should map entities (domain objects - you did call dao classes ) through hibernate database. then entities can mapped java beans (which did call dto classes) using dozer .

eclipselink - JPA: Pre-allocate ID block not work fine -

i'm trying manage id generation through annotation @tablegenerator allocationsize default. understand it, avoid updating row every single identifier gets requested, allocation size used. in theory, provider should pre-allocate block of identifiers equal value of allocationsize - 50 in case - , give out identifiers memory requested until block used or transaction comes end. i use eclipselink (el) jboss 7.1. the problem not happen. inserting 3 records in table students, el pre allocates each record block of 50 id, if transaction same. then, each record, there access table. logs see 3 pre allocations , 3 pairs of select/update query id , ids generated 1- 51 -101 , sequence has final value 150. piece of log connection acquired connection pool update sequence set seq_count = seq_count + ? seq_name = ? bind => [50, table_seq] select seq_count sequence seq_name = ? bind => [table_seq] local sequencing preallocation table_seq: objects: 50 , first: 1, last: 50 connection rel