Posts

Showing posts from August, 2014

Simple C code keeps crashing -

so code did: #include <stdio.h> #include <stdlib.h> int main() { char playername; int playerage; printf("what's name, , age?\nyour name: "); scanf("%s\n", playername); printf("your age: "); scanf("%d\n", &playerage); printf("okay %s, %d years old!", playername, playerage); return 0; } and everytime run it, after input name crashes , don't know how fix it. these 3 things appear when closes: format '%s' expects argument of type 'char *', argument 2 has type 'int' [-wformat]| format '%s' expects argument of type 'char *', argument 2 has type 'int' [-wformat]| 'playername' used uninitialized in function [-wuninitialized]| what mistake? scanf("%s\n", playername); wrong because %s call char* data playername here type char . you have make playername array of characters , set max length of input avoid buffer overflow. #in

c# - Visual Studio - Corrupted .xaml file -

Image
recently i've put computer sleep, , when started up, computer turned off. before open file, asks me encoding. i've tried multiple, , auto-detect. no luck. later when turned on, mainwindow. xaml looked this: the mainwindow. xaml.cs surprisingly fine, , registers variables written in xaml file. other xaml files in project fine. when hover on lines, error shows: the value "□" not valid character does know if mainwindow.xaml salvageable or lost cause? thank lot answers. clear shadow cache , restart visual studio. should fine. shadow cache located at c:\users\username\appdata\local\microsoft\visualstudio\12.0\designer\shadowcache delete shadow cache corresponding visual studio version , restart it. should working fine.

Swift Array intersection by property -

i trying compare 2 arrays. 1 array array of person objects, each of has email property string email address. other array emailaddress object has descriptive word "work" or "personal" , actual string email address. basically both objects have string property email address. want compare these arrays of objects see if 1 of objects each array has same email address. right using nested for loops shown below taking long. for person in self.allpeople! { e in emailaddresses! { if e.value == person.email { return true } } } i thought using set intersection looked work comparing same objects , not object's properties. thanks. you can still use set functionality first creating set of emails. map helps turn 1 collection another, in case changing collection of allpeople collection of people's email s. faster because emailaddresses iterated once, instead of once per person . let personema

opengl - Make Camera Look at point using a world transformation matrix? -

variants of question might have been asked on site, none of answers found worked in case. i trying make camera @ point. camera has world transformation matrix, used calculate front vector, eye position when making view matrix finally. camera treated other object in scene , has world transform. want able modify world transform, , should automatically affect camera. want modify world transform of camera "lookat" point. for this, modify rotation term of world transform ( r in t * s * r ) this: void worldtransform::setlookat( float x, float y, float z ) { vec3 lookpoint = vec3 ( x, y, z ); vec3 lookdir = normalize( lookpoint - m_position ); float looklengthonxz = sqrtf( lookdir.z*lookdir.z + lookdir.x*lookdir.x ); m_rotationx = degrees(atan2f( lookdir.y, looklengthonxz )); m_rotationy = degrees(atan2f( lookdir.x, lookdir.z )); rotateabs( m_rotationx, m_rotationy, m_rotationz ); updatematlocal( ); } basically, have function can set

reactjs - "setState on undefined" this error trying to use es6 style react component in yahoo fluxible -

edit: mistake, webpack hotloader caching old js reason every time ran build. reset , rebuilt , seems working now. i'm trying create simple searchbox using es6 style class declaration in yahoo fluxible react app. i'm working off todo example, converting es6 style syntax , i'm getting error on this.setstate in _onchange method. i've bound functions "this" in constructor i'm still getting error. import react 'react'; import searchproducts '../actions/searchproducts'; const enter_key_code = 13; class searchbox extends react.component { static contexttypes = { executeaction: react.proptypes.func.isrequired }; static proptypes = { text: react.proptypes.string }; static defaultprops = { text:'' }; constructor(props) { super(props); this.state = { text: props.text }; this._onchange = this._onchange.bind(this); this._onk

c# - Convert List to single string -

