Posts

Delphi: Retrieve city from public ip address -

how city name http://whatismyipaddress.com/ website? this attempt: var sl: tstringlist; a: integer; s: string; begin sl := tstringlist.create; try httpgettext('http://whatismyipaddress.com/', sl); := pos('your ip address is', sl.text); if > 0 begin s := copy(sl.text, a, 40); := pos('</', s); s := copy(s, 19, - 19); ip := s; end else ip := 'unknow ip'; freeandnil(sl); end; is way without use synapse library changing (httpgettext) (idhttp1.get) ? thanks me! you have download html content whatismyipaddress.com generates, , parse html needed. can use http client (indy, ics, synapse, curl, wininet/winhttp, raw winsock calls, etc) download html. city appears once in html, inside table, eg: <tr><th style="font-weight:bold;color:#676769;">city:</th><td style="font-size:14px;">name here</td></tr> so s...

java - Is it possible to set an Android Notification or a later date and time that will fire when the app is not running? -

from have read seems code require app running in thread until notification fires. need notification fire @ later date , time user sees notification other notification , clicks , opens of activity, passing in data app knows do. how can make notification fire days later without app running whole time? do use wait accomplish this? long millis = 60000; mynotification.wait(millis); here code fires immediately notificationcompat.builder mbuilder = new notificationcompat.builder(getactivity()) .setsmallicon(r.drawable.star) .setcontenttitle("how " + me.getstring("eventtitle") + "?") .setcontenttext("click here leave review"); intent resultintent = new intent(getactivity(), setupactivity.class); pendingintent resultpendingintent = pendingintent.getactivity( getactivity(), 0, resultintent, pendingintent.flag_update_current ); mbuilder.setcontentintent(resultpendingintent); int mnotificationid = me.getint("eventid"); ...

C# Adding images to a list -

i'm trying add images used imagelist named "images1". i'm not in coding programs know rest of program working except fact "images1" not exist 2 last voids. searched resolve problem have difficulty find answer specific case. how can make image list "images1" available private voids? this code: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.collections; using system.globalization; using system.resources; using system.reflection; namespace booster_pack_2 { public partial class form3 : form { public form3() { initializecomponent(); } private void textbox1_textchanged(object sender, eventargs e) { list<image> images1 = new list<image>(); resourcemanager rm = booster_pack...

ruby on rails - Model custom validation passing true even though it is not -

i'm confused this. model has following custom validation: def custom_validation errors[:base] << "please select @ least 1 item" if @transactionparams.blank? end basically it's checking make sure parameters belonging different model not blank. def request_params @requestparams = params.require(:request).permit(:detail, :startdate, :enddate) @transactionparams = params["transaction"] @transactionparams = @transactionparams.first.reject { |k, v| (v == "0") || (v == "")} end if it's not blank, happens record saved, , kinds of other things happen. def create request_params @request = @user.requests.create(@requestparams) if @request.save ... else render 'new' end end if record not saved, re-rendered new view shows errors stopped @request being created. problem whether or not @transactionparams.blank? true or false, record fails save, , checked puts in lo...

android - R.drawable.icon - cannot find symbol -

i have on code: notification notification = new notification.builder(extension.maincontext) .setcontenttitle(title).setsmallicon(r.drawable.icon) .setcontenttext(message) .setcontentintent(pintent).build(); when try compile it, happens: [javac] /.../mainapp.java:42: cannot find symbol [javac] symbol : variable icon [javac] location: class android.r.drawable [javac] .setcontenttitle(title).setsmallicon(r.drawable.icon) everywhere on google says should put icon.png on res/drawable folder. i'm using haxe/openfl generates folders resolutions: drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi, , file in of them. thought lack of actual "drawable" folder, i've manually created , didn't help. does think of else impacting this? thanks. what import statement r says in class? looks you're importing android.r when want import yourpackage.r, or not import r @ (should default package)

javascript - Having trouble with createElement and appendChild -

i have reasonably simple idea implement. i have array of objects 2 properties: "id" , "name" list these in series of "p" tags within "div". so here html: <body> <div id="listview"></div> </body> and here javascript in tag: sessionstorage.eventid = 2; var playerlist = []; playerlist[0].id = 0; playerlist[0].name = "add new player"; playerlist.push({ id: 5, name: "asako" }); playerlist.push({ id: 6, name: "james" }); playerlist.push({ id: 7, name: "brian" }); playerlist.push({ id: 8, name: "helmut spargle" }); function listall() { var element = document.getelementbyid("listview"); var div; var node; (var = 0; < playerlist.length; i++) { div = document.createelement("div"); div.setattribute("onclick", "javascript: formover(" + playerlist[i].i...

scala - updating Json object -

i have json object need update. original object list looks this: [ { "firstname":"jane", "lastname":"smith" }, { "firstname":"jack", "lastname":"brown" } ] for each element in list, have field, "age", needs added @ run-time, result should following: [ { "firstname":"jane", "lastname":"smith", "age": "21" }, { "firstname":"jack", "lastname":"brown", "age": "34" } ] any suggestions how result still json? thanks. i recommended deserializing json array receive list of case classes, having function fill in missing attributes based on current attributes of case class, , serializing them json , serving response. let's make person case class fields missing option : import play.api.libs.json.json cas...