Posts

Showing posts from July, 2010

python - How can i execute the following code using pycurl -

curl https://api.smartsheet.com/1.1/sheets -h "authorization: bearer 26lhbngfsybdayabz6afrc6dcd" -h "content-type: application/json" -x post -d @test.json if new coding, don't use pycurl considered obsolete. instead use requests can installed pip install requests . here how equivalent requests : import requests open('test.json') data: headers = {'authorization': 'bearer 26lhbngfsybdayabz6afrc6dcd' 'content-type' : 'application/json'} r = requests.post('https://api.smartsheet.com/1.1/sheets', headers=headers, data=data) print r.json if must use pycurl suggest start reading here . done (untested) code: import pycurl open('test.json') json: data = json.read() c = pycurl.curl() c.setopt(pycurl.url, 'https://api.smartsheet.com/1.1/sheets') c.setopt(pycurl.post, 1) c.setopt(pycurl.postfields, data) c.setopt(pycurl.httpheader, ['

parsing a text file in python, c++, given specific format -

i have file in following format; parse in pyhton , c++ , extract number after impvarno: there lots of line in format. sample.txt start: abc pqr (ff_ggggg_confirm_tr):tc:20222,seqnum:86,impvarno:1000000008234436,id:12,oneid:66454,a/c:1,impvalue:905,impvar:25,actualvalue:905,actualvar:25,abc pqr xyz impquantity:0,pgb ncr yepp start: abc pqr (ff_ggggg_confirm_tr):tc:20222,seqnum:86,impvarno:1000000008234436,id:12,oneid:66454,a/c:1,impvalue:905,impvar:25,actualvalue:905,actualvar:25,abc pqr xyz impquantity:0,pgb ncr yepp start: abc pqr (ff_ggggg_confirm_tr):tc:20222,seqnum:86,impvarno:1000000008234436,id:12,oneid:66454,a/c:1,impvalue:905,impvar:25,actualvalue:905,actualvar:25,abc pqr xyz impquantity:0,pgb ncr yepp start: abc pqr (ff_ggggg_confirm_tr):tc:20222,seqnum:86,impvarno:1000000008234436,id:12,oneid:66454,a/c:1,impvalue:905,impvar:25,actualvalue:905,actualvar:25,abc pqr xyz impquantity:0,pgb ncr yepp so wrote following code: #!/usr/bin/env python import sys import re h

html5 - Scale font using css whether width or height changes -

i aware of vh/vw or wmin/vmax units. still can't scale font whether width or height changes. is, can scale font using css in 1 case - if want scale font when width changes, use vw, height vh. there can use both cases? for both cases can use css logic: width:100vw; height:50vw; max-height: 100vh; max-width: 200vh; i believe there vmin , vmax. vmin unit equal smaller of ‘vw’ or ‘vh’. vmax unit equal larger of ‘vw’ or ‘vh’. via http://www.w3.org

xcode - SQLite Query statement - Objective C -

