Posts

Showing posts from June, 2011

Python lists, increment & return modified list -

this question has answer here: python assign values list elements in loop 4 answers the below code doesn't work intended: l = [1,1] def modifylist(list): element in list: element += 1 return list the list expect when run: modifylist(l) is [2,2] instead of [1,1] can explain why python acts way? you need access list element using index , increment: def modifylist(lst): ind, _ in enumerate(lst): lst[ind] += 1 # access list element index , increment return lst or use list comprehension , add 1 each element: def modifylist(lst): lst[:] = [ele +1 ele in lst] # lst[:] changes original list return lst if modifying original list in place, don't need return value, if want create new list return list comprehension: return [ele +1 ele in lst] def mod_in_place(lst): lst[:] = [ele +1 ele in lst] # lst[:] chan

winapi - WS_OVERLAPPEDWINDOW and WM_SYSKEYDOWN -

setwindowlong(hwnd, gwl_style, ws_overlappedwindow); if add line above, program receive every second press of alt key. catch alt key wm_syskeydown event. must mention though, wm_syskey up still detects every release of alt key. so when repeatedly press alt key log looks this: down up down up any idea why that, , how fix problem still retain normal application window look? (that why overlapped window flag used). update: found ws_sysmenu causes same problem, must related sys menu hotkeys.

codeigniter - mb_convert_encoding() function is not working in php -

i using library (glocery_crud) in codigniter convert database table csv , working fine on localhost on live server showing me blank page , not creating csv file . here code -: // convert utf-16le , prepend bom $string_to_export = "\xff\xfe" .mb_convert_encoding($string_to_export, 'utf-16le', 'utf-8'); $filename = "export-".date("y-m-d_h:i:s").".csv"; header('content-type: application/csv;charset=utf-16le'); header('content-disposition: attachment; filename='.$filename); header("cache-control: no-cache"); echo $string_to_export; die(); if commenting first line geting csv file not formatted in csv () -: testing9988312003sdgsgsdgsgvipul@gmail.comsdgfrayear it works fine $string_to_export = "\xff\xfe".iconv("utf-8","ucs-2le",$string_to_export);

python 2.7 - PyPlot.pltm is not defined -

i on ubuntu 14.04 platform. have installed julia, anaconda etc. when try plot on ijulia using pyplot, following error. julia> pkg.add("pyplot") info: nothing done julia> using pyplot julia> x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x)); julia> pyplot.plot(x, y, color="red", linewidth=2.0, linestyle="--") error: pltm not defined in plot @ /home/cgmei/.julia/v0.3/pyplot/src/pyplot.jl:368 is pltm part of other package. when want call external python packages in julia need call them in different way did. in example should is: pkg.add("pycall") using pycall @pyimport pylab x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x)); pylab.plot(x,y, color="red", linewidth=2.0, linestyle="--") pylab.show() if want use python library example clarify, assuming have added package pycall: using pycall @pyimport numpy x = numpy.linspace(0,2*pi,1000) and result

python - pelican blog post not getting generated -

i trying post pelican blog python app, not doing pelican ./output -s settings.py commandline. i have modified pelican accept mocked argparse object pass needs, have moved content of main function in __init__.py to function named runpelican(args) accepts args, , app has mocked argparse this, class mockargparse(object): """mock argparse's pass pelican """ def __init__(self, verbosity=true, theme=none, output=none, path=none, delete_outputdir=none, settings=none, ignore_cache=none, cache_path=none, selected_paths=none, autoreload=none): """ args: path (str): content path settings(str): settings python file path """ super(mockargparse, self).__init__() self.theme = theme self.cache_path = cache_path self.ignore_cache = ignore_cache self.delete_outputdir = delete_outputdir self.s

javascript - Disable submit button on file input validation error using krajee file-input plugin -

i using plugins.krajee.com/file-input , can't find way of disabling upload or submit button of form when validation error occurs minimagewidth exceeded. $('.file').fileinput({ language: 'en', showupload: false, allowedfileextensions : ['jpg', 'png','gif'], maxfilesize:1024, minimagewidth:286, minimageheight:322 }); how use $('.file').fileinput('disable'); when image width minimum setting returns validation error?

javascript - Node.JS WriteFile - File of specific size -

