Posts

Showing posts from June, 2014

r - Fetch the original name of vector variable passed to a custom function -

my problem best understood after reading r script: plothistogram <- function(data, x, binw=0.30, color=false, density=false, h=10, w=10) { require(ggplot2) # data$x <- as.numeric(x) plot <- ggplot(data, aes(x)) if(density & color) { plot <- plot + geom_density(fill="blue", aes(alpha=0.2)) } else if (density) { plot <- plot + geom_density() } else if (color) { plot <- plot + geom_histogram(binwidth=binw, aes(y=..density.., fill=..count..)) + scale_fill_gradient("count", low="purple", high="red") } else { plot <- plot + geom_histogram(binwidth=binw, aes(y=..density.., fill=..count..)) } ggsave(file="histo_plot.svg", plot=plot, height=h, width=w) return(plot) } notice commented line. have use ggplot recognize x belongs data . hack. intent plot name of whatever series input x . i'm not sure how because far can tell,

Eclipse java debugging: source not found -

while debugging java app in eclipse receive " source not found " error in 2 cases: stepping in file in different project imported stepping in file in installed maven repository the files there, eclipse won't step them, instead shows button " attach source " i tried attaching (which opened dialog define variable?!) , eclipse did jump file, debugger not inspect variables there. manually attaching source each dependency isn't practical, in case there thousands of dependency files. i'm new eclipse\java explanation of why happening + how resolve lot! eclipse debugging works class actually loaded program. the symptoms describe sounds class in question not found in project, in distribution jar without debug info found before project working with. this can happen several reasons have @ location classes showing behaviour found (look in navigation pane identify it). need change build path of project avoid using jar , have jvm use pr

javascript - jQuery UI: Set class for draggable when valid -

i know can set class dropable object when valid dragable hovering, using hoverclass. posible that, draggable object (just when hovering on valid target)? ok, managed using events in dropable: el.dropable({ accept: ".target", over: function(e, ui){ ui.draggable.addclass("valid"); }, out: function(e, ui){ ui.draggable.removeclass("valid"); }, hoverclass: "valid" });

python - Using webp images with Pillow 2.2.2 or 2.3.0 -

i using pillow version 2.2.2 convert webp image jpeg image. webp images stored in memory buffer. found when try tom open webp image cause memory leak large number of images become real problem. def webp_to_jpeg(raw_img): image = image.open(stringio.stringio(raw_img)) buffer = stringio.stringio() image.save(buffer, "jpeg") return string_buffer.getvalue() this memory leak happen when work webp images. try update pillow 2.3.0 when did not able read webp images @ , got following exception "webp unknown extension" it's webp decoder bug in pillow (see here ). it's still leaking memory in version 2.4.0 the workaround i've found based on python-webm . 1 leaking memory too, can fix it: in encode.py, import libc free() function : from ctypes import cdll, c_void_p libc = cdll(find_library("c")) libc.free.argtypes = (c_void_p,) libc.free.restype = none then modify _decode() free buffer allocated in webp decoder .dll: def _

What is the order of evaluations of parameters inside the function? -

having foo(bar1(), bar2()) can sure in sml evaluate bar1() first , after bar2() ? yes. strictly speaking have function applied tuple. fields of tuple evaluated left right bar1() evaluated before bar2() . see "the definition of standard ml (revised)" milner, tofte, harper , macqueen page 41. note if foo expression have side-effects or raise exception evaluated before argument , therefore before either bar1() or bar2() . particularly has implications curried applications. foo (bar1()) (bar2()) will evaluate first bar1() foo(bar1value) before evaluating bar2() .

apache - Receving request from Woopingbot/1.1 -

so question next 1 because haven't been able find info woopingbot. recenlty have been receiving http request website, can see in apache log user agent woopingbog/1.1, bot 1 or bot trying find security issues in website?? thanks gabriel this bot woorank.com up-time bot. check see if website calculate uptime statistics. there bot called woobot check site seo.

javascript - Prioritize html elements in @media queries with PHP or JS -

think having divs in page <div id="1"> <div class="2">content</div> <div class="3">content</div> <div class="4">content</div> <div class="5">content</div> </div> is there way sort out divs in different media queries? for example if device "ipad portrait" code should be; <div id="1"> <div class="5">content</div> <div class="2">content</div> <div class="4">content</div> <div class="3">content</div> </div> you can use media queries in javascript, depending on match different dom manipulations. in example if window less 770px reverse order using jquery. var mediaquery = window.matchmedia( "(max-width: 770px)" ); if ( mediaquery.matches ) { var container = $('#1'); var items = container.children(&

sql - Altering my datatypes in SQLite -

i following sqlite tutorial goal create simple student database uml diagram. so lately i'm going through hell trying figure out how alter data types , hoped help. i'll post same question posted instructor. unfortunately, messed on datatypes when trying follow instructor. video, if helps, can found here: http://www.youtube.com/watch?v=07nbszniwu8 ++begin transcript++ thanks far, seems have mystery. first thing did copy uml, took break. upon return, figured i'd started uml while reloading video, first things did create student , sex_type table so: sqlite> create table student(name varchar(23), ...> sex character(1), ...> id_number integer primary key); sqlite> create table sex_type(sex_id text primary key, sex_type integer); but realized, "oops forgot indicated want sex_id not null well." "i'm forgot under ensure foreign key(sex) references sex_type(sex_id)." so thought, reviewed sql books, , recalled known alte

python 3.x - Import package "x" in module "x": prevent importing itself and import package instead -

i run problems when using project structure suggested here: what best project structure python application? . imagine project layout this: project/ |-- bin/ | |-- project.py | |-- project/ | |-- __init__.py | |-- foo.py in bin/project.py want import package project . #project.py project import foo since sys.path[0] project/bin when running bin/project.py , tries import module bin/project.py (itself) resulting in attribute error. there way use project layout without playing around sys.path in module bin/project.py ? need "importpackage" statement, ignores modules same name. since project structure suggested, i'm wondering why no 1 else has kind of problems... you try: import imp module_name = imp.load_source('project','../project') module_name package. edit: for python 3.3+ import importlib.machinery loader = importlib.machinery.sourcefileloader("project", "../project") foo = loader.load_modul

apache - Location and Directory cause 500 error -

i have .htacces file , trying open access file , folder within protected folder. the file index.php following: <files index.php> order allow,deny allow satisfy </files> this works , give me access file. file requires assets assets/ directory. try open directory doing following: <directory "/assets"> order allow,deny allow satisfy </directory> but giving me 500 error. not sure why. you can't use <directory> container inside htaccess file (which <directory> container itself). if want allow access assets, create htaccess file inassets just: order allow,deny allow

ruby on rails - ActionMailer and a self-signed SSL Cert -

i have application (an installation of discourse ) i'm trying deploy. however, email server pointed @ has self-signed ssl cert smtp. is there workaround this? or need find way send mail using "valid" ssl cert? few things care proper cert smtp. user agents. if cert problem won't timeouts, you'll validation errors. suspect what's happening you're trying connect on smtps port isn't listening or exposed firewall. try using smtp+starttls. negotiates tls on port 25 or 587 instead of trying connect directly 465.

clojure with mysql and java -

not sure why error when try code below execute query on mysql database clojure: user=> (mysql.core/list-users) classnotfoundexception mysql.core java.net.urlclassloader$1.run (urlclassloader.java:366) here project.clj file (defproject mysql "0.1.0-snapshot" :description "fixme: write description" :url "http://example.com/fixme" :license {:name "eclipse public license" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [ [org.clojure/clojure "1.5.1"] [org.clojure/java.jdbc "0.3.3"] [mysql/mysql-connector-java "5.1.25"] [postgresql/postgresql "8.4-702.jdbc4"] [org.xerial/sqlite-jdbc "3.7.2"] [java-jdbc/dsl "0.1.0"] ]) here core.clj file (ns mysql.core (:require [clojure.java.jdbc :as sql])) (def db {:classname "com.

c++ - Definition of interactive device -

according c++11 standard (§1.9.8): the input , output dynamics of interactive devices shall take place in such fashion prompting output delivered before program waits input. constitutes interactive device implementation-defined. how gcc, clang , other compilers define "interactive device"? i guess section written cint c++ interpreter in mind. http://root.cern.ch/drupal/content/cint but don't think current status of cint standard conformant.

file io - How to load data in MATLAB from current script folder? -

there script myscript.m, under d:\myprojects, location d:\myprojects\myscript.m i want load .dat file @ d:\myprojects\mydata\somedata.dat how use load() function without using absolute path like data = load('d:\myprojects\mydata\somedata.dat') % not want data = load('mydata\somedata.dat') use relative path. assumes executing program it's home directory d:\myprojects. if need call script different folders should pass path .dat argument script.

c++ - storing integer value in reverse order -

while printing hexadecimal value (the value stored in a ) printing in reverse order , int main() { int i; uint8_t b[4]; int = 0xaabbccdd; uint8_t *ptr; ptr = &b; memcpy(ptr,&a,4 * sizeof(uint8_t)); for(i = 0;i < 4;i++) { printf("%x ",*ptr++); } return(0); } output dd cc bb aa how store in same order gave input( aabbccdd ) this has endianness, it's how computers store numerical values in memory. to sum up, modern processors (x86, x86-64, arm) little-endian (arm bi-endian now, can configure in hardware). what means least significant bytes have lowest address (little end first). instead of trying go against this, i'd advise work around if need to. one thing do, if really have to, use network byte order, defined big-endian. functions htons(), htonl(), ntohs(), ntohl() helpful.

neo4j - NotFoundException merge relationship type for first time -

on fresh db of neo4j (2.0.1) first time run query 400 notfoundexception angry @ 5th relationship. technically these relation types new since it's first query hit db. doesn't break app curious if using bad technique here. have with clause? // match possible mutual friend pattern "match (user:user {userid:{userid}})-[:friend]-(mutualfriend:user)-[:friend]-(possiblefriend:user) " + "where not (user)-[:friend]-(possiblefriend) " + "and not (user)-[:friend_invitation]-(possiblefriend) " + "with user, possiblefriend, count(mutualfriend) mutuals " + // create suggestion user suggested friend "merge (user)-[suggestion1:friend_suggestion]->(possiblefriend) " + "on create set suggestion1.mutual=mutuals, suggestion1.ignore=false, suggestion1.facebook=false " + "on match set suggestion1.mutual=mutuals " + // create suggestion in opposite direction "merge (user)<-[suggestion2:friend_suggestion]-(poss

How to properly sort items in a Python dictionary? -

i have created dictionary in python deal handle change purchase. money = { '$100.00' : 0, '$50.00' : 0, '$20.00' : 0,'$10.00' : 0, '$5.00' : 0, '$1.00' : 0,'$0.25' : 0, '$0.10' : 0, '$0.05' : 0, '$0.01' : 0} however when want print this, can't seem able "least greatest" piece of currency. this have done in attempt sort it: keylist = list(money.keys()) keylist.sort() key in keylist: print(key, money[key]) however result given goes ...$1 -> $10 -> $100 -> $20...any suggestions $1 -> $5 -> $10...? the sorting happening lexicographically, i.e. alphabetically, 1 character @ time. change sort function remove dollar sign , convert float: keylist.sort(key=lambda x:float(x[1:])) or better yet, remove "$" key, leaving key float, , add "$" when printing

javascript - keep getting php white screen of death when i try to add a confirmation box -

i trying make confirmation box when user deletes entry done echo "<a href=\"delete.php?sqluid=".$row[sqluid]."\"><img title='delete row' alt=\"delete\" class='del' src='images/delete.png'/></a></form></div>\n"; statement. tried using "onlick" operator , javascript href redirect delete statement. tried 6 different sets of code found on site dont think implementing correctly. keep getting undefined constant error when check php log <?php //get database credentials require 'config.php'; // connect mysql database server. mysql_connect ($dbhost, $dbusername, $dbuserpass); //select database mysql_select_db($dbname) or die('cannot select database'); require 'header.php'; $query = "select * ring29 order `ring29`.`ospfarea`,`dot1q`,`subnethost` asc;"; $result = mysql_query($query) or die(mysql_error()); //count number of rows returned $count =

Calculating tax correctly using Mysql and php -

i trying re-calculate tax on sale after entered database. can calculate information correctly before storing in database, calculating database reporting purposes has proved troublesome due rounding errors. the application displays interface allows 1 add items , view subtotal, taxes , totals. example input: item 1: 9.95 item 2: 2.95 subtotal: 12.90 taxes (could different each item, same each item) 2.900%: 0.37 1.000%: 0.13 1.100%: 0.14 3.000%: 0.39 tax total : 1.03 total: 13.93 the way calculate taxes before storing database: foreach item $price { foreach tax $percent { $taxes[$percent]+=$price*($percent/100); } } foreach($taxes $percent => $tax_amount) { $taxes[$percent] = round_to_2_decimals($tax_amount); } after calculating information store information in database can retrieved later reporting purposes. example schema: phppos_sales_items - sale_id - item_id - price phppos_sales_items_taxes - sale_id - item_id - tax_percent sam

javascript - Conflict between jquery and bootstrap -

i have code including jquery files , bootstrap files in header.php. running issues if include jquery file before bootstrap.js file, messes other tabs on webpage , if click on other tabs not navigate me. i think there conflict between jquery , bootstrap. pasting header.php file below more reference. header.php <?php require_once "essentials.php"; //error_reporting(~0); //ini_set('display_errors', 1); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!--<style>{height:150px; width:1300px;}</style>--> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="cache-control" content="public"> <title><?php echo $page_title?></title> <script src="http://code.jquer

mysql - how to avoid duplicating in php -

i new in terms of php. creating simple program similar login page. may please me coding, have mysql table named user has 3 column userid, email , password. primary userid , auto increment. how can have code is, column email should no duplication or no same email. have code avoiding empty fields don't know how duplication.. here sample code: <?php if(isset($_post['submit'])){ $dbhost = 'localhost'; $dbuser = 'root'; $conn = mysql_connect($dbhost, $dbuser); mysql_select_db('dtr'); if(! $conn ){ die('could not connect: ' . mysql_error()); } if(! get_magic_quotes_gpc() ){ $email = addslashes ($_post['email']); $password = addslashes ($_post['password']); } else{ $email = $_post['email']; $password = $_post['passw

javascript - How to write a recursive function using levels depth? -

my function: public static function f($rows) { $str = '<ul>'; $level = 1; foreach($rows $row) { if($row['section_level'] > $level) { $level = $row['section_level']; // here want call function again recursion, how?? } else { $str .= '<li><a href="#">'.$row['username'].'</a></li>'; } } $str .= '</ul>'; return $str; } my array: array ( array( ['name'] => 'test1', ['level'] => 1 }, array( ['name'] => 'test2', ['level'] => 2 }, array( ['name'] => 'test3', ['level'] => 2 }, array( ['name&

sql - Query to get hierarchy from a table in Sybase -

i have table following structure: emp rel_emp relation b 1 c 1 b d 1 b 0 .... in above table if "rel_emp" child relation "1" if parent relation "0". need write query parent child hierarchy [there can multiple trees in table]. i know how achieve in oracle [by using "connect prior" clause] need in sybase. can please guide me. p.s: have worked in oracle , dont have idea sybase you can use self-join here. self join act of joining 1 table itself. self join useful convert hierarchical structure flat structure select e.name employee, m.name manager employee e, employee m e.mgr_id = m.id (+) for more info .

Python Regex sub on single character -

is there way perform sub on 1 character of matching pattern? for example, if have string "this word. word. h.e. stein" and want perform sub on '.'s @ end of sentence becomes "this word word h.e. stein" how should go doing this? you don't need use regular expression: >>> "qwerty.".replace('.', '', 1) # 1 -> replace count (only once) 'qwerty' to delete last character, use slice: >>> "qwerty."[:-1] 'qwerty' update according question edit. >>> text = "this word. word. h.e. stein" >>> re.sub(r'(\w{2})\.', r'\1', text) 'this word word h.e. stein' (\w{2})\. : match period after 2 word characters. capture word characters group 1. later referenced \1 .

unix - C - How to ENSURE different random number generation in C when program is executed within the same second? -

for assignment, supposed ensure that, when execute program within same second, should return different numbers. however, i've read other posts , can't quite figure out how within same second. if run code: int main() { srand(time(null)); for(count = 0; count < 10; count++) { printf("%d\n", rand()%20 + 1); } return 0; } i end same result when executed within same second. know how mix results within same second? i'm operating in unix environment if makes difference. thanks. to prevent 2 programs generating same pseudo-random numbers rand() , must, @ minimum use different seeds srand() . the source seeds 2 runs of program derived either 1) same source - mechanism unique generation. 2) random source , chance of same seed generation tolerable low. 1a #1, time() used, definition, programs start in same second, simplistic use of fails. 1b attempting create file both program access write "i started

regex - Speedup mysql queries with regexp and order by length -

i trying implement search auto-completion feature on website. came far table search terms (cities) city_id int(10) auto increment, primary city_name varchar(200) index and query select * city_names lower(city_name) lower('my_search_term%) order length(city_name) limit 10; this query returns 10 cities shortest names containing search string, need, it's slow. guess db first searches matches regexp, sorts results length, , picks 10 rows. think better somehow pre-sort data length(city_name), query stops after reaches 10 rows match regexp. so questions are: is there way sort (collate?) city_names column content length? i'm not planning alter table data, data need sorted 1 single time. what db engine , index structure suitable table (city_names data not unique)? is there way change query in order increase performance? any ideas welcome. update: based on zerkms's suggestions , did following: changed collation latin_general_ci . allowed me rid of lowe

sql - Select Permission was denied on the column for a user -

i have user added role xyz , role has been assigned permissions data read/write, execute etc on database. while executing select query on column of table displays error the select permission denied on column ... i see while taking properties of table that role has been granted select columns in table. can point me i'm missing? i have found out solution. specific user added role in "deny" permissions set against these tables. removing permission solved issue...

c# - Entity framework example with asp.net -

i start learn entity framework. want use entity framework asp.net , try find ef example asp.net there example windows apps. so, want simple insert,update,delete sources/examples of linq ef asp.net just go link. http://www.asp.net/mvc getting started (entity framework) an introduction entity framework absolute beginners entity framework tutorial getting started entity framework 5

php - Html to PDF to JPEG -

i way there. unsure how push temporary pdf object imagick generate , return jpeg image. using mpdf's standard output(), pdf rendered screen: $mpdf=new mpdf(); $mpdf->writehtml($output); $img = new imagick($mpdf->output()); $img->setresolution(300,300); $img->resampleimage(150,150,imagick::filter_undefined,1); $img->resizeimage(512,700,imagick::filter_lanczos,0); $img->setimageformat('jpeg'); $img->setimageunits(imagick::resolution_pixelsperinch); $img->writeimage ("test.jpeg"); under scenario pdf outputed screen instead of jpg image returned/created. proper way pass pdf imagick? i think need: $mpdf->output('temp/'.$filename.'.pdf','f'); $mpdf->output('temp/'.$filename.'.pdf','f'); $pdf_file = 'temp/'.$filename.'.pdf'; $savepath = 'temp/'.$filename.'.jpg'; $img = new imagick($pdf_file); $img->setimageformat('jpg'); $img->

javascript - FullCalendar timezones not modifying times on client's end -

i experiencing frustrating issue i've been working on night. long story short, if in new york creates event @ 2pm, i'd event show 8pm viewing calendar in europe (they 6 hours ahead let's say). my fullcalendar configs this: function renderschedule(timezone) { var userschedule = $('#user-schedule').fullcalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaweek,agendaday' }, timezone: timezone, ignoretimezone: false, events: baseurl + "load_schedule", editable: true, defaultview: 'agendaweek', firsthour: 8, alldaydefault: false } i have more options, should suffice purpose of question.as mentioned in docs, fullcalendar passes url via looks this: mysite.com / my_page / load_schedule ? start = 2014 -

java - JPA typed Query passing values in a Map in constructor -

in jpql typedquery can select values , directly pass values in other class's construtor. working fine. want selected record in key value paired map can pass whole map in variable argument construtor , assign values class property name map (by getting values property name). there way achieve this? here query: hqlquery.append("select new mypackage.myclass( new map('employeecode',he.employeecode) , new map('resignationid',he.employeeid))"); myclass{ private string employeecode; private integer employeeid; public myclass(map<string, object>... maps) //variable map { super(); (map<string, object> map : maps) { if (map.containskey("employeeid")) { this.employeeid= (integer) map.get("employeeid"); } if (map.containskey("employeecode")) { this.employeecode = (string) map.get("employeecode"); }

javascript - angular looses function argument from directive (?) -

i use directive (note: using jade template engine): file-upload.uploadcontainer(complete_function="set_value()") the directive itself: app.directive('fileupload', function() { return { restrict: 'e', scope: { complete_function: "&completefunction" }, //the rest of directive this directive uses uploadservice angular service. need call complete_function in controller when upload finished. uploadservice.onuploadcomplete(function(event) { alert("ok"); console.log("upload completed"); url = event.target.response; console.log(url); $scope.complete_function(url); }); in upload service can see url (which returning server) valid. proceed calling $scope.complete_function(url) looks this: $scope.set_value = function(url) { console.log("called"); console.log(url); i know function gets called because can see log &

uislider - How to change the value dynamically in jquery ui price range slider -

i using jquery ui price range slider . , have option selecting currency . problem if user select different currency range slider still same . want change slider range value in different currency upon changing currency . right show range in dollar , want when user select euro , range changed euro here doing <title>jquery ui slider - range slider</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.9.1.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <script> $(function() { $( "#slider-range" ).slider({ range: true, min: 0, max: 500, values: [ 75, 300 ], slide: function( event, ui ) { $( "#amount" ).val( "$" + ui.

http - Golang serve static files from memory -

i have quick question serving files in go. there great timesaving fileserver handler, use case, have 2 or 3 files (js , css) go app , dont want complicate deployment have think those. do think there easy way build couple of files binary , serve them there. example base64 encode data of files constants , server files constants. work in simple form, dont want go through pain of doing file server (headers, expiries, mime-types, etc) on own. there easy way bake static files binary in form , serve them way? the " go.rice " package takes care of - embedding resources in binaries, , providing http.filesystem implementation.

search string in comma separated array php -

i need return array contains search string in range . want search string pakistan1 , not take above that should ignore array key 0 second string bangladesh4 should ignore other keys below 4 final return array should array( [2]=> [3]=> [4]=> ) there 2 strings needs searched. how can go ? first : pakistan2 second : bangladesh4 $input_arr= array( 0=>array(india0,srilanka1,pakistan0,banglades0), 1=>array(india1,srilanka1,pakistan1,bangladesh1), 2=>array(india2,srilanka2,pakistan2,bangladesh2), 3=>array(india3,srilanka3,pakistan3,bangladesh3), 4=>array(india 4,srilanka4,pakistan4,bangladesh4), 5=>array(india 5,srilanka5,pakistan5,bangladesh5), ); i want return resulting array : $result_arr= array( 2=>array(india2,srilanka2,pakistan2,bangladesh2), 3=>array(india3,srilanka3,pakistan3,bangladesh3), 4=>array(india 4,srilanka4,pakistan4,bangladesh4) ) edited $first_str = "pakistan2";

sql - use for COUNT command to create query in MYSQL -

Image
below shows original sql table. select name, count(city) "count_no" emp group name order count_no desc; i need following result. sam has 4 records. there city of london in 2 records. need how many different cities in sam's records . did lots of queries, couldn't create sql query. add distinct count parameter: select name, count(distinct city) "count_no" emp group name order count_no desc;

php - mkdir() throws warning message -

what's error in here? <?php define('tmp_folder','temp'); $temp_dir = $this->dir['root'].$this->config['sep'].tmp_folder; //$temp_dir = c:\xampp\htdocs\xxx\temp //$this->dir['root'] = c:\xampp\htdocs\xxx if(!file_exists($temp_dir) && !is_dir($temp_dir)){ chdir('../'); mkdir(tmp_folder, 0744); } ?> this throws warning like:- warning: mkdir(): file exists in c:\xampp\htdocs\xxx\yyy\display.php on line 49 i think easy job. but, can't understand what's this? remove below line , try chdir('../');

php - using aggregate function in codeigniter query -

i trying write below query in codeigniter format , getting problem aggregate function: $stmt = "select sum(subscription_amt) samt, bill_month, sum(loan_refund_amt*no_of_loan_installment+error_amt) lamt pf_bill_det trim(pf_number)='$pfno' , fin_year='$fyear' , aproved='y' group bill_month"; $query = $this->db->query($stmt); this query ending error loan_refund_amt*no_of_loan_installment+error_amt not column . please me how write query using codeigniter query format. why don't try this $this->db->select("count(*) mycount"); $this->db->from("mytable"); $this->db->where("field", $value); $this->db->get(); or $this->db->select("sum(field_name) mysum"); $this->db->from("mytable"); $this->db->where("field", $value); $this->db->get(); or $this->db-

c# - Using HTTPS WSDL in Visual Studio/SSIS -

i've had issue have web service asmx file clients can access wsdl through https address, such https://example.address/webservice.asmx?wsdl . when adding web reference visual studio, tries access http://example.address/webservice.asmx?wsdl — returns 404 error server not configured allow non-secured access. occurs in ssis when adding web service reference, or web service task (even when certificate added). in visual studio, i'm able add service reference works (except double[] being changed arrayofdouble, etc.), doesn't appear service references option in visual studio provided within ssis. i've searched around quite bit , there seems no easy solution force https used. instead, i'm wondering if there way import wsdl references project manually without adding web reference (just add request methods). way can create own https soapclient uses these methods without web reference issue. you can generate client proxy classes using wsdl.exe web services d

python - django-recaptcha doesn't validate the input -

Image
i trying integrate django-recaptcha django-registration. have make sure django-registration works. install , configure django-recaptcha according document ( django-recaptcha 0.0.6 ). i add captcha = recaptchafield() in registrationform class in registration/forms.py follow: from captcha.fields import recaptchafield class registrationform(forms.form): required_css_class = 'required' username = forms.regexfield(regex=r'^[\w.@+-]+$', max_length=30, label=_("username"), error_messages={'invalid': _("this value may contain letters, numbers , @/./+/-/_ characters.")}) email = forms.emailfield(label=_("e-mail")) password1 = forms.charfield(widget=forms.passwordinput, label=_("password")) password2 = forms.charfield(widget=forms.passwordinput, label=_("password (again)")) captcha = recaptchafield() ... the captcha show up, no matter typed in chptcha text (type nothing, correct

cluster computing - How to deal with stale data when doing service discovery with etcd on CoreOS? -

i tinkering coreos , creating cluster based upon it. far, experience coreos on single host quite smooth. things little hazy when comes service discovery. somehow don't overall idea, hence asking here help. what want have 2 docker containers running first relies on second. if talking pure docker, can solve using linked containers . far, good. but approach not work across machine boundaries, because docker can not link containers across multiple hosts. wondering how this. what i've understand far coreos's idea of how deal use etcd service, distributed key-value-store accessible on each host locally via port 4001 , not have deal (as consumer of etcd ) networking details: access localhost:4001 , you're fine. so, in head, have idea means when docker provides service spins up, registers (i.e. ip address , port) in local etcd , , etcd takes care of distributing information across network. way, e.g. key-value pairs such as: redisservice => 192.168.3.132:4923

Import Xml into excel: Invalid file reference/ Invalid characters (CData) -

i'm having problems importing xml-file excel. the xml looks follows: <?xml version="1.0" encoding="utf-8"?> <documents> <document> <name><![cdata[ file1-123 ]]></name> <title><![cdata[ title file 1 ]]></title> </document> ... more docs... <document> <name><![cdata[ file2-456 ]]></name> <title><![cdata[ title file 2 ]]></title> </document> </documents> when importing excel 2007, following error: invalid file reference.the path file invalid or multiple schemes not found. according claims of colleague error result of invalid charachaters in cdata . i'm having troubles believing him. characters know invalid: { < , > , ' , " , & } yet characters claims causing errors are:

Pushing at Google Tag Manager the same variable, but they are duplicated -

Image
using google tag manager, use variable in order know location of application. every time user changes section, js code pushes new value 'location' variable, this: (function() { datalayergoogletagmanager.push({'location': 'tools'}); })(); my problem comes when check data layer, duplicates variable 'location' many different values. debugging in console: obviously, when try value of 'location', result not want. know how fix this? thank can provide this ok - datalayer variables act display in console - when they're updated value changes. if use gtm macro read value take latest one. i use html tag show current macro values debugging purposes: <script> console.log("*** gtm debugging console ***"); console.log("gtm event fired: " + {{event}}); console.log("debug mode: " + {{debug mode}}); console.log("location: " + {{location}}); </script> create macro location ,

multithreading - Python Threading - Managing thread termination and the main thread -

before read on, know i'm new python , new threading forgive me if misunderstand how threads work or make rookie error :p short description of goal: the main thread (a) things (e.g. prints "begin!") main thread spawns new thread (b) first prints "thread b started" , prints x+1 forever (1, 2, 3 ...) main thread prints "woop!" then end of main thread reached, terminates , switches thread b making b main thread program running thread b main thread printing x+1 forever , has been forgotten , no longer relevant ctrl+c terminate thread b , effectively, whole program terminated because thread doesn't exist anymore here's have far (the basics): import threading, time def printcount(): print "thread b started" x = 0 while true: time.sleep(1) x = x + 1 print x ## user code ## print "begin!" threadb = threading.thread(target=printcount) threadb.start() print "woop!" th