my problem cant values select query executes 101 error. i think problem has quotes in select statement sqlite3 * database ; nsstring * path = [[[ nsbundle mainbundle ]resourcepath ] stringbyappendingpathcomponent : @"cars.sqlite"]; int returncode = sqlite3_open ([ path cstringusingencoding : nsutf8stringencoding], &database) ; sqlite3_stmt * statement ; char * st ; nsstring *querysql = [nsstring stringwithformat: @"select brand,model cars brand=%@;", tmpbrand]; const char *query_stmt = [querysql utf8string]; st = sqlite3_mprintf (query_stmt); if(sqlite3_prepare_v2 ( database , query_stmt , -1 ,& statement ,null )==sqlite_ok){ returncode = sqlite3_step ( statement ) ; // statement returns record while ( returncode == sqlite_row ) // while there rows { models*tmp=[[models alloc]init]; char* n=(char*)sqlite3_column_text(statement,0); tmp=[nsstring stringwithcstring:n encoding:nsutf8stringencoding]; char* model=(char*)sqlite3_colum

Java SE preventing maven clean -

i using maven remote resources plugin copies resources 1 module of app , creates xml file list of copied files. lot of times when build app , deploy tomcat, terminate , try again, build fails following message: [error] failed execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project students-ui: failed clean project: failed delete {application-path}\target\classes\meta-inf\maven\remote-resources.xml -> [help 1] this happens randomly, doesn't happen @ , takes 5 - 10 tries go through. when happens , try delete file manually says in use java se. why java hold file?

How do you configure PHP to use mysql instead of sqlite -

i have php 5.3 , mysql 5.1 installed on centos. php uses sqlite default, how can configure php use mysql instead? if drupal doesnt recognize mysql valid database backend, mysql doesnt seem installed correctly. try yum install mysql mysql-server php-mysql chkconfig --levels 235 mysqld on /etc/init.d/mysqld start mysql_secure_installation and restart apache with /etc/init.d/httpd restart then try again configure drupal.

c# - Doxygen Documentation for WPF -

i in process of creating documentation c# code. i've done lot of ordinary source code , set doxygen create html out of it. arrived @ ui done in wpf, both xaml , source code. question is, best way document these files? comments possible in xaml not useful cannot nested. don't know if doxygen can possibly handle xaml documentation. should documented in xaml.cs files? i found more or less solution. @ first, have add file extension file_patterns , *.xaml in case. doxygen uses extension determine parser use. guess default c. next add documentation this: <!--> /** \file * \brief brief file description. * * more elaborated file description. */ --> the < !-- , --> comment section xaml files. when doxygen parses file removes documentation without adding it. that's why there > fool doxygen parser comment finished. know ugly worst can happen descriptions lost in documentation still available in files. long there no better way of doing stick this.

c - syslogd not adding process/program name in logs -

i using syslog() function log messages. however, doesn't add program name in message originator of messages; instead, adding syslog e.g jul 16 01:44:49 2025 localhost syslog: passwords encrypted it should jul 16 01:44:49 2025 localhost mmy_c_program: passwords encrypted you may call openlog function first set name of application , facility.

javascript - Ajax Onchange replace div not working -

i have select box onchange, <select class="form-control" onchange="getval(this.value,'<?php echo $prd->pr_id;?>','ajax<?php echo $key?>','<?php echo $key ?>')"> and ajax div in foreach loop, foreach($name $names) { <div id = "ajax<?php echo $key?>" content </div> } my ajax function: function getval(id,prid,divid,key) { alert(divid) $.ajax({ type: "post", data: "aid="+id+"&prid="+prid, url: '<?php echo site_url('grocery/onchange')?>', success: function(html){ $('#'+divid).html(html); }; }); } i tryimg change div content..but not working? you need lot of changes in ajax- first use console.log() instead of alert , because div's id(s) being created dynamically need handle in way- $.ajax({ type: "post", data: {ai

Define 2 plotted lines in an image as variables inside a function in Matlab? -

Image
function [yupper, ylower] = segmentation(a) a=imread('g16.bmp'); ar=a(:,:,1); [rows, columns] = size(ar); avgs = mean(ar(50:165,:), 2); avgs2 = mean(ar(165:315,:), 2); [~,ind]= max(abs(diff(avgs))); [~,ind2]= max(abs(diff(avgs2))); figure, image(ar,'cdatamapping','scaled'); colormap('gray'); hold on; yupper=plot([1 size(ar,2)], [ind+50 ind+50], 'r', 'linewidth', 2); ylower=plot([1 size(ar,2)], [ind2+165 ind2+165], 'g', 'linewidth', 2); end above code used segment grey scale images based on large instensity changes,i'm looking declare 2 plotted lines variables can carry out future processing. however, if type in whos , lines appear follows in table; yl 1x1 112 matlab.graphics.chart.primitive.line yu 1x1 112 matlab.graphics.chart.primitive.l

json - if else in javascript leading to missing values -

i have data in json format . follows json string: var datastring4 = {"details":[{"observationsource":"outpatient clinic","observationvalue":98.69999694824219,"readingname":"body temperature", "observationdatetime":"2014,08,01","readingtype":"vitals"},{"observationsource":"outpatient clinic", "observationvalue":66,"readingname":"heart rate","observationdatetime":"2014,08,01", "readingtype":"vitals"},{"observationsource":"patient self reported","observationvalue":98.5,"readingname":"body temperature","observationdatetime":"2014,08,02", "readingtype":"vitals"},{"observationsource":"patient self reported","observationvalue":62,"readingname":"heart rate","

NEST query for Elasticsearch not working -

we using nest api work elasticsearch using c#. while can insert data, queries reference specific fields in object not working. for example, given following class: internal class magazine { public magazine(string id, string title, string author) { id = id; title = title; author = author; } public string id { get; set; } public string title { get; set; } public string author { get; set; } } objects of class created , inserted elasticsearch follows: magazine mag1= new magazine("1", "soccer review", "john smith"); magazine mag2= new magazine("2", "cricket review", "john smith"); uri node = new uri("http://localhost:9200"); connectionsettings settings = new connectionsettings(node, defaultindex: "mag-application"); elasticclient client = new elasticclient(settings); client.index(mag1); client.index(mag2); the following query works, , returns 2 rows: var searc

java - What is the correct way to pass arguments to the JavascriptExecutor? -

i'm trying use javascriptexecutor code, involved passing in webelement , info it. getting errors, simplified down find problem. string test = ((javascriptexecutor)driver).executescript("return arguments[0];", "macon").tostring(); that code won't run. it'll throw nullpointerexception . can avoid not trying access passed variable. doesn't seem matter pass; int, string, webelement , etc etc. so what's wrong? can't see discrepancies between online examples , code, there's something. i'm using firefox webdriver, , selenium version 2.44.0 you need cast results string : javascriptexecutor js = (javascriptexecutor) driver; string test = (string) js.executescript("return arguments[0];", "macon"); also, there compatibility issues between selenium 2.44 , firefox 35/36 affected javascript code execution: firefox 35: passing arguments executescript isn't working

database - Partitions by null values with MySQL -

i have table: create table `newtable` ( `iblock_element_id` int(11) not null , `property_1836` int(11) null default null , `description_1836` varchar(255) character set cp1251 collate cp1251_general_ci null default null , `property_1837` int(11) null default 0 , `description_1837` varchar(255) character set cp1251 collate cp1251_general_ci null default null , `property_1838` decimal(18,4) null default null , `description_1838` varchar(255) character set cp1251 collate cp1251_general_ci null default null , `property_3139` int(11) null default 0 , `description_3139` varchar(255) character set cp1251 collate cp1251_general_ci null default null , `property_3173` decimal(18,4) null default null , `description_3173` varchar(255) character set cp1251 collate cp1251_general_ci null default null , primary key (`iblock_element_id`), index `ix_perf_b_iblock_element_pr_1` (`property_1837`) using btree , index `ix_perf_b_ibloc

version control - SVN JSHint Hook? -

i have been searching in google , on here have not found relavant answer. project working on using svn. question have wondering if has implemented pre-commit hook stop check in if jshint fails? thank has experience doing this. i not make pre-commit hook because of length of time jshint takes. when commit, they'll have wait jshint complete , wait verdict. remember subversion hooks run on server , not client's machine. means pre-commit hook has checkout, , run jshint. if takes 30 seconds perform, it's 30 seconds developer sitting there waiting commit finish , having hatred you, company, , subversion grow. plus, if happens hook causes fail, you'll have debug , fix while developers unable commit code. your developers grow hate , subversion , may take step of setting own source repository. i've seen done in days when clearcase ruled , subversion first created. developers setup own repository subversion (since easy do) , stopped using corporate clearcas

Scala: how to flatten a List of a Set of filepaths -

i have list[set[path]] : update : each path in set unique , represents particular directory location. there no duplicates. so, looking total number of path elements/ val micedata = list(set(c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test7.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test2.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test6.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test5.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test8.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test3.txt, c:\users\lulu\documents\mice_data\data_mining_folder\apowerpoint.pptx, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test1.txt, c:\users\lulu\documents\

ElasticSearch and Kibana: compare value with aggregated value -

i'm wondering how accomplish requirement. have compare value data average on selected period or on period. i've collected millions of records in index. these records contains sellout amount day day different vendors, products, sectors , product families. what i'd analyse single value average of selected period of average of same periodo of previous year. i'd use kibana show data users. how can accomplish it? thanks

java - In Hibernate Query Language is there any way to select from the result of Inner Query? -

i want select count of result of sub query e.g. select count(*) (select * entity group ); is there way in hql? hql subqueries can occur in select or clauses. hibernate subqsueries

php - Extending calendar functionality to accept years -

Image
i'm working on event scheduler site , stuck i'm using months table (with id & month headers) group results month. due this, if try schedule event january 2016, puts month choose intended, understandably puts 2015. i'm looking on extending beyond end of current year , adding functionality different years. i happily use method using current table setup, tips or suggestions appreciated. current code follows: <?php include 'includes/connect.php'; include 'includes/header.php'; $curmonth = date("n"); ?> <b>upcoming trip information:</b><br><br> <?php $res = mysql_query("select * months order id"); while ($rows = mysql_fetch_array($res)) { if($rows['id'] >= $curmonth ){ $monthname = $rows['month']; ?> <table cellpadding="0" cellspacing="3" width="100%"> <tr> <td> <?php $tid = $_get['transporter']; $check = mysq

c++ - Analyze concurency::task() API & why do we need this? -

i'm, trying understand syntax of concurrency::task in below code snippet. i'm unable understand code snippet syntax. how analyze this: what "getfileoperation" here. object of type storagefile class ? "then" keyword mean here ? there "{" after then(....)? i'm unable analyze syntax ? also why need concurrency::task().then().. use case ? concurrency::task<windows::storage::storagefile^> getfileoperation(installfolder->getfileasync("images\\test.png")); getfileoperation.then([](windows::storage::storagefile^ file) { if (file != nullptr) { taken msdn concurrency::task api void mainpage::defaultlaunch() { auto installfolder = windows::applicationmodel::package::current->installedlocation; concurrency::task<windows::storage::storagefile^> getfileoperation(installfolder->getfileasync("images\\test.png")); getfileoperation.then([](windows::storage::storagef

Excel count instances of a value error -

Image
i need count amount of times value shows in b column , display in 3 seperate fields. came piece of code: =countif(b2:b6716,"0") =countif(b2:b6716,"1") =countif(b2:b6716,"2") but no matter how enter keeps telling me formula incorrect. tried removing " around 3 numbers aswell btw , in order test used words won't work. idea how can work? the error: try like: =countif(b1:b416; "=0") as criteria, should rather put string appended tested value forms condition, not particular number. way, can formulate more fancy criteria, like: =countif(b1:b416; ">100")

.htaccess - Redirect .html extension to no html extension -

i using rule in .htaccess rewritecond %{request_uri} !^/billing/ rewriterule ^([^\.]+)$ $1.html [nc,l] and wondering it possible automatically redirect links have .html @ end e.g examplewebsite.com/fishing.html examplewebsite.com/fishing thanks! you can add redirect rule .html removal before earlier rule : rewritecond %{the_request} /([^.]+)\.html[\s?] [nc] rewriterule ^ /%1 [r=302,l,ne]

Java Min Heap Priority Queue Implementation -

i'm trying implement min heap pq, i'm having issues regarding correctness of implementation , can't seem figure out i'm doing wrong - doesn't output lowest priority or sort them properly. public void additem(vertex item) { if (queuesize == queuearray.length) { vertex[] queuearray2 = new vertex[queuesize*2]; system.arraycopy(queuearray, 0, queuearray2, 0, queuesize); queuearray = queuearray2; } if (queuesize == 0) { queuearray[queuesize] = item; // insert @ 0 queuesize++; } else { int index=queuesize; //vertex newnode = new vertex(item, priority); queuearray[index] = item; queuesize++; int parent=(index-1)/2; while (index!=0 && queuearray[index].getf()<queuearray[parent].getf()) { // swap parent , index items vertex temp = queuearray[parent];

jquery - Reading in a local csv file in javascript? -

[edit] solved problem using d3 , nevermind thanks! so have csv file looks this, , need import local csv file client side javascript: "l.name", "f.name", "gender", "school type", "subjects" "doe", "john", "m", "university", "chem i, statistics, english, anatomy" "tan", "betty", "f", "high school", "algebra i, chem i, english 101" "han", "anna", "f", "university", "phy 3, calc 2, anatomy i, spanish 101" "hawk", "alan", "m", "university", "english 101, chem i" i need parse , output like: chem i: 3 (number of people taking each subject) spanish 101: 1 philosophy 204: 0 but now, stuck on importing javascript. my current code looks this: <!doctyp

Visual Studio 2013 Pro installation 0x80070643 error -

Image
when install visual studio professional update 4, "package failed" error. the log file show 4 errors , 1 warning. the 4 errors are: 0x80070643: failed execute msu package 0x80070643: failed configure pre-machine msu package mux: set result: return code = -2147023293 (0x80070643) error message =, vital = false, package action = install, package id = windowsidentityfoundation_x64 applied non-vital package: windowsidentityfoundation_x64, encountered error: 0x80070643. there 1 warning message: mux: warning : missing display name: windowsidentityfoundation_x64 googling led me here . don't know .net etc , hoping can fix without opening whole new can of worms because worried if tried reinstalling .net may entangled in host of other issues. please help. thanks. have tried apply method 1. fix suggested microsoft: https://support.microsoft.com/en-us/kb/976982/en-us this seems have fixed issue others have come across around web

python - How to increase the size of a thumbnail in QListWidget -

problem => create qlistwidgetitem object containing list of images thumbnails @ relatively larger size current 1 have (sorta "medium icons" or "large icons" option in windows explorer) progress far => have managed find out how create list , icons far small. what have tried => i've tried changing font size of list items assuming tht cld make font grow bigger proportionally. didn't work. i've tried setting size of thumbnail using (pil's image) according online blogger didnt work well. code snippet => #imported image , imageqt pil , imported qtgui , qtcore testimages = glob.glob(dirname + "/*.jpg") # create list item each image file, # setting text , icon appropriately image in testimages: picture = image.open(image) picture.thumbnail((128,128), image.antialias) icon = qicon(qpixmap.fromimage(imageqt.imageqt(picture))) item = qlistwidgetitem(image, self)

CSS Selector "combine" Elements -

i'm new css , try parse html via jsoup parser java. example html: <p>however beautiful s6 edge looks, doubt [...] <a title="samsung unveils galaxy note 4 , curved screen note edge" href="http://www.example.com/">note edge</a>, dual gently curved screen [...] or accidental palm taps.</p> i text inside <p> element follows: elements text = doc.select("p"); (element element : text) { system.out.println(element.owntext() + "\n"); } output: however beautiful s6 edge looks, doubt [...] , dual gently curved screen [...] or accidental palm taps.   1 can see, text note edge insde <a> element not showing up. so wanted ask if there possiblity show entire text, including text inside <a> element follows: however beautiful s6 edge looks, doubt [...] note edge , dual gently curved screen [...] or accidental palm taps. i'm greatful every suggestio

java - Can't load IA 32-bit .dll on a AMD 64-bit platform -

error loading win32com: java.lang.unsatisfiedlinkerror: c:\program files\java\jdk1.7.0_51\jre\bin\win32com.dll: can't load ia 32-bit .dll on amd 64-bit platform when using project send sms phones, got above error. have machine amd processor. please me descriptive answer. lot ! try that: 1.download , install 32-bit jdk. 2.go eclipse click on project(run as-> run configurations...) under java application branch. 3.go jre tab , select alternate jre. click on installed jre button, add 32-bit jre , select it.

Custom Visibility Modifiers in C++ -

i reading signals & slots | qt core 5.4 , had following code snipped. #include <qobject> class counter : public qobject { q_object public: counter() { m_value = 0; } int value() const { return m_value; } public slots: void setvalue(int value); signals: void valuechanged(int newvalue); private: int m_value; }; i have seen private , public , , protected before never this. what going on whole public slots: , signals: visibility modifiers (is called)? what mean , in standard talk this? when can / should use these in own code? slots signals evaluate empty strings or modifiers , defined implicitly including qobject.h . these markers qt moc (meta object compiler). q_object being expanded generic qt-class interface. the moc generate code header , these macros provide information 'these methods slots' or 'this going qt-ified class' you should use them in qt-projects , case develop class 'become'

unable to render facebook login button on android studio -

i'm facing strange problem facebook login button of facebook android sdk 4. i've follow guide convert previous code (i've used old facebook sdk), android studio not render correctly button. login button code: <com.facebook.login.widget.loginbutton xmlns:fb="http://schemas.android.com/apk/res-auto" android:id="@+id/fb_button" style="@style/facebookloginbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/my_button" android:layout_centerhorizontal="true" android:layout_marginbottom="-14dp" android:textsize="34sp" fb:login_text="@string/login_with_facebook" fb:logout_text="logout" /> wbhere facebook login button style is <style name="facebookloginbutton"> <item name="android:background">@drawable/button_facebook</it

Import a django app view in another app view -

i have 2 django apps , i've called view of app1 in app2, this: #app: app1 #someview.py def a_view(request, someparam): #some code here #app: app2 #otherview.py app1.someview import a_view def another_view(request): param = 1 a_view(request, param) def view2(request): #some code it works fine. problem want call view app2 in app1. add import statement in someview.py this: #app: app1 #someview.py app2.otherview import view2 def a_view(request, someparam): #some code here the result importerror "cannot import name view2". can tell me why happen? the second import shadowing first 1 ... try import app2.otherview or from app2.views app2_views

java - Stateless and Stateful confusing definitions and outputs (contradicting to my view) -

from understand @stateless means state of every encountering of client server starting scratch, , @stateful means server saves in memory client's data. (" stateless means there no memory of past. every transaction performed if being done first time. statefull means there memory of past. previous transactions remembered , may affect current transaction. "). i have been reading http://www.tutorialspoint.com/ejb/ejb_stateless_beans.htm , http://www.tutorialspoint.com/ejb/ejb_stateful_beans.htm . examples there show in @stateless annotation, when client exits , re-enters, seems if server did save data , presented books added "previous" client, in @stateful annotation seems if server treated returning client new one, , didn't save list client created. i assume misunderstanding has misunderstanding of terms "state", "memory" or "transaction", @ moment, confused definition seems contradicting outputs. you hav

apache - Whitelist user IPs in Shiro -

i enable facebook crawl website, needs user authentication. facebook says 1 way around whitelist ips. using apache shiro , know can client's ip calling gethost basichttpauthenticationfilter, not know how let ip addresses past authentication. you have build custom implementation of shrio's org.apache.shiro.web.filter.authc.authenticatingfilter minimally, have customize basichttpauthenticationfilter extending , adding logic skip basichttpauthenticationfilter if request coming whitelisted ip address. package com.acme.web.filter.authc; import java.io.ioexception; import java.util.collections; import java.util.hashset; import java.util.set; import javax.servlet.servletexception; import javax.servlet.servletrequest; import javax.servlet.servletresponse; public class whitelistedbasichttpauthenticationfilter extends basichttpauthenticationfilter { private set<string> whitelist = collections.emptyset(); public void setwhitelist(string list) {

php - MySQL EAV SELECT one-to-many single row results -

i've seen similar questions on here, haven't been able find 1 matches specific scenario. have following 3 tables: content id, [other fields] attributes id, title attributes_values id, attribute_id[foreign attributes.id], content_id[foreign content.id], value what i'd single query (or group of sub-queries) can return appropriate data avoid having manipulate in programming. a little more info tables: attributes has 3 records (model #, part #, , show in cart). i need select records content attribute_value show in cart = 1. along this, i'd other related attribute_values returned related attribute.title. results this: id [other fields] model # [from attributes.title field] part # [from attributes.title field] 1 [any data] value attributes_values value attributes_values 2 [any data] value attributes_values value attributes_value so far, way of accomplishing not elegant i'm having multiple joins same

Jquery Replace Select Options -

this question has answer here: how change options of <select> jquery? 7 answers i looking replace current select options set of option without using loop. have block of code: <select> <option>o1</option> <option>o1</option> </select> i have variable: $newoptions = "<option>newo1</option> <option>newo1</option>"; and want swap inside of select state new options. no loop needed. <select> $newoptions </select> is there way using jquery? $('selectoptions[name='+fldname+']').replacewith(newoptions); thank you. try way: <select id='needselect'> <option>o1</option> <option>o1</option> </select> $newoptions = "<option>newo1</option> <option&g

node.js - Mongoose.js - population and additional fields? -

i want add additional data usermodel watchedmovies , have following schema: let userschema = new schema({ watchedmovies: [{ type: schema.types.objectid, ref: 'movie' }] }) and: let movieschema = new schema({ title: string }) i wondering possible add additional fields watchedmovies object , store along objectid? add watchedat date when i'm populating watchedmovies usermodel.find().populate('watchedmovies', 'title').exec(...) like: { _id: objectid(userid), watchedmovies: [{ _id: objectid(...), title: 'some title', watchedat: timestamp }] } watchedat attribute specifies when (date object) reference added usermodel is possible mongoose , how should change schema? thank you change schema to let userschema = new schema({ watchedmovies: [{ movie: { type: schema.types.objectid, ref: 'movie' }, watchedat: date }] }) then can populate .populate('

javascript - Select values, then only call function -

i use jsfillde used previously. as can see when clicking on filter (soup, meat, etc.), filtered result load in real time . instead let user make selection , then trigger result cliking a"update" button (to enhcance performances on mobile) i quite unsure how acheive in javascript, new..i using ionic, , below html piece call filter function. <ion-item ng-repeat="dish in dishlist | selecteddishtype:selection "> <article class="item_frame"> <h1 class="item_name_english">{{dish.nameenglish}}</h1> <h2 class="item_name_local_language">{{dish.namelocal}}</h2> <p class="item_description ">{{dish.description}}</p> </article> <!--main article frame 1 --> </ion-item> add button : <div class="listing_venue_types_filter_page"> <div class="input

javascript - Magnific Popup link format -

so.... problem. seemed magnific popup wouldn't work libraries added correctly , console didn't display errors. figured out removing tags in link. have html markup not working: <a class="image-link" href="img/gallery1.jpg"> <img class="img-responsive" src="img/gallery1.jpg" alt=""> <span class="zoom"></span> </a> here's simple script lightbox: <script type="text/javascript"> $(document).ready(function() { $('.image-link').magnificpopup({type:'image'}); }); </script> but if remove span, lightbox triggers correctly. have span because icon hover effects in css. i'd make plugin work it. please me , don't assume much. don't know javascript/jquery programming.

python - Plotting contours from data csv -

i have data within csv file temperature, x, y , z points arranged in columns. z points can negated remains 0 through data acquisition. i'd obtain contour plot of data. my problem same this got redirected other threads still couldn't figure out going on. edit: here's unfinished code should open data? don't know go here. import numpy np import matplotlib.pyplot plt matplotlib.mlab import griddata import csv data = np.genfromtxt('tempcontour0.csv', delimiter=',', dtype=[('t',float),('x',float),('y',float),('z',float)],usecols=(0,1,2)) t=data['t'] x=data['x'] y=data['y'] z = np.zeros((len(x),2)) z[:,0] = x z[:,1] = y plt.contour() plt.show() the data file so: t,x,y,z 316.002,0,0,0 309.314,0.00839113,0,0 309.67,0.0172418,0,0 310.34,0.0265772,0,0 310.903,0.0364239,0,0 311.558,0.0468098,0,0 312.704,0.0577645,0,0 313.582,0.0693192,0,0 314.582,0.0815067,0,0 316.2,0.0943616,0,0 317.391,0

javascript - Angular custom method on $resource with .then() function causing error -

i have in angular service: return $resource(base + '/cases/:id', {id: '@id'}, { status: {method: 'get', params: {status: '@status'}} }); when using method added $resource definition along promise's .then() function, i'm getting error: cases.status({status: 'pending'}) .then(function(res) { console.log(res); $scope.cases.pending = res.data.cases; }) .then(function() { $scope.tabbed.pending = true; }); after above snippet run, error is: typeerror: undefined not function on line: .then(function(res) { can not use these functions when i'm using method defined on $resource ? i think need use $promise of $resource object call success function when actual promise gets resolved & proceed promise chain. code cases.status({status: 'pending'}) .$promise .then(function(res) { console.log(res); $scope.cases.pending = res.data.cases; }) .then(f

jsp - Spring form:select issue -

i wrote simple code in jsp using form:select <form:select id="a" path="validpath"> <form:option value="x"/> <form:option value="y"/> </form:select> here showing whole box , showing these 2 items. not looking drop down box. showing options in single huge box. make more clear showing option without selecting something x y ... i not sure how can fix issue? i think should work. can refer link more information : spring mvc dropdown box example make sure have added library <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

mysql - DISTINCT ON query w/ ORDER BY max value of a column -

i've been tasked converting rails app mysql postgres asap , ran small issue. active record query: current_user.profile_visits.limit(6).order("created_at desc").where("created_at > ? , visitor_id <> ?", 2.months.ago, current_user.id).distinct produces sql: select visitor_id, max(created_at) created_at, distinct on (visitor_id) * "profile_visits" "profile_visits"."social_user_id" = 21 , (created_at > '2015-02-01 17:17:01.826897' , visitor_id <> 21) order created_at desc, id desc limit 6 i'm pretty confident when working mysql i'm new postgres. think query failing multiple reasons. i believe distinct on needs first. i don't know how order results of max function can use max function this? the high level goal of query return 6 recent profile views of user. pointers on how fix activerecord query (or it's resulting sql) appreciated. the high level goal of query r

multithreading - Forcing MPI to use a specified no. of cores -

i kinda new mpi, forgive me if trivial question. have quad core cpu. , want run openmpi c++ program uses 2 processes on single core. there way so? if so, how? referred this link on stack overflow which, most probably , says there might way... if so, how can it? since mpi spawns separate processes, scheduling of processes onto cores generally/usually performed operating system. can still achieve want manually setting affinity of processes specific core. you can in linux using sched_setaffinity function. to pin process specific core, can use following approach: #include <mpi.h> #include <sched.h> // ... void pin_to_core(int cpuid) { cpu_set_t set; cpu_zero(&set); cpu_set(cpuid,&set);

recursion - Missing 1 required positional argument - Python -

typeerror: sequence() missing 1 required positional argument: 'n', sequence() apparently when using sequence(n-1) + sequence(n-2) n not using value function, can fix it? memo = {0:0,1:1} def sequence(type, n): if type == "fibonacci": if not n in memo: memo[n] = sequence(n-1) + sequence(n-2) else: return memo[n] try this: sequence(type, n-1) + sequence(type, n-2) the error explicit, function sequence expecting 2 parameters, you're passing one. side note, should remove else , , make sure return memo[n] executed @ end - because function must always return value, otherwise recursion won't work.

jsp - Form, input, onMouseOver - onMouseOut and browsers -

Image
i've form (post) input (a line), in jsp file: <input type="submit" value="executar" name="1" id="execute" style="visibility:hidden" onmouseover="window.status='url: http://jlex1x2-uocpfc.rhcloud.com'" onmouseout="window.status=''"> it works with: ie 6 , mozilla firefox 36.0.4: see onmouseover. it doesn't work with: mozilla firefox 9.01 , chrome 41.0: nothing appears. ie 9: appears '*.rhcloud.com/directory/filename.jsp#' edit 2 apr: my form (simplifyed) (without textarea): : <form action="#" method="post"> ... // initial code </form> i improve input (for browsers) '*.rhcloud.com'. working fine me..just remove style="visibility" . here code , output screenshot : <input type="submit" value="executar" name="1" id="execute" onmouseover="win

html - Styling issue with Datalist formatted as Div Table -

Image
i creating datalist formatted table using divs formatting. problem header of table not lining rest of table. if remove headertemplate, lines properly. suggestions on how can fix this? my datalist aspx <asp:datalist id="table1" runat="server" repeatcolumns="1" cellspacing="1" repeatlayout="table"> <headertemplate> <div class="table"> <div class="heading"> <div class="cell"> <p>heading 1</p> </div> <div class="cell"> <p>heading 2</p> </div> <div class="cell"> <p>heading 3</p> </div> <div class="cell"> <p>heading 4</p> </div> <div class="cell"> <p>heading 5</p>

How to fill multiple areas with different colours in a map & adding labels so as not overlapping each other in R? -

this follow question earlier post . i have been able of way answer help. still trying fill function work correctly. have each padd in data set different colour. padd made of number of states. here data: structure(list(state = structure(c(1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l, 9l, 10l, 11l, 12l, 13l, 14l, 15l, 16l, 17l, 18l, 19l, 20l, 21l, 22l, 22l, 23l, 24l, 25l, 26l, 27l, 28l, 29l, 30l, 31l, 32l, 32l, 33l, 34l, 35l, 36l, 37l, 38l, 39l, 40l, 41l, 42l, 43l, 44l, 45l, 46l, 47l, 48l, 49l, 50l), .label = c("alabama", "alaska", "arizona", "arkansas", "california", "colorado", "connecticut", "delaware", "florida", "georgia", "hawaii", "idaho", "illinois", "indiana", "iowa", "kansas", "kentucky", "louisiana", "maine", "maryland", "massachusetts", "michigan", "m

.net - Attributes in external assembly -

i using sqlite-net . uses attribute [ignore] skip field during serialization. i have class property: [ignore] public observablecollection<myentity> myentities { get; set; } it works fine when create table: _connection.createtableacync<myclass>().wait(); now move class external assembly (project) , have error when sqlite-net trying create table. error messages said there unknown type observablecollection. looks [ignore] attribute doesn't work if class in external assembly (project). i trying debug sqlite-net code. here the fragment : var ignore = p.getcustomattributes (typeof(ignoreattribute), true).count() > 0; if (p.canwrite && !ignore) { cols.add (new column (p, createflags)); } i have ignore == false field [ignore] attribute. i newbie in .net not sure in case. are attributes working classes in external assemblies (project)? if are, error in sqlite-net ?

matlab - Custom Curve-Fitting equation doesn' t works -

i trying fit custom equation cumsu=a+b*(1586-x).^m estimate parameters a,b,m. data: cumsu=[...];%the reason don't give vector cumsu large number of values included. x=[1:1586]; i thankful if can helps me. thank in advance! you can create custom fitting models via fit function . fitobject = fit(x,y,fittype,fitoptions) in case should replace fittype fitting equation: customfit=fit(x,cumsu,'a+b*(1568-x)^m') with random numbers output was: general model: f(x) = a+b*(1568-x)^m coefficients (with 95% confidence bounds): = -2.011 (-2.959e+06, 2.959e+06) b = 1.479 (-2.424e+06, 2.424e+06) m = 0.1049 (-9.702e+04, 9.702e+04)

javascript - Bing Speech and Bing Maps conflicting in Windows 8 Store app -

bing maps dosent work when bing speech referenced in win8 system(works win8.1 system). in veapicore.js , veapimodules.js there window[$mapsnamespace]. when both spech , maps referenced maps never intialized in namespace. speech present which.the maps namespace has 2 dll files refernced bing speech. happens in windows 8 system. in 8.1 both speech , maps in maps namespace. there solution this. i've come across before. it's speech api overriding microsoft namespace. there 2 options. first add bing maps script reference after speech reference. bing maps sdk extends microsoft namespace , not override it. second option change namespace of bing maps control: add snippet before referencing sdk js files in html file below: window.$mapsnamespace = 'microsoftjs' ; then replace newly created custom namespace ‘microsoft’ below: microsoftjs .maps.loadmodule('microsoft.maps.map', { callback: createmap, culture: 'us', homeregion: 'en-us' });

c - how to print values from file after appending -

i have following problem: must must make student file name, age , grades. works ok, problem when printing on screen. let's read 3 students, when type 'l' printing content on screen works great. when press 'a' add student file(append), student appear in file(so have total of 4 students), when press 'l' print again, prints 3 out of 4 students, including appended one, removes anther one. 's' stands write file. #include <stdio.h> #include <stdlib.h> #include <ctype.h> struct student{ char nume[20]; int varsta; float medie; }; void citire_date(struct student *studenti, file *f, int n){ int i; for(i=0;i<n;i++){ printf("introduceti datele studentului %d\n", i+1); printf("nume: "); fflush(stdin); gets((studenti+i)->nume); printf("varsta: "); scanf("%d", &((studenti+i)->varsta)); printf("medie: "); scanf("%f",