is there way specify size/length of file , have system reserve space needed? i'm looking like: fs.write('file', buffer, 1024*1024*54); // create 54mb file. just create buffer of size? fs.writefile('file', new buffer(1024*1024*54));

sql - How fatal is the maximum execution timeout warning in MySQL -

Image
been working xamp installed under year. installed few frontend software mysql (to see 1 comfortable most). now, past 2 days, whenever go localhost/phpmysql , receive warning fatal error: maximum execution time of 30 seconds exceeded in c:\xampp\phpmyadmin\lib.. i understand maximum execution time required execute being exceeded here. found few post on stackoverflow guides rectification. , till here. i have question , concern. question why of sudden error when, remember, did nothing upset default settings of mysql? concern i working on project uses database (important, cannot loose it), phpmyadmin when refreshed after warning starts work there never problem. i'll need couple of week done project. can continue timeout error without risking database or should try , rectify right away? dcoder answer good, try change maximium execution time in mysql server, also, can try find query making noise using slow-query-log (you can activate , useful in case of mes

c# - How to open new form when Enter as Tab? -

when press enter button, acts tab code @ form1_keydown event control nextcontrol; if (e.keycode == keys.enter) { nextcontrol = getnextcontrol(activecontrol, !e.shift); nextcontrol.focus(); e.suppresskeypress = true; } there combobox in form press enter button open new form . how because doesn't work on cmb_keypress event here can wirte as: control nextcontrol; if (e.keycode == keys.enter) { nextcontrol = getnextcontrol(activecontrol, !e.shift); nextcontrol.focus(); if(nextcontrol=combo) { keypreview=false; } e.suppresskeypress = true; }

sql - Oracle Display the values of columns in single row without using connect by clause -

Image
this query select deptno,ename emp_task; output i want output this eno ename 20 trinath/rabha 8 saikiran/kishore 10 kumar/vicky/dafni select deptno, listagg(ename,'/') within group (order ename) names temp_task group deptno order deptno;

ios - Issue while doing in-AppPurchase in iPhone -

Image
i adding in- apppurchase feature app. i want select type non-consumable not getting option. i getting screen. knows how solve issue. it seems or agent of account haven't agree latest paid application agreement. you must have paid applications contract apple in place use iap. https://developer.apple.com/library/ios/documentation/languagesutilities/conceptual/itunesconnect_guide/chapters/managingcontractsandbanking.html

centos6.5 - install errors on astrisknow 6.12-64bit on vmware workstation 8 -

i'm using asterisk , trying implement test environment testing asterisk functionalities on vm. i'm using vmware workstation 8 , trying install asterisknow 6.12-64 bit vi iso downloaded following location. http://www.asterisk.org/downloads/asterisknow now i'm stuck in middle of: installing vmware tools,please wait... mount : special device /dev/hda not exist mount : block device /dev/sr0 write-protected, mounting read only after forever waiting. this taking long , never ending. tried install several times , result same. noticed starting install following error displayed, lets continue: unsupported hardware detected. this hardware (or combination thereof ) not supported centos. {note i'm using typical vm in vmware} i tried browsing google solution couldn't find solution. please , let me know if best way start asterisk. looks trying install vmware tools vm. vmware tools optional , used convinience only. try searching setting d

javascript - Access the element inner html and attribute values inside controller function -

html content as, <div ng-controller="logctrl"> <ul> <li ng-click="logme" someattr="hello ricky">hello martin</li> </ul> </div> javascript content as, var app = angular.module('app', []); app.controller('logctrl', function ($scope, $element) { $scope.logme = function(){ console.log("html content " + /*---- how can print $element's inner html text here --- */) console.log("attribute value " + /*---- how can read li element's someattr value here --- */) } }) this must print message in console (when user clicks mouse), html content hello martin attribute value hello ricky try html <li ng-click="logme($event)" someattr="hello ricky">hello martin</li> controller $scope.logme = function(e){ var value=e.target.attributes.someattr.value; }

ruby on rails - How to solve this internal error in redmine -