trying convert list property string, ideas? public class contactlog { public string { get; set; } public string message { get; set; } public string formattedmessage { { return to+ ',' + message; } } } public void sendbatch(list<contactlog> logs) { //problem line string messages = createbulkmessage(logs.select(o => o.formattedmessage)); } public string createbulkmessage(string message) { //do stuff } you can use string.join combine results of select 1 string : string messages = string.join(", ", logs.select(o => o.formattedmessage));

Is there a Mysql function to see if there's one result or more than one result MySQL query? -

we're writing code match submissions people. given first name, last name, etc. try narrow down single result. however, submissions addresses or other contact info might spelled wrong, prefer match on few criteria possible--hence multiple steps finding match. here's algorithm: count first name , last name if count == 1 // done if count > 1, count first name, last name, email if count == 1 // done // etc. what best way tell if we'll 1 person result or not given query? the obvious answer count, unnecessary since don't need number, need see if it's plural results or singular result (the matching may bad enough return count of thousands). option limit 2 results, minimizes counting, adds confusing code (why count if it's limited well?) is there preferred method doing this? mysql not have function tell if have 1 match or more. options, said, count(*) or use limit 2 . the limit option should faster execute, going assume performance differe

ruby on rails - Update parent object when child objects meet certain condition -

Image
i have 2 models - order , item: order.rb: class order < activerecord::base has_many :items end item.rb: class item < activerecord::base belongs_to :order end schema item: t.decimal "price", precision: 12, scale: 3 t.string "status" schema order: t.string "status" item's status marked shipped when user received items. how can update order status "complete", in condition items' status updated "shipped"? you need update items table include foreign key , relating orders : $ rails g new migration addorderidtoitems #db/migrate/add_order_id_to_items______.rb class addorderidtoitems < activerecord::migration def change add_column :items, :order_id, :integer end end $ rake db:migrate you can read more why important here : - this allow following: #app/models/order.rb class order < activerecord::base has_many :items, inverse_of: :order end #app/models/

rest - MessageBodyWriter not found for media type=application/x-protobuf -

i want use protobuf in rest application. when running app, giving me following error.. messagebodywriter not found media type=application/x-protobuf i have placed these files in same package using these. new both rest , protobuf, not getting exact problem. per many blogs mentioning @provider or @consumer enough jersey catch custom messagebodywriter. please me issue.. the code using follows - string response = webtarget.path("auth").request(mediatype.text_plain) .post(entity.entity(login, "application/x-protobuf") ,string.class); and resource - @post @produces(mediatype.text_plain) @consumes("application/x-protobuf") public string authentication(login login) { return login.getusername().touppercase(); } detailed log follows - severe: servlet.service() servlet [login] in context path [/webapp] threw exception org.glassfish.jersey.message.internal.message

java - Trying to calculate the distance between the position of two objects -

i have these 2 instance variables set within constructor of object be: (int)(math.random()*100); the 2 instance variables are: private double xpos; private double ypos; the class called soldier , have 3 other classes inherit soldier, (only constructor @ moment) the output getting @ moment is: my name is: cavalier @ position: (45.0,56.0) my name is: crossbowman @ position: (15.0,91.0) my name is: halberdier @ position: (67.0,8.0) i trying calculate distance in x , y positions of objects the method trying is: protected soldier distancebetween(soldier x, soldier y){ double distbetween = (x.xpos - y.xpos)+(x.ypos-y.ypos); return this; } the method trying achieve 2 objects inherit soldier taken distbetween paremeters, example use names: halberdier, cavalier , crossbowman. when call method: cavalier.distancebetween(cavalier,crossbowman); i want calculate distance between x , y coordinates how achieve this?

g++ - Why after compile c++ code with -O3 flag function generate wrong output? -

when in main function write function fun; fun.addname("string1"); std::cout << fun.getnumberofindeks(); i see on screen 2 different numbers: 1 (error) when g++ have -o3 flag 0 when g++ have -o0 flag below definition of class , methods: class ifunction { public: virtual void addname(std::string nazwa_funkcji) = 0; virtual std::size_t getnumberofindeks() = 0; }; class function: public ifunction { public: function(); void addname(std::string nazwa_funkcji); std::size_t getnumberofindeks(); private: std::vector<std::unique_ptr<std::string>> vp_nazwy_indeksow_; std::unique_ptr<::std::string> p_nazwa_; } function::function():p_nazwa_(new std::string("")) { } std::size_t function::getnumberofindeks() { vp_nazwy_indeksow_.size(); } void function::addname(std::string nazwa_funkcji) { std::unique_ptr<::std::string> pl_nazwa_funkcji (new std::string(naz

sql - VB.net Faster way of creating folders, subfolders and Excel files within those folders -

i'm using vb 2010, sql server 2012 excel 2010. the users @ company have requirement use specific excel report hospitals , doctors. i have table in sql server contains data , name of person assigned hospital/doctor office, hospital name , lastly address of hospital name/doctor office. the folders can have following structure: c:\test\assignee name\hospital name\hospital or doctor address\hospital or doctor address.xlsx alternatively hospital name blank ending following structure: c:\test\assignee name\hospital or doctor address\hospital or doctor address.xlsx here code have until now, takes 4 hours 4 of these assignee folders , reports generated. i need have 26 assignee folders, 3831 subfolders, 7281 files. i'm looking faster way of doing this, please. here code: private sub create_cqm_folders_vb() private sub create_cqm_folders_vb() dim t1 datetime = datetime.now dim t2 datetime dim duration timespan dim connectionstring strin

css - Border-top Extending too far -

i've got interesting one: testing methods list-item elements of nav bar spread evenly across length of nav. used display:table , display: table cell method spread , seemed work fine. when went add ::after element add top-bar , have smoother on-hover effect, found bar extended past wanted -- trying have end of words "communication design". thought i'd resize nav container holding list-elements because it's table/table-cell, when nav resizes, list-items shink along , can never shore last element in list. is there way either affect size of last table cell or show percentage of ::after element? code: html: <h3>test & co.</h3> <p id="title2">communications design</p> <div id="navcontainer"> <ul> <li>home</li> <li>about</li> <li>work</li> <li>contact</li> </ul> </div> css: * { padding: 0; margin: 0; } h3 { padding-

javascript - How to correctly use lodash pick method -

i'm attempting use underscore filter out properties of object. beginning of following code works expected, .pick not working. i'm aiming limit properties of returned object strings listed in .pick method. var result = _.chain(data) .each(function(item) { item.answers = []; _.each(data, function(object) { if (item.id === object.id) { item.answers.push({ id: object.answer_id, email: object.answer_email, date: object.answer_date }); } }); item = _.pick(item, 'id', 'owner_id', 'url', 'enabled', 'review_date', 'answers' ); }) .uniq(function(item) { return item.id; }) .value(); the array start with, 'data', looks this: [ { id: '8ffdf27b-5a90-478a-b263-dhhdhdhhdhd', answer_date: fri oct 30 2015 14:35:07 gmt-0400 (edt), answer_id: 1, answer_email: 'test@example.co

cordova - phonegap build android does nothing -

i have phonegap cli application until working fine , able publish google play store in alpha testing mode. so in www directory did 'phonegap build android' , in platforms/android directory did 'ant release' create signed release apk. i've been forced upgrade phonegap version, google play store rejected latest submission no longer supported level using (i think 3... something). so, when 'phonegap -v' 5.3.6. when i'm in www directory , 'phonegap build android --verbose' get: [phonegap] executing 'cordova build android --verbose'... [phonegap] completed 'cordova build android --verbose' with no time @ between first line , second line, no verbose output , no apk output! any idea going wrong? thanks graham its seems related nodejs 5.0... in case cordova build command seems failling since update. after investigation can pass problem running "build script" in platform/build folder ./platform

How can i iterate over a basic blocks in a specific routine in intel pintool? -

i tried iterate on basic blocks in specific routine, found problems: void routine(rtn rtn, void *v) { rtn_open(rtn) (bbl bbl = rtn_bblhead(rtn); bbl_valid(bbl); bbl = bbl_next(bbl)) { /* code */ } rtn_close(rtn); } error: deprecated-declarations, how can fix error, or way ? you have deprecated-declarations warning because rtn_bblhead deprecated. use rtn_inshead instead. from include\pin\gen\image.ph : /* not edit */ /* rtn_bblhead deprecated. see rtn_inshead. */ extern pin_deprecated_api bbl rtn_bblhead(rtn x); this mentioned in documentation: rtn_bblhead you can pass -wno-deprecated-declarations gcc suppress warning. edit remember pin above dbi (dynamic binary instrumentation) framework: extremely when comes instrument executed code flow, , less when needs break down non executed code. routine instrumentation lets pintool inspect , instrument entire routine when image contained in first loaded' documentation points: a pintool

mysql - Should I store additional data in SQL join/junction table? -

are there drawbacks storing addition data in join/junction table. for example, working on database of trucking companies , have 3 tables: table 1 - company, table 2 - trailer_type, table 3 - junction_table, each company can have more 1 trailer type, need trailer count of each trailer type per company. logic place put trailer count seem in junction table company.id , trailer_type.id. are there drawbacks doing way , if there better way? from way phrased question, think intuition correct. identified junction table place keep counts. you're hesitating, apparently because it's "junction table". all tables created equal. point of view of sql, there no fact tables, no dimension tables, no junction tables. there tables. a normalized design denotes minimal key identify each row. in case, natural key of junction table {company_id, trailer_type_id}. there information that's functionally dependent on key? why, yes, there is: ntrailers . colu

vba - Visual Basic - Selection start / end position -

Image
im stuck on problem visual basic. need start , end of selection, in example on image should 12/19. couldnt find on internet.. guess im stupid... hope can me not clear question, looks textbox control on userform. if that's case, can start , end of current selection using selstart , sellength properties: dim p1 long p1 = textbox1.selstart dim p2 long p2 = p1 + textbox1.sellength

How come a GCM permission isn't granted on Android 6? -

background i'm trying investigate app @ office needs change permissions, in order support android 6 nicely. the problem i've found permission needs confirmation , isn't, except 1 : <uses-permission android:name=".permission.c2d_message"/> it seems permission isn't mentioned anywhere for, 1 that's not granted automatically , yet can't find user can enable confirmation. what tried in order find permissions granted default , aren't , called code: private void checkpermissionsofapp(string packagename) { packagemanager pm = getpackagemanager(); try { final applicationinfo applicationinfo = pm.getapplicationinfo(packagename, packagemanager.get_meta_data); log.d("applog", "listing permissions of app packagename: " + applicationinfo.packagename); packageinfo packageinfo = pm.getpackageinfo(applicationinfo.packagename, packagemanager.get_permissions); //get permissions

c# - MaxCounters codility understanding -

i have wanted try challenges on codility , started beginning. assignments relatively easy 1 called maxcounters. not believe 1 hard although first 1 marked not painless. i have read task , started coding in c# language: public static int[] maxpart(int n, int[] a){ int[] counters = new int[n]; for(int = 0; < a.length; i++){ for(int j = 0; j < counters.length; j++){ if(a[i] == counters[j] && (counters[j] >= 1 && counters[j] <= n )){ counters [j] = counters [j] + 1; } if(a[i] == n + 1 ){ int tmpmax = counters.max (); for(int h = 0; h < counters.length; h++){ counters [h] = tmpmax; } } } } return counters; } having 3 loops of course makes slow, lets leave later. concern how understood , other people see on question here . from assignment's description. it has 2 actions: increas

python - Converting an array of strings into an array of ones and zeros -

i have array looks this: x = ['green', 'red', 'red', 'red', 'green', ...] i want create new array y that: y = [1, 0, 0, 0, 1, ...] i have tried following , not work: for n in x: if x[n] == 'red': p = 0 if x[n] == 'green': p = 1 y.append(p); typeerror: list indices must integers, not str you can create dictionary of desired mappings , map list . more flexible if have lot of cases. in [8]: x = ['green', 'red', 'red', 'red', 'green'] in [9]: d = {'green':1, 'red':0} in [10]: map(d.get, x) out[10]: [1, 0, 0, 0, 1]

jquery - Call WebAPI from HTML5 page -

Image
i trying bind json response webapi call in html5 page. not sure off. webapi returns json: { "id": 1, "date": "2015-10-26t00:00:00", "status": "initiated", "action": { "verificationactiontypeid": 0, "verificationactiontype": null, "verificationactiontakenid": 0, "verificationactiontaken": null, "verficationactioncreatedate": "0001-01-01t00:00:00", "emailaddress": null, "notes": null }, "actions": [ { "verificationactiontypeid": 0, "verificationactiontype": "perform rinse flowcell", "verificationactiontakenid": 0, "verificationactiontaken": "skip", "verficationactioncreatedate": "2015-10-26t10:04:05.093", "emailaddress": null, "no

c# - converts varchar to int while i am inserting to an sql table -

i have table, have named users, , whenever user using sign form want insert users.table credentials enters. problem that, somehow, database trying convert username(column) varchar int. insert query : string query = "insert users(firstname, lastname, username, password, role, email, class) values('" + txtfn.text + "', '" + txtsn.text + "','" + txtusername.text + "','" + txtpassword.text + "', '" + cbrole.text + "','" + txtemail.text + "','" + cbclass.text + "')"; the error pops-ups everytime user trying sign up how can prevent conversion happening or other way deal error? in advance. here how use sql parameters , specify types. safier , more precise , handle conversions types (such datetime): string query = "insert users(firstname, lastname, username, " + " p

python - Datetime - String Round Trip -

this question has answer here: convert timestamps offset datetime obj using strptime 3 answers this gets me string. how go datetime object can date arithmetic , such? from datetime import datetime, timezone s = datetime.now(timezone.utc).astimezone().isoformat() this code snippet produces string happy with, how datetime ? 2015-11-01t07:49:35.106745-08:00 this works, lot busier see. dt = datetime.strptime(s[:-3]+s[-2:], "%y-%m-%dt%h:%m:%s.%f%z") print(dt)

ios - When can auto layout infer width and horizontal position? -

Image
i'm trying lay out following simple ui using auto layout: so far, i've set 5 constraints: the left edge of textfield constrained left alignment guide the top edge of textfield contained top alignment guide the right edge of label constrained right alignment guide the top edge of label constrained top alignment guide the right edge of textfield constrained 20 points leading edge of label based on these constraints, think width of textbook determined size of label, , horizontal layout both implied. indeed how these constraints behave when change size of button, i'm still receiving following warning in xcode: my question why? width , horizontal position can determined information provided, , providing additional information (like fixed width) mess flexibility of interface. well width can't calculated based on constraints applied. both textfield , label grow , shrink based on content. what happen if @ runtime add more text or increase text

java - Create shortcut with minimized window -

good morning, have java code using jshortcut, problem can not create shortcut minimized window, try looking properties windowstyle, find nothing. code. public void createdesktopshortcut() { try { link.setfolder(jshelllink.getdirectory("desktop")); link.setname("ie"); link.setpath(filepath); //windowstyle = 7 link.save(); } catch (exception ex) { ex.printstacktrace(); } } how can add option?

python - Creating a new list from 2 lists based on the index return from a third list -

say have following lists (python 3): numbers = [1,2,3,4,5,6] letters = [a,b,a,b,c,c] state = [false, false, false, false, false, false] what looking receive 2 inputs user 2 index positions within range of length of list letters. if case choices correspond matching letters such , (index 0 , 2), there must change in list state false true said positions. afterwards, should create new list depending on new state list, getting index item numbers if element in state false , getting index item list letters if state true: choice = 0 choice_2 = 2 if letters[choice] == letters[choice_2]: change state[choice] , state[choice_2] true create fourth list list state , use values numbers , letters in range(len(state)): if state[i] == true: element in index[i] of list letters used else: element in index[i] of list numbers used creating new list such that: new_list = [a,2,a,4,5,6] numbers = [1,2,3,4,5,6] letters = ["a","b","a",

c# - Get a substring from a string using regex -

i have many strings in format: fdg.sdfg.234fdsa.dsf_1.2.5.62.xml 23432ssdfsa_sadfsd_1.2.7.6.xml 3.3.3asdf_ddd_1.2.1.doc i number from: fdg.sdfg.234fdsa.dsf_1.2.5.62.xml get: 1.2.5.62 from: f23432ssdfsa_sadfsd_1.2.7.6.xml get: 1.2.7.6 from: f3.3.3asdf_ddd_1.2.1.doc get: 1.2.1 etc this code works: string test = "4534534ghgggg_1.1.3.4.xml"; int = test.lastindexof('.'); int = test.lastindexof('_') + 1; console.writeline(test.substring(from,to - from)); but want know how can regex. ideas? this code seems work long numbers looking preceded "_". edited - final working result // fdg.sdfg.234fdsa.dsf_1.2.5.62.xml // 23432ssdfsa_sadfsd_1.2.7.6.xml // 3.3.3asdf_ddd_1.2.1.doc string source = "fdg.sdfg.234fdsa.dsf_1.2.5.62.xml"; var match = regex.match(source, @"_[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)*").tostring().replace("_", ""); console.write

php - How does running an application on a Vagrant instance through PhpStorm work? -

Image
so, i'm trying set breakpoints , code stepping in phpstorm run/debug configuration runs on vagrant/virutalbox instance. however, gaps in understanding how phpstorm integrates vagrant impeding me getting work. follows current theory of how integrating phpstorm vagrant instance works , questions have. if take time correct/expand theory and/or answer questions follow, helpful. theory: phpstorm can run code in vagrant instance , via ssh tunnel. access vm required breakpoints function because phpstorm needs know server in terms of execution in order know when stall. q1: can ssh vm clicking "start ssh session" , selecting directory containing vagrantfile. when this, cli vm opens in bottom of ide. need ssh'ed vm in manner in order breakpoints work? q2: vagrant instance configured run application code on host name via port. still need hit "run" in phpstorm in order code run in such way breakpoints hit? if so, should run/debug config on same port

Getting contents of indesign text frame through applescript -

i trying form applescript read contents of 1 text frame in indesign , if frame contains character "/" move text frame. figured out how make other text frame move, cannot figure out way make applescript "read" in first text frame , search character. here have far... tell application "adobe indesign cs6" tell active document set horizontal measurement units of view preferences inches set vertical measurement units of view preferences inches repeat x 1 count pages set thispage page x tell thispage if (get text frames name of applied object style "box1") contains character "/" move (get text frames name of applied object style "box2") {-1.245, 0} --relative move x, y end if end tell end repeat end tell end tell i either no error won't or else gives me compiler errors. please help! thank you

vscode extensions - Can I Extend an Existing Colorizer or Language in VS Code -

what i'd create extension extends html support - html support , more, includes following: syntax highlighting (colorizer) intellisense format html emmet snippets these details listed on page html programming in vs code ultimately create extension supports liquid templating syntax highlighting , auto complete. i've gotten #1 work on it's own colorizer, , #2 can accomplished through language server. since liquid expressions inserted html documents, plugin should built top of/extend html support rather override it. possible? it doesn't possible extension. looking @ source code src\vs\languages\html\common , if want extend existing built in language support, can create class extension. for example, handlebars language support extension of html , implemented thusly: // handlebars.ts import htmlmode = require('vs/languages/html/common/html'); export class handlebarsstate extends htmlmode.state { ... } export class handlebarsmode exte

Error in C++ code logic -

i given graph consisting of n nodes , m edges. pair of nodes u, v called if , if can go node u v , return v u without using edge more once. need add @ 1 edge graph make pairs of nodes good. added edge can between 2 vertices connected edges. not allowed add self loops (edge node n node n). guaranteed graph connected. input n , m in first line. each of next m lines contains 2 space separated integers x , y, denoting there edge between node x , y. output output "yes" (without quotes) if possible make pairs of node adding @ 1 edge. output "no" (without quotes) otherwise. example` input: 4 4 3 2 1 3 2 1 1 4 output: yes my logic: count edges not create cycle end. eg: edge(1,4) in above example. this, count instances of particular node in input , if equal 1, particular node end. if have more 2 ends, answer "no". my code: #include <cstdio> #include <iostream> using namespace std; int main() { int n,m,num[100010] = {0},temp1,t

c# - Properties Palette - Type Selector Event -

is there way determine user interacting type selector of properties palette? i see these journal entries: ' 0:< unnecessary nesting;d:\sunrise\2016_px64\source\revit\desktopmfc\ui\propertiespaletteview.cpp;1741;id_change_symbol ;n++eb(nb); ' 0:< appendable opton;-;d:\sunrise\2016_px64\source\revit\desktopmfc\ui\propertiespaletteview.cpp;1144;ids_modify_type_attrib ;n--ob(nab); but it's hasn't been enough of clue tell me how might notified of event. jeff i not believe there direct notification of specific interaction ui point of view. if user makes modification element, including , not limited specific ui interaction, can notified hooking in dynamic model updater framework dmu: http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.31

binaryfiles - how to open and read a binary file in C++ by a given bin file? -

is there me check did wrong? or explain why? beginner , tried best open binary file. runs out "file open" "0". nothing came out. the objective: count3s program opens binary file containing 32-bit integers (ints). program count number of occurrences of value 3 in file of numbers. objective learn opening , accessing files , apply knowledge of control structures. name of file containing data used program "threesdata.bin". my code below, please me if know it. thank in advance! #include <iostream> #include <fstream> using namespace std; int main() { int count=0 ; ifstream myfile; myfile.open( "threesdata.bin", ios::in | ios :: binary | ios::ate); if (myfile) { cout << "file open " << endl; cout << count << endl; } else cout << "cannot open it" << endl; return 0; } first of should read file opened in binary mode myfile.read (buffer,lengt

Running Visual Studio Load Test From Build Definition -

i created build definition runs automated tests using mtm build environments , test suites. created visual studio load test, can added test suite test method marked [testmethod] attribute. however, when run build, no errors , appears aggregate tests don't run. there way make work? i found article: https://blogs.msdn.microsoft.com/testingspot/2013/01/22/how-to-automatically-run-a-load-test-as-part-of-a-build/ describes way it, can't find build template matches describes, , appears allows run single load test. also, when configure test controller, there option configure load testing, this, must unregister team project collection. if done, appears controller can no longer used in environments run project automated tests. defeats purpose of want , makes seem load tests , team projects mutually exclusive. case? if so, big oversight. load tests kind of thing run automatically. help. you unfortunately right. test controller used load testing cannot used othe

How to remove a specific job from Redis job queue -

i'm new redis rudimentary question. i'm considering creating redis job queue using list. jobs json-encoded objects. i realize can use lpop , rpush managing queue. can use rpoplpush when using multiple lists (e.g "queued", "processing" , "completed"). let's have worker processes images steadily going through "queued" list. let's client has deleted image front-end, before particular job has begun process. how delete job "queued" list worker doesn't waste time processing it? in other words, how can index individual jobs in job queue?

Template Haskell - How to lookup type operator name? -

how lookup type operator name? not work: issueth.hs: {-# language templatehaskell #-} module issueth import language.haskell.th f :: q [dec] f = n <- lookuptypename "ghc.typelits.*" return [] issue.hs: {-# language templatehaskell #-} module issue import issueth $f ghc issue.hs fails message: pattern match failure in expression @ issueth.hs replacing "ghc.typelits.*" "ghc.typelits.(*)" or "*" doesn't work either. i guess have enough brief answer. alas found reason problem, not how solve it. my testing shows lookuptypename does support type operators, if start : . originally requirement, in analogy infix data constructors, lifted allow things arithmetical type operators in ghc.typelits . (the downside can no longer have type operator variables , once popular things arrow code.) presumably lookuptypename not updated take account, , have filed bug report this. edit: fix has been made, , sh

java - HikariCP with Kerberos JDBC for Connection Pooling -

my application runs spring framework , have connected hive server kerberos authentication along hikaricp. i looked examples of spring security kerberos not relate hikari cp. following code getting connections drivermanager. how use datasource , hikaricp ? private string gethadoopjdbcurl() throws ioexception { system.setproperty("javax.security.auth.usesubjectcredsonly", "false"); system.setproperty("java.security.krb5.conf", enviroment.getproperty(kerberos_config_file)); org.apache.hadoop.conf.configuration configuration = new org.apache.hadoop.conf.configuration(); configuration.set("hadoop.security.authentication", "kerberos"); configuration.set("hadoop.security.auth_to_local", connectiondetails.getsecurityauth()); usergroupinformation.setconfiguration(configuration); if (!(connectiondetails.getkerberosusername().equalsignorecase(utility.empty_string) || connectiondetails.getk

javascript - jQuery Ajax POST not returning with PHP variable -

i have following function: $(window).scroll(function() { if(ready && labelstatus && $(window).scrolltop() + $(window).height() > $(document).height() - 100){ $('#bottom2').html(loading); ready = false; $.ajax({ url: 'scripts/nearbothome.php', data: {"currentnumber": botnumber, "usersid": usersid}, type: 'post', success: function(data) { botnumber = "<?php echo $uniqueend; ?>"; alert("<?php echo $uniqueend; ?>"); $('#oldposts').append(data); $('#bottom2').html(bottom); ready = true; labelstatus = data; if (data < 1) { labelstatus = false; } } }); } }); this works fine , intended except setting variable 'botnumber' new value. php variable it's supposed set should returned .php file executed ajax ($uniqueend). see here: <?php //open database connection include("../db.php&

asp.net - Close Image and Embed code in String Format (ASP) -

my codes in "item template - asp:repeater element" when try print them in page (aspx) embed video player can not displayed if image displayed already. think happening cause of not closed tags (image , embed tags). how can close elements in stringformat. i'm newbie @ programming , sorry bad english. here codes: <%#(string.isnullorempty(eval("image").tostring()) ? "" : string.format("<img class='img-thumbnail' style='margin-top:15px !important; margin-bottom:15px !important; width:300px; margin: 0 auto;' src='http://example.com/image/{0}'" , eval("image").tostring()))%> <%#(string.isnullorempty(eval("embed").tostring()) ? "" : string.format("<iframe style='margin-left: 20px;' width='300' height='169' src='https://www.youtube.com/embed/{0}'" , eval("embed").tostring())) %> i think re missing > :

How to make SFSafariViewController open link in new Window (IOS Development) -

after implemented sfsafariviewcontroller . when navigatin through web site contains link target=_blank or javascript window.open link opened in same view, open in view, or make create windows automatically! safari view controller not support windows. better off making own mini web browser using wkwebview total control , customisation apple specifies in docs: https://developer.apple.com/library/ios/documentation/safariservices/reference/sfsafariviewcontroller_ref/

scope - mutation inside a function in javascript -

n00b question here: suppose call function updates number or string this var x = "well"; var helloify = function(str){ str += "hello" }; i'd expect behavior: helloify(x); console.log(x) \\ "well hello" but instead get \\ "well" doesn't "+=" change value of "x"? change persist in scope of function not in global environment? thanks! --confused when call helloify(x); pass value of x (a string) not reference x . str += "hello" modifies str , leaves x alone. nb: objects addressed reference, if x had been reference object have modified single object addressed both variables. simple strings not objects though.

python - Set PYTHONPATH for cron jobs in shared hosting -

i had issues running python script on shared hosting (bluehost), , of other threads able set pythonpath , run script no issues. now need run script via cron job. cron jobs in shared hosting environment 1 line can call script, can't figure out how set pythonpath before calling script. example: python /path/to/my/script.py i sure issue should common couldn't find answer in other threads. any idea how set pythonpath cron jobs? also codebase developed in local environment , server gets copy through git pull. preferred solution not change source code server. it's ok call script cron job calls main script , set variables there, changing main script prefer not happen don't need maintain 2 versions of code 1 local , 1 server. change cron job run shell script. inside shell script, set pythonpath , call python program. change cron job this: /path/to/my_shell_script.sh contents of my_shell_script.sh : export pythonpath=something python /path/to/p

java - How can I access SQLyog community through netbeans and insert a query in it? my code is Here below -

i have added apache tomcat in libraries , connect correct want insert data in sqlylog through html page. what's wrong in code have doubts insert query , file. public class myservlet extends httpservlet { class dbconn { connection c1 = null; statement st = null; resultset rs = null; private final string ac; private final string aaa; dbconn() { try { class.forname("com.mysql.jdbc.driver"); c1 = drivermanager.getconnection("jdbc:mysql://localhost:3306/teacher", "root", "abcde"); } catch (exception cnfe) { system.out.println("couldn't find driver!"); system.out.println("couldn't connect: print out stack trace , exit."); system.out.println("we got exception while creating statement:" + "that means we're no longer connected."); } try { st = (statement) c1.c