Posts

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.