when try connect database in redmine custom workflow, , click on "save", redmine internal error. please find code below @connection = activerecord::base.establish_connection( :adapter => "mysql2", :host => "localhost", :database => "bitnami_redmine", :username => "bitnami", :password => "xxxx" ) vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call' vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/engine.rb:484:in `call' vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:231:in `call' vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/railtie/configurabl

ios - From prototype to real APP -

i starter developing own ios app, ran trouble: want work out cool ui, , find lots of tools thinking, seems give prototype design. wondering possible can convert prototype excitable objective-c code. if use xcode , interface builder, no other tool, prototype ready built , run.

javascript - Callback() Node Js -

i'm confused program. bought book called "node js, mongodb, , angularjs web development" brad dayley. found program demonstrate called closure, , shows program example. first part of program. function logcar(logmsg, callback){ process.nexttick(function(){ callback(logmsg); }); } var cars = ["ferrari", "porsche", "bugatti"]; for(var idx in cars){ var message = "saw " + cars[idx]; logcar(message, function(){ console.log("normal callback: " + message); }) } i've been trying figure out how program functions entire hour, can't figure out function of callback(logmsg). i know basic question, can't wrap head around it. callback function pass logcar(). when logcar completes doing whatever supposed do, call callback function. inside loop, call logcar() this.. logcar(message, function(){ console.log("normal callback: " + message); }) here, function

node.js - why mongoose doesn't change mongodb -

my mongdb started by: sudo mongod --port 27111 but mongoose code() doesnt work on mongodb, nothing in mongodb changed mongo shell point of view. $mongo 127.0.0.1:27111/foo -- insert -- mongodb shell version: 2.4.9 connecting to: 127.0.0.1:27111/foo show dbs local 0.078125gb show dbs local 0.078125gb var mongoose = require('mongoose'); var db = mongoose.createconnection('mongodb://127.0.0.1:27111/foo'); var schema = mongoose.schema; var tasks = new schema({ project: string, description: string, }); mongoose.model('task', tasks); var task =mongoose.model('task'); var task = new task(); task.project = 'bikeshed'; task.description = 'paint bideshed red.'; task.save(function(err){ //save if(err) throw err; console.log('task saved'); }); //搜索文档 task.find({"project":

c# - Microsoft Band SDK on Windows Phone 10 -

folks, users seem have issues running 1 of our apps on windows phone 10, os needs "prompt" use of band on first run. don't see way programmatically request permission, , app fails connect unless remove pairing completely, remove app, re-add pairing, , reinstall app. (and then) os prompt use of band, , works. is design? how programmatically prompt permission, , why wp10 os not prompt instead of failing? there additional need in manifest wp10 more wp8.1? thoughts?

javascript - Difference between local and global require in RequireJS -

using requirejs , don't believe understand difference between following 2 different usages of 'require'. in case, talking browser, not node.js. 1 of questions is: can require dependencies synchronously on front-end using requirejs? first there this: define(function(){ //below require global require of requirejs, aliased requirejs. require(['module'],function(mod){ //mod loaded here } }); then there this: define(['require'],function(require){ require(['dep'],function(dep){ //require local not global //dep loaded here } //now require subsequently called 'local' require var dep = require('dependency'); //i doubt possible on front-end..or it? }); i guess don't see purpose of using require argument define on front-end, there one? my confusion arising because of example here: http://requirejs.org/docs/api.html re

multithreading - In java, what happens when deleting an object while it is being used? -

here scenario: i have java hashtable takes string key , object value. one thread gets object using key , calls method on object. while method doing operation step b), thread calls remove on particular key references object. what happens ? should put lock on operation ? nothing happens, assuming you're talking (thread-safe) java.util.hashtable . removing object hashtable has no impact on other references object. objects eligible garbage collection once nothing references them.

set iOS bg images all screen sizes -

i have created background images ios devices. far understand, ios pick appropriate image @ runtime according screen resolutions. is there way set image screen background root view? method should take automatic image picking account. is there way set image screen background root view in storyboard, locate scene representing root view controller , view. drag uiimageview main view , pin top, left, bottom, , right edges of superview constant of zero. send it's behind other subviews of main view. set image desired image, , supply appropriate content mode. done.

php - How Restful Request Public Key and Private Key Works for each request -

i looking @ public key , private key encryption web request. came across api encrypts data using jquery public key requested server , passed server further process. my question how handle such dynamically created public/private key each time. example requesting rsa public key server , encrypt data , pass server, how server know key pair used request. i seeing examples http://www.jcryption.org/ in requests key , passed server decryption, have plenty of requests generate separate key each request how can decode on server side.

openlayers 3 - checking all (visible) layers for crossorigin-parameter and return a variable depending on it -

i'm trying receive variable after checked layers of map on crossorigin-property (if given). in fact want set variable printposs=true/false. as one visible layer doesnt have proper crossorigin-value variable should become possible=true , function/foreach-loop can quit, returning value "outside" thats got alreay poor js-knowledge. seems variable keeps value of last processed layer. jsfiddle here: http://jsfiddle.net/wa5g90xb/3/ (i added browser console-logging) map.getlayers().foreach(function (layer, idx, a) { if (layer instanceof ol.layer.group) { layer.getlayers().foreach(function (sublayer, jdx, b) { var origin = sublayer.getsource()['crossorigin']; var visible = sublayer.getvisible(); var title = sublayer.get('title'); if (visible === true && origin == 'anonymous') { printposs=true; } else if (visible == false) { printposs = true; } else {

mysql - PHP "else" and "if" on code for registration script -

i purchased script while ago (php/mysql) contains user registration form. script has area selection of gender (male or female). 2 options. i want modify code allow selection of animal instead of sex. changed code in applicable places, , works great. problem is, displays animals 1 , 2, since initial code setup "male/female" selection (2). i need find way code allow 15 animals instead of 2 results. here code. "profile_userinfo_gender1" , "gender2" call "gender" or "animal". should go "gender15". please help! thank you! if ($d->u->gender == 0) $d->gender = $this->lang('profile_userinfo_withoutinfo'); else { if ($d->u->gender == 1) $d->gender = $this->lang('profile_userinfo_gender1'); else $d->gender = $this->lang('profile_userinfo_gender2'); } if ($d->u->gender == 0) $d->gender = $this->lang('profile_user

Converting a linked list to a circular list -

first time using site , beginner in c++. have linked list built , trying convert circular linked list it's not going well. give me 2 cents going wrong? thanks. edit: problem is, after attempt connect last node first, display list again , first node seems have been replaced last node. list before: 123456 list after: 623456 #include <iostream> #include "suitornode.h" using namespace std; void getnumsuitors(int& numberofsuitors); void headinsert(suitornodeptr& head, int value); int main() { suitornodeptr head, temp, remove; int numberofsuitors; getnumsuitors(numberofsuitors); head = new suitornode(numberofsuitors); //creates list of nodeswith desired number of suitors (int = numberofsuitors-1; > 0; --i) { headinsert(head, i); } // iterate through list , display each value temp = head; while (temp != null) { cout << temp->getnum(); temp = temp->getnext();

c# - "There is no ViewData item of type 'IEnumerable<SelectListItem>'" error with custom model and list -

i have dropdownlist in view: @html.dropdownlist("sale.typetransaction", viewbag.typetransaction selectlist, new { @class = "form-control" }) as can see, name of dropdownlist sale.typetransaction because sale it's model inside custom model: public class officesale { public officesale() { saleproductrelations = new list<saleproductrelation>(); sale = new sale(); } public sale sale { get; set; } public list<saleproductrelation> saleproductrelations { get; set; } } sale has property typetransaction , string . in controller fill selectlist follows: public actionresult newsale() { var list = new list<selectlistitem>(); list.add(new selectlistitem { text = "cash", value = "cash" }); list.add(new selectlistitem { text = "credit", value = "credit" }); list.add(new selectlistitem { text = "promotion", value = &quo

c# - Saving user scoped settings (ApplicationSettingsBase) -

i trying application settings save when user exits configuration form (not mainform). keep settings in memory because when open form again, have data configured still there, not save disk. filepath saving xml file to c:\users\david_000\appdata\local[company name][project name]\1.0.0.0. i using [userscopedsetting()] in class implements applicationsettingsbase file, should save when call, properties.settings.default.save(); this class uses applicationsettingsbase public class deviceconfiguration : applicationsettingsbase { /// <summary> /// initializes new instance of <see cref="deviceconfiguration"/> class. /// </summary> public deviceconfiguration() : base() { this.masterdevices = new bindinglist<device>(); this.slavedevices = new bindinglist<device>(); } [userscopedsetting()] [settingsserializeas(system.configuration.settingsserializeas.xml)] public bindinglist<device

Calling oracle function from Java JDBC -

we have oracle function trying call jdbc. takes 3 inputs (string, number , date) , returns 1 number: create or replace function mww_avgcost (in_prd_lvl_number prdmstee.prd_lvl_number%type, in_org_lvl_number orgmstee.org_lvl_number%type, in_sales_date prcmstee.prc_from_date%type) return number begin using java jdbc code follows: string call = "{ ? = call pmm.mww_avgcost(?, ?, ?) }"; callablestatement cstmt = conn.preparecall(call); cstmt.registeroutparameter(1, java.sql.types.integer); cstmt.setstring(2, productnumber); cstmt.setint(3, storenumber); // convert xml input sql date java.sql.date sqldate = new java.sql.date(saledate.togregoriancalendar().gettimeinmillis()); cstmt.setdate(4, sqldate); cstmt.execute(); bigdecimal resultfromfunction = cstmt.getbigdecimal(1); log.info("resultfromfunction:" + resultfromfunction); the result returns 1 though , not p

python - scikit-learn: Identification property in clustering dataset -

while performing kmeans clustering in scikit-learn, need feed dataset of shape (n_samples, n_features) . each sample of dataset corresponds user, identified user_id , not feature. so, if feed dataset in format, lose identification info each sample. so, how store user_ids in dataset?

html - How to import GuruFocus 10-year finance data to CSV using JAVA? -

i trying automatically import data gurufocus single or multiple csv sheets using java. sample tables listed here: http://www.gurufocus.com/financials/aapl know how write code import html tables? i create parser using regex on input side in combination http://csvjdbc.sourceforge.net/ on output side. , use apache http cliënt read website (if no api available) here quickstart: https://hc.apache.org/httpcomponents-client-ga/quickstart.html

angularjs - Visual Studio 2015 Hot Towel Angular -

i have installed visual studio 2015 rc1. trying install hot towel angular package. when install receive following messages in output window: installing nuget package hottowel.angular.2.3.3. installed 'hottowel.angular.2.3.3' valueinvestingmentor.web. ========== finished ========== restoring packages c:\users\kruerj\documents\visual studio 2015\projects\valueinvestingmentor\src\valueinvestingmentor.web\project.json writing lock file c:\users\kruerj\documents\visual studio 2015\projects\valueinvestingmentor\src\valueinvestingmentor.web\project.lock.json restore complete, 1741ms elapsed when @ project.json file looks this: { "webroot": "wwwroot", "version": "1.0.0-*", "dependencies": { "microsoft.aspnet.mvc": "6.0.0-beta4", "microsoft.aspnet.server.iis": "1.0.0-beta4", "microsoft.aspnet.server.weblistener": "1.0.0-beta4",

python - How to refer to the curve_fit() (method, function?) of scipy.optimize -

the use of scipy.optimize.curve_fit() has been important in current (astrophysics-related) research project. i'm working on publication want make reference scipy.optimize.curve_fit() in paper. current draft of paper refers curve_fit() follows ...are fit using curve_fit() function in optimize module of scipy. i want make sure use of words "function" , "module" correct. still learning structure of modules, methods, , functions in python , wanted make sure referring them correctly. bonus: scipy website's citation guidelines state: for specific algorithm, consider citing original author’s paper (this can found under “references” section of docstring). as far can tell, curve_fit() has no references specified in docstring, , neither leastsq() relies on heavily. planning on citing general scipy library (as specified in citation guidelines on website) rather specific guideline. there more specific reference can point me to?

android - Radio Button in one radio group in 2 horizontal line -

Image
i try set 4 radio button in 1 radio group in 2 lines, problem when take linear layout horizontal orientation radio group functionality not work . radio buttons select . @ time 1 button should select. <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <radiobutton android:id="@+id/r1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/lbl1" /> <radiobutton android:id="@+id/r2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"

c - Why Does `libusb_bulk_transfer' Return 0? -

