Posts

How to display latitude and longitude for every five seconds using alarm manager in android? -

i creating application in have show reminder every 5 minutes. instead of reminder have show longitude , latitude every 5 minutes. have 2 activities: 1 alarmmanager , other alarmmanagerbroadcastreceiver . how do this? public class alarmmanagerbroadcastreceiver extends broadcastreceiver { string gps; final public static string one_time = "onetime"; @override public void onreceive(context context, intent intent) { powermanager pm = (powermanager) context.getsystemservice(context.power_service); powermanager.wakelock wl = pm.newwakelock(powermanager.partial_wake_lock, "your tag"); wl.acquire(); bundle extras = intent.getextras(); stringbuilder msgstr = new stringbuilder(); if(extras != null && extras.getboolean(one_time, boolean.false)){ msgstr.append("reminder"); } format formatter = new simpledateformat("hh:mm:ss a"); msgstr.append(formatter.format(new date())); ...

javascript - polling vs long polling -

i got onto these examples showing polling vs long-polling in javascript, not understand how differ 1 another. regarding long polling example, how keep connection open? this traditional polling scenario looks like: (function poll(){ settimeout(function(){ $.ajax({ url: "server", success: function(data){ //update dashboard gauge salesgauge.setvalue(data.value); //setup next poll recursively poll(); }, datatype: "json"}); }, 30000); })(); and long polling example: (function poll(){ $.ajax({ url: "server", success: function(data){ //update dashboard gauge salesgauge.setvalue(data.value); }, datatype: "json", complete: poll, timeout: 30000 }); })(); thanks! the difference this: long polling allows kind of event-driven notifying, server able actively send data client. normal polling periodical checking data fetch, say. wikipedia quite detailed that: with long polling, client re...

asp.net mvc - Dynamically Managing MVC Layouts -

i have small mvc web project want able achieve following: select base page layout , css/javascript based upon active domain optionally allow base/default setting overridden @ start of session. to achieve have created layout object following properties: public class pagelayout { public string reference { get; set; } public string domain { get; set; } public string layoutpath { get; set; } public string csspath { get; set; } public string javascriptpath { get; set; } } my idea being @ start of session, url checked layout parameter. example: http://www.{domain}.com/tech in instance, pagelayout object reference "tech" retrieved. if no parameter found page layout object domain property matching active domain retrieved. i have several questions regarding right way implement this: where best place implement logic in mvc? session_start method in global.asax seems potential candidate i want persist retrieved pagelayout object across whole sess...

database - How to synchronize tables in Django? -

in database want synchronize 2 tables. use auth_user(default table provided django) table registration , there table user-profile contain entities username, email, age etc. how autometically upadate columns username , email in user-profile according updation in auth_user table. from django.contrib.auth.models import user class profile(models.model): username = models.charfield(max_length = 30) email = models.emailfield() age = models.positiveintegerfield() auth_user_id = models.foreignkey(user) you can either modify django registration code , include code save profile model on every new registration. or you can set signal on every save of user model. see documentation . def create_profile(sender, **kwargs): if kwargs["created"]: p = profile(user=kwargs["instance"], ...) p.save() django.db.models.signals.post_save.connect(create_profile, sender=user) create_profile() called every time user object saved. in...

php - Can i insert into two different tables from the same statement? -

i have car application, cars have bunch of information avaible count kept essential on table called auto , made huge table attributes cool. wish can insert same array data 2 different tables under same pdo $sql = "insert auto(year, make, model, mileage, price, vin, att1, att2, att3, att4, picture1, picture2, picture3, picture4, picture5, picture6, picture7, picture8, picture9, picture10, picture11, picture12) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; can 'and insert attributes (' $sth = $dbh->prepare($sql); $final = array_merge(array_values($vehicleinfo),array_values($paths)); $sth->execute($final); echo '<h4 id="successmessage" style="color: red;">vehicle added succesfully</h4>'; i'd tempted loop on tables want run sql on; $tables = array('auto', 'attributes'); foreach($tables $table) { $sql = 'inse...

subnet - Obtaining SubnetMask in C -

i wanted ip address , subnet mask. ip part done, couldn't find socket function return structure subnet mask in it. socket function exist, returns in structure? thanks! in windows using iphelper. #include <winsock2.h> #include <iphlpapi.h> #include <stdio.h> #include <stdlib.h> #pragma comment(lib, "iphlpapi.lib") #define malloc(x) heapalloc(getprocessheap(), 0, (x)) #define free(x) heapfree(getprocessheap(), 0, (x)) /* note: use malloc() , free() */ int __cdecl main() { pip_adapter_info padapterinfo; ulong uloutbuflen = sizeof (ip_adapter_info); padapterinfo = (ip_adapter_info *) malloc(sizeof (ip_adapter_info)); getadaptersinfo(padapterinfo, &uloutbuflen); printf("\tip mask: \t%s\n", padapterinfo->ipaddresslist.ipmask.string); } if (padapterinfo) free(padapterinfo); return 0; }

c# - Implementing wcf with mvc4 entity framework fails invoking method -

i have wcf application in have used entitity framework , have implemented dbcontext querying database. when view svc file in browser exposes operations. i have interface class this: [servicecontract] public interface iservice1 { [operationcontract] list<booksmodels> getbookslist(); [operationcontract] booksmodels getbook(int id); } i have implementation in svc.cs file public list<booksmodels> getbookslist() { mvcentity en = new mvcentity(); return en.book.tolist(); } public int getbookid(int id) { //return db.book.find(id); return 1; } and booksmodels class this [datacontract] public class booksmodels { [key] [datamember] public int bookid { get; set; } [datamember] public string bookname{get;set;} } and have config file default 1 created when creating wcf service application . but ...