Posts

Showing posts from August, 2012

android - How to add a callback to an activity that's created in a fragment? -

i have fragment button calls following method when clicked/pressed: public void onclick() { intent intent = new intent(getactivity(), mynewactivity.class); startactivity(intent) } however, want pass callback method mynewactivity called inside activity's ondestroy method. need callback method call fragment's finish() method. i tried using static variables , worked seems bad design. what's best way this? if not through callback method, what's better approach? use startactivityforresult() proposed in comments. use below code: fragment: public class myfragment extends fragment { private static final int request_code = 1353; @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view v = inflater.inflate(r.layout.fragment, container, false); v.findviewbyid(r.id.b

python 2.7 - tor tutorial "speaking to russia" stuck at 45 - 50% -

when try follow tutorial ( https://stem.torproject.org/tutorials/to_russia_with_love.html ) how start tor keep getting stuck @ 45% , sometimes @ 50%. using windows 8, python 3.4 , liclipse ide. [1mstarting tor: [0m [34mapr 26 12:47:21.000 [notice] bootstrapped 0%: starting[0m [34mapr 26 12:47:21.000 [notice] bootstrapped 45%: asking relay descriptors[0m [34mapr 26 13:04:00.000 [notice] bootstrapped 50%: loading relay descriptors[0m the script looks this, change have made myself here use requests library instead of urllib rquest data source i'm not getting part of code here anyway. basicly copy of code @ tutorial page using socksipy. torconnector.py: from io import stringio import socket import requests import socks # socksipy module import stem.process stem.util import term socks_port = 7000 # set socks proxy , wrap urllib module socks.setdefaultproxy(socks.proxy_type_socks5, '127.0.0.1', socks_port) socket.socket = socks.socksocket # perform

logic - Create No to nearest Decimal in filemaker calculation -

i have database calculating shipping cost. logic of shipping cost such way calculated every 500gm. have price list according different weight when using calculation taking weight user example 1.4 unable next calculative weight of 1.5 , .7 1.0 , 1.7 2.0 how achieve this? try (substitute mynumber different result): let ( [ mynumber=2.6; mynumberint = int(mynumber); mynumberfr = mynumber - mynumberint; mynumberfr = case ( mynumberfr =0;0;mynumberfr >0.5 ; 1;0.5 ); result = mynumberint + mynumberfr ] ; result ) you can wrap in custom function, in case need change later throughout system. i sure there better mathematical formula, should started

javascript - $.getJSON return value to variable -

this question has answer here: how return response asynchronous call? 21 answers here's problem i have json file full of country codes, , function gets random country code, this: function getrandomcountrycode(specificmap){ $.getjson('../maps/' + specificmap + '.json', function( data ) { var countries = []; (var in data.country) { countries.push(data.country[i].code); } var rndcountrycode = countries[math.floor(math.random()*countries.length)]; return rndcountrycode; }); }; in function, call above function , try store rndcountrycode variable variable it's available inside new function. function loadmap(map){ var specificmap = map; var y = getrandomcountrycode(specificmap); console.log("y : " + y); } all undefined . did lot of research (here , here , here ) , realized because of asynchro

javascript - How can i call c# functions from JS? -

i have c# page 2 functions - 1 data mssql database, , second 1 insert data it. i want know how use ajax (or other way?) call functions js file. 1 of functions need data back, other 1 need send data js c# functions.. i believe using jquery based on tags. to send request in jquery: $.get("myurl", function(data) { console.log(data); }); data contains content of myurl - if content json, plainobject , if not string. to send request parameters in jquery: $.get("myurl", {"param1":"content","param2":"content"}, function(data) { console.log(data); }); to send post request in jquery: $.post("myurl", {"param1":"content","param2":"content"}, function(data) { console.log(data); });

c# - No connection string named 'MyAppDbContext' could be found in the application config file -

inside dal project have repositories consume ui. i've refactor project bit , on gather data repository i'm getting error "no connection string named 'myappdbcontext' found in application config file." my app.config on same project (dal) repository lives have following context <?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 --> <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </configsections> <connectionstrings> <add name="myappdbcontext" connectionstring="data source=.\sqlexpress;initial catalog=myapp.dal.myappdbcontext;i

css - Wordpress programming -

Image
dear stackoverflow friends, i have little problem wordpress website making. need .gif file under header no space between. how can fix that? so can see image mean kind regards, murtaza

arrays - Python inserting a row in a 2Darray -

i have 5x17511 2d array (name = 'da' ) made pandas.read_csv(...) i added 1 column indexing this: da.index = pd.date_range(...) so 2d array has 6x17511 size now. i'd insert/append 1 more row 2d array, how this? i tried with: np.insert(da,1,np.array((1,2,3,4,5,6)), 0) says: valueerror: shape of passed values (6, 17512), indices imply (6, 17511) thanks in advance! i have assumed numpy question rather pandas question ... you try vstack ... import numpy np da = np.random.rand(17511, 6) newrow = np.array((1,2,3,4,5,6)) da = np.vstack([da, newrow]) which yields ... in [5]: da out[5]: array([[ 0.50203777, 0.55102172, 0.74798053, 0.57291239, 0.38977322, 0.40878739], [ 0.9960413 , 0.22293403, 0.34136638, 0.12845067, 0.20262593, 0.50798698], [ 0.05298782, 0.09129754, 0.40833606, 0.67150583, 0.19569471, 0.75176924], ..., [ 0.97927055, 0.44649323, 0.84851791, 0.05370892, 0.94

php - laravel - get value from url -

i know might off question or can duplicate after searching lot decided post question. using socialite laravel , still newbie it. decided have twitter login. did @ last didn't know how values such oauth_verifier , oauth_token variable url example.com/callback?oauth_token=xyz&oauth_verifier=123 . i want check values. have tried using \input::get('oauth_verifier') , isset($_get('oauth_verifier')) didn't output each time. please help. there function user() gives possible values can socialize. try this $user = socialize::with('twitter')->user(); dd($user);

Linq to XML VB.NET Select and edit rows and cells from a HTML table -

i have plain table made of rows (tr) , cells (td) no specific attributes. i can read , parse xelement, need use linq xml , perform calculations , changes on cells based on position in row. <tr><td>a</td><td>12</td><td>2</td><td>result</td></tr> <tr><td>ba</td><td>3.65</td><td>6</td><td>result</td></tr> for instance need add values of cells 2 , 3 write result cell 4 each row. i can find plenty of examples given cell has name attribute, bot none can select rows , each row apply calculation on cells based on relative position. one possible way, assuming table rows has consistent structure* : dim xml = <table> <tr><td>a</td><td>12</td><td>2</td><td>result</td></tr> <tr><td>ba</td><td>3.65</td><td>6</td><td>res

algorithm - Determining the big-O runtimes of loop with inner loop repeat time is const -

i have function for(int i=0;i<n; i++) { b[i]=0; for(int j=0;j<5;j++) { b[i]=a[j+i] } } i need calculate big-o of above function. answers is: inner loop run 5n time => o(n) . total complexity o(n) . think have mistake in calculations, don't know mistake. no, haven't made mistake. correct in thinking , solution perfect! the outer-loop run n-times , inner loop runs 5(constant) times. therefore, loops complexity o(5*n) = o(n) , other statements of constant time-complexity. since, 5*n times execution of program means o(n) time-complexity of program .

regex - Powershell: Read a section of a file into a variable -

i'm trying create kind of polyglot script. it's not true polyglot because requires multiple languages perform, although can "bootstrapped" either shell or batch. i've got part down no problem. the part i'm having trouble bit of embedded powershell code, needs able load current file memory , extract section written in yet language, store in variable, , pass interpreter. have xml-like tagging system i'm using mark sections of file in way not conflict of other languages. markers this: lang_a_code # <{langb}> ... code in language b ... ... code in language b ... ... code in language b ... # <{/langb}> lang_c_code the #'s comment markers, comment markers can different things depending on language of section. the problem have can't seem find way isolate section of file. can load entire file memory, can't stuff between tags out. here current code: @echo off setlocal enabledelayedexpansion powershell -executionpolicy

php - Magento - Display product and category body page for each design in admin -

Image
i need identify add cart button , disabled (js , php) based on product id(this not real aim of question, bold real one) since haven't found solution have thought let admin press button in admin section dedicated tomy extension , capture button information js , save them later. to display main body of product page , 1 of category each theme in design section. how retrieve themes , packages: //main package/theme mage::getstoreconfig('design/package/name') //reegex theme $ob=unserialize(mage::getstoreconfig('design/package/ua_regexp')); foreach($ob $key) echo $key['value']; my main concern bold part, if possible? how do it? clear: need red rectangle: above there breadcrumbs , on right sidebar more details when admin creates/edit product, can select or not countries item can selled. happens: when page load system check if item merchantable in costumers country otherwise removes button. bring problems: wide theme support: i'm not sur

ios - How to load HTML in UITextView? -

i have html contents achor tag in it. want load html content in uitextview . you can convert html document nsattributedstring so: // html needs in form of nsstring nserror *error = nil; nsattributedstring *attstring = [[nsattributedstring alloc] initwithdata:[html datausingencoding:nsutf8stringencoding] options:@{nsdocumenttypedocumentattribute:nshtmltextdocumenttype, nscharacterencodingdocumentattribute:@(nsutf8stringencoding)} documentattributes:nil error:&error]; if (error) { nslog(@"error: %@ %s %i", error.localizeddescription, __func__, __line__); } else { // clear text view textview.text = @""; // append attributed string [textview.textstorage appendattributedstring:attstring]; } if come across problems try changing encoding nsasciistringencoding in places.

Java applet crashes in Chrome -

i have issue java applet in chrome. error message: java(tm) platform se8 u40 has crashed appears. after searching internet, enabled java in browser. changed java security settings, still not work. testing applet using applet viewer command in terminal produces error message too: java.lang.noclassdeffounderror : firstapplet in folder have class ( firstapplet.class ) , html page( page.html ) , firstapplet.java page.html <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> </head> <body bgcolor="#0000ff"> <applet code="firstapplet" width="500" height="500"></applet> </body> </html> firstapplet.java import java.applet.applet; import java.awt.button; im

python - AttributeError: 'module' object has no attribute 'BuiltinFunctionType' in pycharm -

i write code in python language uses copy module. when run code in pycharm console has no error in pycharm gui environment gives me error: traceback (most recent call last): file "c:/....../python/deepshallowcopy.py", line 2, in <module> copy mport deepcopy file "c:\python34\lib\copy.py", line 114, in <module> types.builtinfunctiontype, type(ellipsis), attributeerror: 'module' object has no attribute 'builtinfunctiontype' my code is: from copy import deepcopy col3=["rrrr","bbbb"] col4=deepcopy(col3) print(col3,col4) col3[0]="jfjdhf" print(col3,col4) taking closer @ traceback, traceback (most recent call last): file "c:/....../python/deepshallowcopy.py", line 2, in <module> copy import deepcopy file "c:\python34\lib\copy.py", line 114, in <module> types.builtinfunctiontype, type(ellipsis), attributeerror: 'module&#

sql server - How can I set a start and modified date with one SQL Update command? -

i have simple sql server table: create table [dbo].[usertest] ( [usertestid] int identity (1, 1) not null, [userid] int not null, [modifieddate] datetime null, [starteddate] datetime null ); i set modified date this: update usertest set modifieddate = @modifieddate usertestid = @usertestid , userid = @userid but there way can set starteddate in same sql @modifieddate if starteddate null ? you can use coalesce statement set starteddate if not null, or @modifieddate if is. update usertest set modifieddate = @modifieddate, starteddate = coalesce(starteddate, @modifieddate) usertestid = @usertestid , userid = @userid

python - "Invalid destination position for blit" in pygame when loading configuration from file -

i trying unsuccessfully load room file during runtime. confuses me line of code: objglobal.instances.append(oplayer.oplayer(x, y)) successfully creates object when executed in main function, when put not when in file loading function: file "e:\fun stuff\python stuff\python projects\simpleengine\main.py", line 56, in main objglobal.drawobjects(displaysurface) file "e:\fun stuff\python stuff\python projects\simpleengine\global.py", line 57, in drawobjects surface.blit(self.instances[i].sprite, (self.instances[i].x, self.instances[i].y)) typeerror: invalid destination position blit that error occurs later on when try , call 1 of objects' variables or functions, of course. here function loading room: def loadroom(objglobal, fname): # list of stuff openfile = open(fname, "r") data = openfile.read().split(",") openfile.close() # loop through list assign said stuff in range(len(data) / 3):

android - YouTube Player plays for 2 seconds and stop in full screen -

i'm facing 2 major problems, i'm using youtube player , when gets on full screen, plays 1-2 seconds , stop. when click "play" button in middle, it's buffering on again. if gray bar filled it's center. those problems aren't occurring in portrait mode. here class, youtube api demo bit defference public class video extends youtubefailurerecoveryactivity implements youtubeplayer.onfullscreenlistener, utils.ongeturllistener, view.onclicklistener { static int auto_play_delay = 1000; static final int portrait_orientation = build.version.sdk_int < 9 ? activityinfo.screen_orientation_portrait : activityinfo.screen_orientation_sensor_portrait; private linearlayout mrootlayout; /** * * youtube *** */ youtubeplayerview mplayerview; youtubeplayer mplayer; boolean misfullscreen; string urlid; /** * * *** */ relativelayout mcontainer; imageview mbtplay; bool

ruby on rails - How can i get a percentage of how many users favorited a post -

how can percentage of how many users favorited post? 80% of users favorite first post. using gem called markable . in posts controller can favorite post this. class postscontroller < applicationcontroller def favorite @post = post.friendly.find(params[:id]) current_user.mark_as_favorite @post redirect_to @post end end i can see users have favorited post this @post = post.first << test post @post.users_have_marked_as_favorite << [user1, user2] @post.users_have_marked_as_favorite.count << 2 below post , user models class post < activerecord::base extend friendlyid friendly_id :title, use: :slugged # markable_as :favorite gives me option favorite markable_as :favorite end class user < activerecord::base acts_as_marker end this calculate percentage , round have 2 decimal numbers class post < activerecord::base def favored_percentage (users_have_marked_as_favorite.count * 100 / user.count).round(2) end end

How do I amend my .htaccess rules to allow more than 1 parameter? -

i have url 3 parameters following http://example/songs.php?name=name&uploadedby=xyz&cat=rock before had url 1 parameter this: http://example/songs.php?name=name the rules in .htaccess file follows: rewriterule ^([a-za-z]+)$ /songs.php?name=$1 currently works 1 parameter only. how can make work 1 or more parameters? help appreciated. try this rewriterule ^([a-za-z0-9]+)/([a-za-z0-9]+)/([a-za-z0-9]+)/?$ /songs.php?name=$1&uploadedby=$2&cat=$3 [qsa,nc,l]

r - "fuzzy key matching" for a data.table merge -

i'm trying match workers year year using name strings , measure of experience. experience can increase @ 1 year year, i'd use matching when other metrics fail. for example: dt1<-data.table(name=c("jane doe","jane doe", "john doe","jane smith"), exp=c(0.,5,1,2),id=1:4,key="name") dt2<-data.table(name=c("jane doe","jane doe", "john doe","jane smith"), exp=c(0,30,1.5,2),key="name") i want match first "jane doe" in dt1 first "jane doe" in dt2 . latter "jane doe"s don't match, because they're different people (based on vastly different experience levels). i'd add flags know matched these people in way later on down line. here's first pass: dt2[dt1,`:=`(id=ifelse(exp<=i.exp+1,i.id,na), flag=ifelse(exp<=i.exp+1,i.id,na))] b

jquery - Auto Arrange box in css or javascript -

Image
i creating template , want know how auto arrange multiple height box in css or javascript. i tried change css , javascript , i've searched on google i've had no luck yet. i giving here image clear know looking showing in image... please check image before replay need thank you have looked @ library masonry? http://masonry.desandro.com/

how to deploy crystal report on client machine, in vb.net -

i working on vb.net project crystal report. my problem that, on client's machine crystal report forms failing following error; error-> "either crystal report registry key permissions insufficient,or crystal reports run time not installed correctly" any idea how solve issue please? you need install crystal report viewer client pc, not whole software viewer. depends on client pc 64 bit or 32 bit, , version has been developed with.

Adding an end parameter in Python -

i've got issues adding "end" parameter function searches specific letter in string. this code far: def find(str, ch, start=0): index = start while index < len(str): if str[index] == ch: return index index = index + 1 return -1 i know cannot use len() parameter because defined during def process , not when call on find function. cannot useful because length of string not established during def . thank answers/answer. you add end parameter this: def find(string, ch, start, end): index = start while index <= end: #check if reaches 'end' parameter if string[index] == ch: return index index = index + 1 if index > len(string): break #break if index greater len(string) return -1 demo: >>> find('testing123','1',0,9) 7

apache - htaccess Removed File Extension Yet Extension Still Exists -

using htaccess, able make html urls function without file extension, yet file extension still exists. example: example.com/index , example.com/index.html both exist! i want html file urls exist @ single stripped url (e.g. example.com/index ) i've tried manually deleting .html off of files, files load plain text. can achieve results want? htaccess code: rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ $1.html rewrite doesn't remove extension. allows not use , internally rewrites in rule. can't manually make file extension disappear. has there work. in addition current rule need check request , redirect extensionless url if enter .html on it. use rule , let me know how works you. rewriteengine on rewritecond %{the_request} ^[a-z]{3,9}\ /([^&\ ]+).html rewriterule .* /%1? [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ $1.html [l]

excel vba - how to Prepare Data Report from Data Grid in vb6? -

Image
i trying generate report excel file copied data grid! there seems no way it. out there suggestions.please help. here snap.i doing in vb6. thank you!

ios - How to check if a UILabel is empty and append content to a label? -

new ios , swift. want best practice tips. want append content label in new line. try: @iboutlet weak var history: uilabel! @ibaction func appendcontent() { if history.text != nil && !history.text!.isempty { history.text = history.text! + "\r\n" + "some content" } else{ history.text = digit } } it seems work, however, is there better way check text not nil , not empty? is there "keyword" thing "\r\n"? you can use optional binding: if let check if nil . example 1: if let text = history.text !text.isempty { history.text! += "\ncontent" } else { history.text = digit } or can use map check optionals: example 2: history.text = history.text.map { !$0.isempty ? $0 + "\ncontent" : digit } ?? digit !$0.isempty in cases not needed code can bit better: history.text = history.text.map { $0 + "\ncontent" } ?? digit edit: what map do: the

javascript - Crashing the application from within a Q promise instead of propagate a rejection through a chain of promises? -

so problem q swallows exceptions not meant reject promises, crash application possible, know broken. i know can (and should) use done method @ end of chain, it's pain in butt keep track of chain ends. , doesn't because doesn't prevent q catching , once cached exception looses it's stack trace. is there way crash when exception thrown rather propagate rejection chain hoping there done @ end of it? right, pr q got merged, can this: process.on("unhandledrejection", function(err, promise){ throw err; // terminate error if `.catch` not attached }); which cause process exit whenever exception not explicitly handled (via catch ). ends long saga of debugging issues promises. gone days of .done . just make sure q 1.30, released 6 minutes ago :d

python - Implement same methods in different classes -

i don't know how word problem, i'll try explain example. let's have 3 gui classes: base surface class detailed surface class sprite class all of them independent of each other, no inheritance among them. have function "drag()" makes surface/sprite dragable, , want implement function method 3 of them. since it's exact same code implementations find annoying, cumbersome , bad practice rewrite code. thing came far make saperate class , inherit class. doesn't seem way go. i'd thankfull advice. edit another example different setup - have following classes: basesurface dragable resizable eventhandler only first 1 independent, others depend on first (must inherited). end user should, without effort, able choose between simple basesurface, 1 implements dragable, 1 resizable, 1 eventhandler, , combination. "without effort" mean end user should not have make e custom class , inherit desired classes plus call appropriate m

rest - How do you manage the underlying codebase for a versioned API? -

i've been reading on versioning strategies rest apis, , none of them appear address how manage underlying codebase. let's we're making bunch of breaking changes api - example, changing our customer resource returns separate forename , surname fields instead of single name field. (for example, i'll use url versioning solution since it's easy understand concepts involved, question equally applicable content negotiation or custom http headers) we have endpoint @ http://api.mycompany.com/v1/customers/{id} , , incompatible endpoint @ http://api.mycompany.com/v2/customers/{id} . still releasing bugfixes , security updates v1 api, new feature development focusing on v2. how write, test , deploy changes our api server? can see @ least 2 solutions: use source control branch/tag v1 codebase. v1 , v2 developed, , deployed independently, revision control merges used necessary apply same bugfix both versions - similar how you'd manage codebases native apps when

SSRS and filtering at a field level -

i have dataset number of records unique identifier , "createdate" field. need able filter @ field level determine count of number of records added in last 7 days, not wish filter @ dataset level. have created "calculated" field dataset , having difficulty syntax count records (using unique field "propertyid" count field) counting records create date within last 7 days. expression using created field have named saleslastweek is:- =iif(fields!createdate.value > =dateadd(dateinterval.day,-7,today()), =count(fields!propertyid.value), 0) the error message received is:- the expression used calculated field '=iif(fields!createdate.value > =dateadd(dateinterval.day,-7,today()), =count(fields!propertyid.value), 0)' includes aggregate, rownumber, runningvalue, previous or lookup function. aggregate, rownumber, runningvalue, previous , lookup functions cannot used in calculated field expressions. i'm not sure why t

javascript - Node.js scope of a variable inside a function -

i getting started node.js, , on small program writing running problem when trying pass variable. i have function pass line have read file. in function create mongoose model of line , try save database. working fine, in cases there wrong data , can't saved database save text file. i added call save file, file gets created empty. when debugging code, console messages displayed , appears @ point in execution line empty string. proper way pass value ? var parserecord = function (line) { var arrayofstring = line.tostring().split(" "); if (arrayofstring[0].substr(0,1) != '#'){ var dbrecord = new logentry({ logdatetime: arrayofstring[0] + ' ' + arrayofstring[1], serverip: arrayofstring[2], requestmethod: arrayofstring[3], uristem: arrayofstring[4], serverport:arrayofstring[6], clientip:arrayofstring[8], browsertype:arrayofstring[9], referrers

php - Query google search engine? -

i trying query google search engine date first page results process it. query using returns results not in date range set; if copied same query google works date not php script. script returns current or normal results if date parameter not set. part of code snippet used below. query referring below in code snippet posted in $url variable. query: https://www.google.com/search?q='.$query.'&source=lnt&tbs=cdr%3a1%2'.$startdate.$enddate.'&tbm= $query= $_post['query']; $query=str_replace(" ","+",$query); if ($_post['start_date']==''){ $startday='1'; $startmonth='11'; $startyear='2011'; } if ($_post['end_date']==''){ $endday='1'; $endmonth='11'; $endyear='2013'; } $startdate='ccd_min%3a'.$startmonth.'%2f'.$startday.'%2f'.$startyear.'.%2'; $enddate='ccd_max%3a'.$endmonth.'%2f'.$endday.'%2f'.$end

javascript - Trying to refactor an animation into a class object, how to construct its interrelating parts -

i'm trying refactor animation code class object can instantiated. the original code file functions , variables, , called variables functions, turning out little bit of problem since 1 of things code had constructor populate array. i'm little confused @ how put aspect new class constructor function, since mini class particle has method of own called .use has ctx variables inside that. how point ctx information thats contained in rest of function since in scope area? i tried adding .use method prototype drawslinky.prototype.particle.use , when gets point should call function, says isn't function, imagine that didn't work. here's code right now, error following : drawslinky.prototype.particle = function(x, y, color, area, velocity, rad){ this.x = x; this.y = y; this.vx = math.cos(rad) * velocity; this.vy = math.sin(rad) * velocity; this.color = color; this.area = area; this.use = function(){ this.x += this.vx *= .99; th

c++ - How to know if a word in a string has digits? -

the question have: how can tell if word in string has digit in or not? what need do: write program reads in line of text , outputs line digits in integer numbers replaced 'x'. for example: my userid john17 , 4 digit pin 1234 secret. it should become my userid john17 , x digit pin xxxx secret. notice how digits in john17 not affected. the code have far: #include <iostream> using namespace std; int main() { string str; int i; cout << "enter line of text: "; getline(cin, str); (i = 0; <= str.length(); i++) { if (str[i] >= '0' && str[i] <= '9') { str.at(i) = 'x'; } } cout << "edited text: " << str << endl; } there plenty of methods can use. below of them: 1 - generic algorithm: iterate through string: example: "my userid john17 , 4 digit pin 1234 secret." set boole

java - How do I solve NullPointerException in CustomList -

this customlist class customlist: public class customlist extends arrayadapter<string> { private final activity context; private final string[] web; private final integer[] imageid; public customlist(activity context,string[] web, integer[] imageid) { super(context, r.layout.single_row, web); this.context = context; this.web = web; this.imageid = imageid; } @override public view getview(int position, view view, viewgroup parent) { layoutinflater inflater = context.getlayoutinflater(); view rowview= inflater.inflate(r.layout.single_row, null, true); textview txttitle = (textview) rowview.findviewbyid(r.id.txt); imageview imageview = (imageview) rowview.findviewbyid(r.id.img); txttitle.settext(web[position]); imageview.setimageresource(imageid[position]); return rowview; } } and imageid array fill while loop below while(crs.movetonext()){ string img = crs.getstring(crs.getcolumnindex("icon")); try

C++ print string one word at a time, count characters, and average of characters -

how can print single word string in each line number of characters right next , average of characters together? i'm suppose use string member function convert object c string. function countwords accepts c string , returns int. function suppose read in each word , lengths including average of characters. have done how words in string except don't know how continue rest. for example: super great cannon boys super 5 great 5 cannon 6 boys 4 average of characters: 5 this program far: #include <iostream> #include <string> #include <cstring> using namespace std; int countwords(char *sentence); int main() { const int size=80; char word[size]; double average=0; cout<<"enter words less " <<size-1<<" characters."<<endl; cin.getline(word, size); cout <<"there "<<countwords(word)<<" words in sentence."<<endl; return 0; } int countwo

javascript - Not able to load google map URL through Angularjs -

Image
i trying send value $scope front end. url google embade. seems throwing error. here attaching error screenshot. and here how controller looks var module = angular.module('app', ['onsen']); module.controller('listingmapctrl', function($scope, $http, $rootscope) { ons.ready(function() { $scope.maplocation="https://www.google.com/maps/embed/v1/directions?key=my_key&origin=current+location&destination="+$rootscope.latlong; }); }); and here calling it: <iframe ng-src="{{maplocation}}" frameborder="0" style="border:0" width="100%" height="100%;"></iframe> do else had same problem? way rectify problem? here how html head tag looks <html lang="en" ng-app="app"> <head> <meta charset="utf-8"> <meta name="apple-mobile-web-app-capable" content="yes"> <me

SQl injection getting current user and database priv -

i doing tutorial lab on sql injection. i stuck @ retrieving username of current user , priv has. i tried select user dual, select current_user. in sqlplus, current user type sql> show user. question being asked: 1. use sql injection string in search field name of database user application connecting database with. 2. use sql injection string in search field system privileges granted user application connecting database with. please help. thanks

arrays - C++ - Read input file and store and calculate statistics -

Image
i posted question on topic earlier when beginning problem. since then, have worked on source code , filled in lot of blanks. have experiencing troubles now, because there lot of discrepancies , problems source code. please ignore comments. include them own personal benefit remind me of doing or going on when checking own work. first, has 9 function prototypes categorized 3 groups 3 methods each same thing different variables. example, int getfirstlowest(studentdata[]) int getfirsthighest(studentdata[]) , , double getaverage1(studentdata[], int) . want different method find lowest, highest , average of each exam , lowest, highest , average value of totals of each. idea had create array of size 3 each statistic need calculate (lowest, highest, average , standard deviation), don't know how it. next, curious if should combine gettotal function , getgrades function more efficient. gettotal method adds exam scores while getgrades filled if else statements categorize scores

How does the Cats library in Scala relate to scalaz? -

how the cats library relate scalaz ? cats project mentions descended scalaz. i keep getting political*, cats intents , purposes scalaz. has not reached full parity of yet, keep in mind created few months ago. goal more pragmatic approach , more democratic when comes evolution. so, naming of operators , classes going little more straightforward, has no qualms using mutable data within method if means better performance. last, hoping have better documentation....all of means may end becoming replacement scalaz better beginner's approach not embroiled in math world. if want fuller answer, maybe head on gitter board , erik (non) answer himself :) *the gist scalaz has social baggage causes number of big names shy away using and/or contributing.

excel - Return Value From One Workbook' VBA To Another Workbook' VBA -

i have 2 workbooks vbas. pass value returned wba!vba1 wbb!vba2; both workbooks running under same excel application. for example, in wba!vba1, there x = function() , return integer 0 if run successfully; i want pass returned value 0 wbb!vba2 other operations. from can see asking. want able store variable wba inside of vba , view in vba in wbb. knowledge not possible variables created @ run time. once process has finished variables cleared. 1 thing run vba in wba , store ever variables need in hidden sheet. way in wbb can call vba , variables have stored in hidden sheet. so getting variables not @ run time. have call each macro seperatly. or way have code stored in personal macro book or workbook, need set references wba , wbb. code ran in seperatly , can view variables in vba.

angularjs - How many watches ng-switch creates? -

simple: how many watches ng-switch place? for example: <section ng-switch="value"> <div ng-switch-when="1">1</div> <div ng-switch-when="2">2</div> <div ng-switch-when="3">3</div> <div ng-switch-when="4">4</div> </section> will create 1 watch? four? thanks in advance. ngswitch creates single watcher on expression in ng-switch attribute. one easy way check following in controller: // $timeout crude way "wait" until ng-switch sets watcher $timeout(function(){ console.log($scope.$$watchers ? $scope.$$watchers.length : 0); }) another, (minus 1 because expression introduces own $watch): <pre>{{$$watchers.length - 1}}</pre> <section ng-switch="value"> <div ng-switch-when="1">...</div> ... </section> and yet another, going source , seeing sin

asp.net web api2 - How to inject UrlHelper in Web API 2 using StructureMap.WebApi2 nuget package -

i using structuremap.webapi2 nuget package web api 2 project managing depedency injection. web api controllers use constructor injection inject urlhelper dependency should resolved structuremap ioc. trying following approach set urlhelper web api controller: public class foocontroller : apicontroller { private urlhelper _urlhelper; public modelfactory(httprequestmessage request) { _urlhelper = new urlhelper(request); } } but above code getting following error: no default instance registered , cannot automatically determined type 'system.net.http.httpmethod' there no configuration specified system.net.http.httpmethod can suggest me best possible ways resolve above issue? your problem structuremap tries resolve greediest constructor first, in instance taking @ source code httprequestmessage reveals following constructors: public httprequestmessage(httpmethod method, string requesturi); public httprequestmessage(ht