i using libusb-1.0. when call: int rc = libusb_bulk_transfer(handle_, ep_in_addr, (unsigned char *)buf_, 64, &read_, 0); it returns rc = 0 (no error) , read_ = 0 (zero number of bytes received). have specified infinite timeout (last argument), isn't `libusb_bulk_transfer' supposed block until have data? sometimes, returns rc = 0 (no error) , read_ == 0 (zero number of bytes received). a bulk endpoint can send packets zero bytes of data, called 0 packets. not error condition.

Jquery- reload doesnt occur if clicked second time -

<li id="rpt21" align=left><a class="keepopen" href="#">trade list buys</a></li> if click on above link 'trade list buys', list gets loaded in right side of screen. however, when click again while on same page, doesnt reload data on right side. looks static. how can ensure reloads every time click. below rpt21 function gets executed. $("#rpt21 a.keepopen").click(function() { $("#report_panel").hide(); $("#report_header").hide(); $("#report_panel_alldata").hide(); $("#report_header_alldata").hide(); var rmanager = $("#rmanager").val(); var manager = $("#manager").val(); var account = $("#account").val(); var folderdate = $("#folderdate").val(); var pricedate = $("#pricedate").val();; x = getdataforrpt(rmanager, manager, account, folderdate, pricedate, "buy_list", "

java - How can I turn off javascript validation (including tern / lint / jshint) for certain folders (such as node_modules) in eclipse? -

i went project properties > javascript > include path > source , excluded node_modules directory. but, when run validation on project still tries validate of javascript files in folder. it's because tern.java doesn't support include/exclude path.

c# - Add Claim On Successful Login -

i need add claim user's identity after successful user login. think needs happen: public async task<actionresult> login(loginviewmodel model, string returnurl, string myclaimvalue) { if (!modelstate.isvalid) { return view(model); } var result = await signinmanager.passwordsigninasync(model.username, model.password, model.rememberme, shouldlockout: false); switch (result) { case signinstatus.success: usermanager.addclaim(user.identity.getuserid(), new claim("myclaim", myclaimvalue)); return redirecttolocal(returnurl); case signinstatus.lockedout: return view("lockout"); case signinstatus.requiresverification: return redirecttoaction("sendcode", new { returnurl = returnurl, rememberme = model.rememberme }); case signinstatus.failure: default: modelstate.addmodelerror("", "invalid login attempt."); return view(model)

c# - Failing to connect to steam with SteamKit2 -

i making trade offer bot in c# using steamkit2, , of time connecting steam. of time freezes when have output "connecting steam..." right before client.connect(); called. happens enough needs fixed, don't know problem is. here code (a lot taken steamkit2 tutorial): using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using steamkit2; namespace ato { class offersender { string username; string password; steamclient client; callbackmanager manager; steamuser user; bool isrunning = false; public offersender() { } public void login() { console.write("please enter username: "); username = console.readline(); console.write("please enter password: "); password = console.readline(); client = new steamclient(); mana

how can i add info to a DB with php when its being dynamically added with javascript? -

i have page adds checkboxes dynamically javascript when hit add button, on every add of checkbox page want save database . im not sure how go doing maybe ajax , php? know how make insert matter of getting call function on every add. javascript $(document).ready(function() { $('#btnsave').click(function() { addcheckbox($('#txtname').val()); txtname.value=""; }); $("#remove").click(removecheckbox); $("#save").click(myfunction); }); function addcheckbox(name) { var container = $('#cblist'); var inputs = container.find('input'); var id = inputs.length+1; $('<input />', { type: 'checkbox', id: 'cb'+id, value: name }).appendto(container); $('<label />', { 'for': 'cb'+id, text: name }).appendto(container); $('<br/>').appendto(container) } html/php $username = "root"; $password = ""; $ho

c# - DataMember property 'relation key' cannot be found on the DataSource -

i have dataset has several tables in c# windows app. have 1 parent table , of other tables in set child tables have relation id column in parent. i added new table , made necessary relation parent table through wizard , designer, not coding. however, when go form , try change datamember on property screen of bindingsource, doesn't find relation created in drop down menu. try manually input name of relation , receive error message listed in title. i've never had issue before when have added child tables dataset , changed datamembers them i'm not sure go here in order resolve issue. assistance awesome. let me know if need more information. edit: should add seems happening 1 dataset. tried adding exact same table different dataset had , worked without issue.

datetime - Is CurrentUICulture.DateTimeFormat different on OS and .NET version? -

i ran following code on 2 different pc's string info = string.format("clr ver. {0}, culture name: {1}, shortdatepattern: {2}", environment.version, thread.currentthread.currentuiculture.displayname, thread.currentthread.currentuiculture.datetimeformat.shortdatepattern); on windows server 2008 r2 .net 3.5, value of info clr ver. 2.0.50727.5485, culture name: english (canada), shortdatepattern: dd/mm/yyyy however, on windows server 2012 .net 4.5, value is clr ver. 4.0.30319.34209, culture name: english (canada), shortdatepattern: yyyy-mm-dd i wondering why currentuiculture.datetimeformat dependent on .net version?? breaking change in .net4.5? you correct default short-date format en-ca changed, of .net 4.0. can test yourself: console.writeline(new cultureinfo("en-ca").datetimeformat.shortdatepattern); running on .net 2 runtime (framework 2.0/3.x) give "dd/mm/yyyy" . running on .net 4 runtime (framework 4.x)

mysql - PHP $wpdb Select? -

i use assistance sql query. have small 3 column table, id, ip, , birthday. id auto increments. i'm trying select birthdays associated specific ip, i'm not sure if sql statement wrote correct. var_dump returns empty array. if check me appreciated. global $wpdb; $query = "select birthday $table ip=$ip"; $results = $wpdb->get_results($query, array_a); var_dump($results); wrap ip address passed mysql single quotes , use actual table name. if resulting array blank, missing ip table.

c - I am trying to read a file and to show the reading progress in %. I have tried following code but I am not able to divide in chunks & show progress -

i trying read file , show reading progress in percentage. have tried out following code not able divide in chunks , show progress. how should show progress? printf("file contains %ld bytes!\n", fsize); buf = (char*) malloc (sizeof(char)*fsize); if (buf == null) { printf("memory error!\n"); return 2; } else { printf("allocating memory!\n"); bytes_read = fread(buf, 1, fsize, pf); printf("number of bytes read %1d",bytes_read); here's rough draft, illustrate replacing 1 fread() use: size_t numtoread = fsize; char* bufptr = &buf[0]; while ( numtoread > 0 ) { int percentdone = 0; size_t numsuccessful = fread( bufptr, 1, 10000, pf ); // choose size bufptr += numsuccessful; numtoread -= numsuccessful; percentdone = ( 100 * ( fsize - numtoread ) / fsize ); // display percentage } disclaimer: have not compiled snippet, please forgive typ

powershell - Rename folders in file share -

the script comparing folder names in share store user profiles in ad , seeing ones disabled or don't exist , counting them. want take list , rename user folders aren't in ad .old . $delusercount = 0 $usernotfoundcount = 0 $foldernames = (get-childitem \\kiewitplaza\vdi\appsense_profiles).name foreach($name in $foldernames) { try { $user = get-aduser $name -properties enabled if($user.enabled -eq $false) { $delusercount = $delusercount + 1 } } catch { $usernotfoundcount = $usernotfoundcount + 1 } } write-host "user disabled in ad count " $delusercount write-host "user id notfound in ad count " $usernotfoundcount how after: $delusercount = $delusercount + 1 insert: rename-item "\\kiewitplaza\vdi\appsense_profiles\$name" ` "\\kiewitplaza\vdi\appsense_profiles\$name.old" update: you want insert after foreach statement: if($name

vba - EXCEL: Automatically populating cells from websites requiring a login and where the information is not directly stored in tables -

i trying write vba code in excel file fetch data company's intranet site (which requires login). i doing part of company project , need excel auto fetch these fields (numbers) portal. i did research , found relevant code helps automate login process, each field need fill i.e cells under column c row 1, need first fetch unique web link column row 1, on , forth. sub gettable() dim ieapp internetexplorer dim iedoc object dim ietable object dim clip dataobject 'create new instance of ie set ieapp = new internetexplorer 'you don’t need this, it’s debugging ieapp.visible = true 'assume we’re not logged in , go directly login page ieapp.navigate "http://severe-frost-552.heroku.com/login" while ieapp.busy: doevents: loop until ieapp.readystate = readystate_complete: doevents: loop set iedoc = ieapp.document 'fill in login form – view source browser control names iedoc.forms(0) .login.value = "dailydose" .password.value = "pass

python - Check if string is in a pandas dataframe -

i see if particular string exists in particular column within dataframe. i'm getting error valueerror: truth value of series ambiguous. use a.empty, a.bool(), a.item(), a.any() or a.all(). import pandas pd babydataset = [('bob', 968), ('jessica', 155), ('mary', 77), ('john', 578), ('mel', 973)] = pd.dataframe(data=babydataset, columns=['names', 'births']) if a['names'].str.contains('mel'): print "mel there" a['names'].str.contains('mel') return indicator vector of boolean values of size len(babydataset) therefore, can use mel_count=a['names'].str.contains('mel').sum() if mel_count>0: print ("there {m} mels".format(m=mel_count)) or any() , if don't care how many records match query if a['names'].str.contains('mel').any(): print ("mel there")

sql server 2008 - cumulative totals based on condition -

i trying cumulative totals based on criteria. below dummy sample data set. cumulative time based on indicator id . when indicator continuously 1 same id , sum of duration . if becomes 0 restart. id duration indicator cumm_duration 1 30 0 30 1 30 1 60 1 30 0 30 1 30 0 30 1 30 1 60 1 30 0 30 1 30 0 30 1 30 0 30 1 30 0 30 1 30 0 30 1 30 0 30 1 30 0 30 1 30 1 60 1 30 1 90 2 30 1 30 2 30 0 30 2 30 0 30 2 30 0 30 2 30 1 60 2 30 0 30 2 30 1 60 2 30 0 30 2 30 0 30 2 30 0 30 2 30

Javascript performance of indexing -

is following line considered unoptimal, considering being used in many places or inside of loop: var age = myobject[index]["person"]["identity"]["bio"]["age"] even if hash lookup in javascript o(1) (i don't know sure), you'd still have overhead of lookup operations. so, yes, suboptimal big loop.

python - Replacing Strings in Column of Dataframe with the number in the string -

i have dataframe follows , want replace strings in maturity number within them. example, want replace fzcy0d 0 , on. date maturity yield_pct currency 0 2009-01-02 fzcy0d 4.25 aus 1 2009-01-05 fzcy0d 4.25 aus 2 2009-01-06 fzcy0d 4.25 aus my code follows , tried replacing these strings numbers, lead error attributeerror: 'series' object has no attribute 'split' in line result.maturity.replace(result['maturity'], [int(s) s in result['maturity'].split() if s.isdigit()]) . hence struggling understand how this. from pandas.io.excel import read_excel import pandas pd import numpy np import xlrd url = 'http://www.rba.gov.au/statistics/tables/xls/f17hist.xls' xls = pd.excelfile(url) #gets rid of information dont need in dataframe df = xls.parse('yields', skiprows=10, index_col=none, na_values=['na']) df.rename(columns={'series id': 'date&#

Scala try and catch Error -

so here code: def loadoperation(filename:string): csvlist = { try{ val pattern = """^(.+);(\d{5});(4|2|31);(0|1);(.+);(\d+|\d+,\d+)$""".r source.fromfile(filename).getlines().foldleft(list[csventry]())((csvlist, currentline) => currentline match { case pattern(organisation,yearandquartal,medkf,trueorfalse,name,money) => new csventry(organisation,yearandquartal.toint,medkf.toint,trueorfalse.toint,name,money) :: csvlist case default => csvlist }) } catch { case one: java.io.filenotfoundexception => println("this file not found!") }} the problem code doesnt work, shows following error: type mismatch found: unit required csvlist expands list[csventry]? how can solve problem? the problem catch clause: println("this file not found!") has type unit , not csvlist . should add additional line returns empty list, such as catch { case one: java.io.filenotfoundex

javascript - How to get the image by ID from image Slider and store it to the cookies? -

i have image slider of 5 pics in home page in asp.net mvc application. when user click on other menu tab within application last seen image of image slider should stored in cookies. when user come homepage,image slider start last seen image . chtml: <div id="sliderframe"> <div id="slider"> <a id="image1" href='#' class='linkdisabled'> <img src="~/content/internal/images/image1.jpg" alt="" /> </a> <a id="image2" href='#' class='linkdisabled'> <img src="~/content/internal/images/image2.jpg" alt="" /> </a> ..... i thinking of overwriting images id in cookies , when user homepage last stored image in cookies shown in image slide. how image id , store cookies? please help. first, container of links , collection of links inside container var slider = document.getelementbyid("slider