Posts

Showing posts from July, 2012

dictionary - Want ability to save and load the ESRI map in my Application -

we developing app. user can draw object on map , want save location , map extent drawn graphics on our server using serialize json representation of state. , when user come afterward clicking location item want re-render same state last graphics had drawn on using same serialize json object server. how achieve feature in arcgis javascript api. need write our own feature layer if yes how it? typically use feature service store , serve data (graphics). can define , publish feature service either using local arcgis server installation , or in cloud on arcgis online . once have feature service published, connect using arcgis api javascript (jsapi) featurelayer . see of editing samples idea of different ways can use featurelayer , other modules jsapi manage data in feature service. you can (optionally) create web map references feature layer defines other map properties initial extent, basemap, etc , have app load web map. as far persisting other parts of map state (ext...

python - Why is my widget being overlapped? -

i using bryan oakley's code @ tkinter adding line number text widget create text widget line numbers. want create custom widget can use text widget optional line numbers. in: t = linedtext(top) t.insert("insert", "hello") t.show() but of now, when show line numbers, covers text widget. window resized automatically. why happening? code: import tkinter tk class textlinenumbers(tk.canvas): def __init__(self, *args, **kwargs): tk.canvas.__init__(self, *args, **kwargs) self.textwidget = none def attach(self, text_widget): self.textwidget = text_widget def redraw(self, *args): '''redraw line numbers''' self.delete("all") = self.textwidget.index("@0,0") while true : dline= self.textwidget.dlineinfo(i) if dline none: break y = dline[1] linenum = str(i).split(".")[0] self.c...

angularjs - View(Template) does not update when the controller changes -

i have directive pushes element array, , shows elements on view, problem though array gets updated (the log shows correct values) view keeps showing empty array. doing wrong? note: not need parent's $scope anything, i'm adding/modifying on directive's scope. directive: app.directive('streaming', function(){ return { restrict: 'ea', scope: { live: '&', data: '&', }, controller: function($scope){ $scope.messages=[]; //..... //eventually reaches $scope.messages.push({..}); }, templateurl: '/directives/templates/streaming.html' }}); template: <div class="row" > <canvas id="canvas" width="640px" height="360px"></canvas> </div> <div ng-show="live" id="chat"> {{messages}} <div ng-repeat="m in message...

vb.net - Get certain part of string -

so im getting client, computer name , ip. im getting server picks them in textbox multiline. so, im getting message this: name: xxx-pc; ip: xxx.xxx.xxx.xxx ! want take name , ip form, how extract name/ip when lenght different? thanks this candidate regex.match() using pattern "^name: (.*?); ip: (.*?)$" breakdown: ^ - beginning of string name: - literal string (.*?) - 0 or more characters stored in capture group 1 ; ip: - literal string (.*?) - 0 or more characters stored in capture group 2 $ - end of string code sample: imports system imports system.text.regularexpressions public module module1 public sub main() dim data string = "name: xxx-pc; ip: xxx.xxx.xxx.xxx" dim name string = string.empty dim ip string = string.empty dim match = regex.match(data, "^name: (.*?); ip: (.*?)$") if match.success name = match.groups(1).value ip = match.groups(2).value...

asp.net - One to Many Assosiation without a collection on many Side EF -

i have baseentity : public class baseentity<t> { public baseentity() { this.createddate = system.datetime.now; this.updatetddate = system.datetime.now; } [system.componentmodel.dataannotations.key] [system.componentmodel.dataannotations.required] [system.componentmodel.dataannotations.schema.column("id")] [system.componentmodel.dataannotations.schema. databasegenerated(system.componentmodel.dataannotations.schema.databasegeneratedoption.identity)] public t id { get; set; } [system.componentmodel.dataannotations.required] [system.componentmodel.dataannotations.schema.foreignkey("created_by")] public virtual bonchaghwebapplication.models.core.user createdby { get; set; } [system.componentmodel.dataannotations.required] [system.componentmodel.dataannotations.schema.foreignkey("updated_by")] public virtual bonchaghwebapplication.models.core.user updatedby { get; set; }...

shell - Bash: Reading quoted/escaped arguments correctly from a string -

i'm encountering issue passing argument command in bash script. poc.sh: #!/bin/bash args='"hi there" test' ./swap ${args} swap: #!/bin/sh echo "${2}" "${1}" the current output is: there" "hi changing poc.sh (as believe swap want correctly), how poc.sh pass "hi there" , test 2 arguments, "hi there" having no quotes around it? a few introductory words if @ possible, don't use shell-quoted strings input format. it's hard parse consistently: different shells have different extensions, , different non-shell implementations implement different subsets (see deltas between shlex , xargs below). it's hard programatically generate. ksh , bash have printf '%q' , generate shell-quoted string contents of arbitrary variable, no equilavent exists in posix sh standard. it's easy parse badly . many folks consuming format use eval , has substantial security concerns. n...

algorithm - A graph with n nodes and n vertices can contain just one cycle -

if graph unweighted g have same number of nodes , edges , correct assume graph g contain 1 cycle ? can proved ? edit: , node conected if , if there 1 component in graph. in other words, if each node, there path node in graph, can assume there 1 cycle.

c# - Integration test good practice -

i using unit test time. need write integration test. should save db, , check if saved data ok. can't find simple clean example of integration test. idea this: [test] public void integrationtestexample() { // arrange without mocking var objec1 = new objec1(); var objec2 = new objec2(); var starttestclass = new starttestclass(objec1, objec2); var savedata = "test data"; //act starttestclass.savetodb(savedata); // assert var valuefromdb = selectsaveddata(); assert.areequal(savedata, valuefromdb); } //get data db assert private string selectsaveddata() { var sqlquery = "select top 1 data table1"; var data = repositoryfortest.selectsaveddata(sqlquery); return data; } but not sure if approach? have suggestions? you should test 1 piece of integration @ time, , leave db in such state can run multiple tests , should not affect each other. ms test framework allows define methods set...

c++ - Is there any Dynamic Binding During Deinitialization idiom -

aka: there "calling virtuals during deinitialization" idiom i cleaning old code , need fix cases virtual methods called in constructors , destructors. don't know code base , huge. major rewrite not option. the fix constructors simple. moved virtual calls static create template , made constructors protected. needed compile , change location causing errors use create template. minimal chance regressions. there no analog destructors. how solve this? example code #include <iostream> class base { public: virtual ~base() { deinit(); } protected: virtual void deinit() { std::cout << "base" << std::endl; } }; class derived : public base { protected: virtual void deinit() override { std::cout << "derived" << std::endl; base::deinit(); } }; int main() { derived d; } this code not call derived::deinit (only prints "base"). need fix...

Allow document editing for non-google users -

i'm using google drive api create documents , share them others. ok until had send invitation collaborate non-google user. first of all, since google account owners can edit document, set link can edit. https://www.googleapis.com/drive/v2/files/{file_id}/permissions?key={your_api_key} { "role": "writer", "type": "anyone", "withlink": true } and sent invitation collaborate user: https://www.googleapis.com/drive/v2/files/{file_id}/permissions?key={your_api_key} { "role": "writer", "type": "user", "value": "******@outlook.com" } but, instead of shareable link, invitation join google sent user. ...glwbwxes/edit?invite=ci-zznyl&pli=1 how can send shareable link non-google users instead of invitation create google account? when dont have google account, can collaborate anonymously. once add non-google account sharing list, of...

wpf - Geting user input from listview -

i created listview. need user's input textbox inside listview. when user click on submit button user input listview displayed in messagebox. how user input textbox inside listview <listview x:name="lstvqualification" height="96" margin="10,6,14,0" verticalalignment="top"> <listview.view> <gridview> <gridviewcolumn width="249" header="education"> <gridviewcolumn.celltemplate> <datatemplate> <stackpanel orientation="horizontal"> <textbox x:name="txteducation" width="247" text="{binding education}" /> </stackpanel> </datatemplate> </gri...

database - multiple sql queries on single php page -

i have code <?php include("db.php"); $sql="select * lead"; $result=mysqli_query($conn, $sql); $i=0; ?> <?php while($row=mysqli_fetch_array($result)) { if($row['del']==1){ $sql1="select count(*) notes lead_id='$row[lead_id]'"; $var=mysqli_query($conn,$sql1); $var=mysqli_query($conn,$sql1); $var1=mysqli_num_rows($var); ?> and below php code table displays data fetched $row.the problem not getting correct count of rows.it shows 1 have multiple rows same lead id you call $sql1="select count(*) notes lead_id='$row[lead_id]'"; and have $var=mysqli_query($conn,$sql1); $var1=mysqli_num_rows($var); but mysql_query return 1 row count(*) . have $sql1="select * notes lead_id='$row[lead_id]'"; and call mysqli_num_rows($var);

xml - How to underline text of button in Android? -

i new in android programming.i developing simple app . have button transparent , has icon , text. want underline text of button have not been able this. below xml code: <button android:id="@+id/park" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableleft="@drawable/park" android:text="@string/button_name" android:background="#00000000" android:textcolor="#000000"/> and string file has: <resources> <string name="button_name"><u>parking areas</u></string> </resources this approa ch works in textview not in button. -any suggestion? button button = (button) findviewbyid(r.id.park); button.setpaintflags(button.getpaintflags() | paint.underline_text_flag);

mysqli - PHP echo implode with single along with coma -

i trying add single coat along coma in below code , display data mentioned below (expected output)but iam unable add single coat along coma. $query ="select * abc xyz='xyz' , standard='xyz' "; $data=mysqli_query($mysqli,$query)or die(mysqli_error()); $id = array(); while($row=mysqli_fetch_array($data)){ $id[] = $row['id']; } $idall = implode(',', $id); echo $idall; current output 13,13k,043 expected output '13','13k','043' try this: $idall = "'" . implode("','", $id) . "'";

java - Is DatagramSocket.connect() supposed to stall when called on localhost while listening for a packet? -

in java, datagramsocket.connect(inetsocketaddress addr) supposed filter packets except port/address, when call method (while listening packet in background thread), stalls. datagramsocket datagramsocket = new datagramsocket(8000); inetaddress localaddress = inetaddress.getbyname("localhost");//localhost/127.0.0.1 int destinationport = 7000; datagramsocket.connect(localaddress, destinationport); // stall program print statements before call "datagramsocket.connect" print out print statements after call "datagramsocket.connect" not. update: i getting stalling when calling datagramsocket.disconnect(). datagramsocket.connect, stalling happens whether specify parameters inetaddress , port , when give combined inetsocketaddress. oddity if subclass datagramsocket , call synchronized method in subclass, similar stalling results. odd thing there no other synchronized methods in entire subclass. note java version (oracle java 8 downloaded on ubuntu): ...

android - Facebook LoginButton doesn't work, just show a spinning screen -

i'm following facebook instruction , use own loginbutton, ran 2 issues (they happened randomly between two) : it said invalid hash key, although i've added key fb app or there's spinner, nothing else happened. in case, checked onactivityresult function, got following: requestcode = 129742 resultcode = -1 also in both cases, in following function of facebookbuttonbase, externalonclicklistener null protected void callexternalonclicklistener(final view v) { if (externalonclicklistener != null) { externalonclicklistener.onclick(v); } } what missing? thanks update: way obtained key hash using provided piece of code , copy value out, paste onto fb. @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); try { packageinfo info = getpackagemanager().getpackageinfo( "com.facebook.samples.loginhowto", pac...

unable to import com.sun.javafx.css.StyleableDoubleProperty; -

Image
i'm trying follow tutorial: http://jperedadnr.blogspot.sg/2012/09/a-javafx-weekly-scheduler.html however, intellij throwing error here:

git - libgit2sharp Repository "safe handle has been closed" -

is there problem instantiating repository object twice in same method, each time wrapped in separate using() statement : using(var repo = new repository({local-path}, new repositoryoptions()) { // stuff repo } // other stuff not related repo using(var repo = new repository({local-path}, new repositoryoptions()) { // more stuff repo } for such code-block structure, in do more stuff block i'm experiencing run-time exception safe handle has been closed . is there problem instantiating repository object twice in same method, each time wrapped in separate using() statement instantiating repository instance quite cheap, there's no problem approach. however, 1 has keep in mind following things objects ( reference s, commit s, tree s, ..) returned through libgit2sharp library expected used during lifetime of repository (ie. before it's disposed). not doing may lead objectdisposedexception being thrown. for performance reasons, libgit2 , underlyin...

Delphi with Indy 10 - Best approach for TCP communication -

Image
i creating client-server application using delphi xe3 , indy 10 (idtcpserver , idtcpclient). server side show connected clients, , can select clients on list , send them commands or streams/files. created message queue, sugested mr. remy lebeau. here doing: what know is: is approach trying do? when 1 side starts read/writing, expects other side write/read? if other side can't? supose server requests file, doesn't exists, must client write "empty" stream anyway avoid problems? btw, can't find example of (indy 10 tcp communication), using queue, error handling, etc. on indy's website there many broken links. can sugest me website examples? thanks help! when 1 side starts read/writing, expects other side write/read? if other side can't? supose server requests file, doesn't exists, must client write "empty" stream anyway avoid problems? make client send reply accepting/rejecting request before file can transferre...

javascript - Angularjs: `$applyAsync` vs `$apply` with sockets -

i use sockets , lot of messages server. there handler every socket message , invoke $apply in every handler. better performance use $applyasync instead of $apply if there lot of messages , if so, why? frequent invoking of $apply makes app slow. unless you're receiving more 1 message every 4ms ( minimum resolution of settimeout in modern browsers ), it's unlikely you'll see performance improvement - in fact might find performance degrades touch additional timers added , fired. if receive many messages, may find helps since batch processing single digest cycle. without knowing socket it's hard make solid suggestion, aggregate data socket receiving , digest every n updates or throttle digests occur every 500ms or that?

osx - What are MinimalBookmark limitations in NSURLBookmarkCreationOptions? -

i @ first use suitableforbookmarkfile. however, database store bookmark takes 200mb. change minimalbookmark, database takes 98kb. 1/2040 of 200mb. in apple's doc, says specifies bookmark created option should created minimal information. produces smaller bookmark can resolved in fewer ways. anyone further explain on this? thanks. owen

jquery - Restrict getJSON / PHP query to server -

this question has answer here: prevent others calling json web service 1 answer i using js library requires json data passed in order display information. need parse data via php script, below: $.getjson('http://example.com/q.php?a=3298&b=test', function(data)... is there way restrict query server / localhost? don't want third-party person or website being able retrieve data going directly http://example.com/q.php?a=3298&b=test&callback= ? . it sounds want not restrict localhost , mean server access url (and unless browser running on server , you're person using it, isn't want). if understand correctly, need visitor accessing site able use within js code, don't want them snag url, modify parameters, , pull arbitrary data server. if that's case, you'll want encrypt or hash values pass. instead of you'r...

asp.net mvc - Best way to let Admin create User in ASP MVC -

in visual studio 2013 have created mvc project individual account (asp net identity 2.x). so @ url account/register (anonymous) user can sign up. now want admin user can create user (and in view there additional fields respect register view). what's best way accomplish this? use same route , view (account/register) show field in view according role of user? or create route/controller/view admin? i think best ways is: create admincontrooler in asp mvc or webapi (if any) , there write method user role admin. like: [authorize(roles = "admin")] public class admincontroller : apicontroller { [httppost] public void createuser(userviewmodel model) { ... logic } } this best practice because if need add few new methods user-admin only, add in controller

python - Translation url is not working on top menu in odoo (openerp) website ? -

i created top menus on custom module , working well. following code creating menu. <record id="cloud_menu" model="website.menu"> <field name="name">cloud</field> <field name="url">/#cloud</field> <field name="parent_id" ref="website.main_menu" /> <field name="sequence" type="int">2</field> </record> <record id="software_menu" model="website.menu"> <field name="name">software</field> <field name="url">/#software</field> <field name="parent_id" ref="website.main_menu" /> <field name="sequence" type="int">3</field> </record> .... but problem was, when selected arabic (or language other english) , choose of created top menu (only menus created module), l...

Predicate on a Map<String, String> field using spring-data-mongodb -

as subject says, have problems query involving predicate on map<string, string> field. i have following test case reproduces problem: @test public void testreferencespredicate() throws exception { //cleans event collection final dbcollection event = mongotemplate.getcollection("event"); event.drop(); final event anevent = new event(); //event has more fields final map<string, string> somerefs = new hashmap<>(); somerefs.put("a", "b"); anevent.setreferences(somerefs); final event save = this.eventrepository.save(anevent); assertnotnull(save); final booleanbuilder refpredicate = new booleanbuilder(); final map<string, string> references = new hashmap<>(); references.put("a", "b"); (final map.entry<string, string> s...

javascript - Redactor - Fixed toolbar not working on mobile -

according redactor docs regarding fixed toolbar settings , can pass toolbarfixed flag true, , toolbar should stay @ top of viewport user scrolls down, isn't working on mobile. my suspicion why doesn't work on mobile is: source code listening scroll event, when on mobile drag event. has encountered this? if work around? currently running version 10.1.3 suspect line: $(this.opts.toolbarfixedtarget).on('scroll.redactor.' + this.uuid, $.proxy(this.toolbar.observescroll, this)); this issue product , should fixed on end. however, if happen take long fix issue can write own script positioning toolbar not hard given toolbar exists in same context rest of page no iframes involved.

authentication - java run program using different credentials -

i want run executable jar different functional user credential , share colleagues use (without sharing username & password). i have tried runas there no way pass password in command. option /savecred won't me after system restart prompts password , wrong attempts lock functional account. suggestions? p.s. need programmatic fix. using tool market not option.

Android Lollipop view height doesn't fit screen -

Image
i'm working on bringing app targeting api level 18 support @ least lollipop level 21, i've run graphical issue. when targeting api level 21+ view seems large screen, , bottom of app truncated on screen buttons: the xml defined as: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <include layout="@layout/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content"/> <tabhost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" > <relativelayout android:layout_width="match_parent" ...

apache spark - How to perform basic statistics on a Json file to explore my numeric and non-numeric variable? -

i've imported json file has schema : sqlcontext.read.json("filename").printschema root |-- col: long (nullable = true) |-- data: array (nullable = true) | |-- element: struct (containsnull = true) | | |-- crate: string (nullable = true) | | |-- mlrate: string (nullable = true) | | |-- nrout: string (nullable = true) | | |-- up: string (nullable = true) |-- ifam: string (nullable = true) |-- ktm: long (nullable = true) i'm new on spark , want perform basic statistics like getting min, max, mean, median , std of numeric variables getting values frequencies non-numeric variables. my questions : how change type of variables in schema, 'string' 'numeric' ? (crate, mlrate , nrout should numeric variables) ? how basic statistics ? how change type of variables in schema, 'string' 'numeric' ? (crate, mlrate , nrout should numeric variables) ? you can create sche...

javascript - Function to submit form by id -

how can submit form using form id function param? that: html: <a href="#" onclick="confirmsubmit(form1)">delete file</a> javascript: function confirmsubmit(id) { var agree=confirm("are sure wish delete file?"); if (agree) document.getelementbyid('form' + id).submit(); else return false; } you can pass form id string parameter(means in single quotes) onclick function. see below <a href="#" onclick="confirmsubmit('form1')">delete file</a> function confirmsubmit(id) { var agree=confirm("are sure wish delete file?"); if (agree) document.getelementbyid(id).submit(); else return false; }

web - Compilation error on file lib/phoenix_ecto/html.ex -

while compiling project use elixir phoenix web framework, following compilation error occurs: ==> phoenix_ecto compiled lib/phoenix_ecto.ex compiled lib/phoenix_ecto/plug.ex compiled lib/phoenix_ecto/ison.ex ==> compilation error on file lib/phoenix_ecto/html.ex == ** (compileerror) ib/phoenix_ecto/html.ex:7: unknown key :impl struct phoenix.html.form (elixir) src/e ixir_map.erl:175: :elixir_map.--assert_struct_keys/5-1c$"011-0--/5 (elixir) src/e ixir_map.erl:48: :elixir_map.translate_struct/4 (elixir) src/e ixir_clauses.erl:36: :elixir_clauses.clause/7 (elixir) src/e ixir_def.erl:178: :elixir_def.translate_clause/7 (elixir) src/e ixir_def.erl:167: :elixir_def.translate_definition/8 [31m[1mcould not compile dependency phoenix_ecto, mix compile failed. can recompile dependency 'mix deps.compile phoenix_ecto' or update 'mix deps.update phoenix_ecto' how can project compile correctly? you need update both phoenix_ecto , phoenix_html. ...

java - How to specify maven properties in a aggregator POM? -

i have project structure below.in aggregator pom project1 , project 2 defined modules.now if want add maven property can accessed in projects how can it?. best project structure in case.? if define property <temp.dir>data</temp.dir> in aggregator pom not available in project1 pom.xml , project2 pom.xml.i have duplicate same property in both pom's. project - project1 - - pom.xml ---- has parent pom project - project2 - - pom.xml --- has parent pom project b - pom.xml (aggregator pom) update:to clarify more project1 pom , project 2 has different parent pom's.so aggregator pom cannot set parent. you need set aggregator pom parent of project1 , project2 . eg. in project1 , project2 poms add: <parent> <groupid>com.agr</groupid> <artifactid>project-aggregator</artifactid> <version>1.0.0</version> </parent> edit: i understand project1 , project2 have different parent poms. the so...

r - RenderPlot returns invisible plot on my local machine, but it is visible on other machines -

obligatory "i'm new r/shiny". in process of building app queries database, , returns plot of data retrieved. here generalised code being used return plot: app.r library(shiny) library(shinydashboard) library("rodbc") library(ggplot2) ui <- mainpanel(fluidpage( tabsetpanel( tabpanel("plot", plotoutput("plot1")) ) )) server <- function(input, output,session) { db <- odbcconnect(dsn="db", uid = "username", pwd = "password",believenrows=false ) plotquerytxt = paste("select * mytable") mydata <- sqlquery(db, plotquerytxt ) odbcclose(db) output$plot1 <- renderplot({ggplot(mydata,aes(column1,column2))+ geom_point()}) } shinyapp(ui, server) the issue here that, on personal machine, plot rendered invisible. when app run on other machines, or on remote server, plot can seen. question is: what causing plot v...

Bash script pass find files to awk [Mac] -

i have gzipped log files in directory , this: log/day_1_time_log_1.log.gz ... log/day_1_time_log_100.log.gz log/day_1_location_log_1.log.gz ... log/day_1_location_log_100.log.gz i take 4th column (some json strings) logs containing string time , cat them 1 file. did , getting zcat: unknown compression format error. find logs/* -name *time* | zcat | awk -f"\t" '{ print $4 }' > output.json what wrong code? can pass directly awk ? you can use xargs : find logs/ -name '*time*.log.gz' -print0 | xargs -0 -i % gzcat % | awk -f'\t' '{print $4}' > output.json

iron router - subdomain support in meteor (like with slack - http://team.slack.com) -

subdomain support in meteor (like slack - http://team.slack.com ) as in slack app users can create own subdomains (unique) , depending on subdomain data should loaded, , around application proceeded. can use http://slack.com?team=teamname , think subdomain clean , better. any suggestions/pointers. thanks. taken meteor forums . using dns wildcard point *.example.com app server, have in client code: var hostnamearray = document.location.hostname.split( "." ); if ( hostnamearray[1] === "example" && hostnamearray[2] === "com" ) { var subdomain = hostnamearray[0]; } if ( subdomain ) { meteor.call( "findteambysubdomain", subdomain, function (err, res) { var teamid = res; if ( teamid ) session.set( "teamid", teamid ); } }); } tracker.autorun ( function () { meteor.subscribe( "teaminfo", session.get( "teamid" ) ); }); make sure signed in user has permission...

javascript - AngularJS - Get value from non-input element to filter through list -

i'm trying retrieve value "li" element, depending on 1 user clicked on, responsible setting radius on map , display search results. these values either 5,10,25,50 or 100. number needs passed custom filter filter search results. html <ul class="cf" id="filter"> <li ng-click="getradius(5)" class="current"><a href="#">5 km</a></li> <li ng-click="getradius(10)"><a href="#">10 km</a></li> <li ng-click="getradius(25)"><a href="#">25 km</a></li> <li ng-click="getradius(50)"><a href="#">50 km</a></li> <li ng-click="getradius(100)"><a href="#">100 km</a></li> </ul> on search results, further down, want call filter. <li ng-repeat="store in stores | orderby:'-d':true" ng-click=...

php - How to escape all array elements from special characters while sending to mysql database -

i sending array has been passed view controller(ajax-json). in controller, collecting of them in array this: $to_update = array( 'name' =>$name, 'qualification' =>$qualification, 'percentage' =>$percentage, ); and sending model inserting in database, , call like $result = $this->model_name->func_name($to_update); and in model, insered like, $this->db->insert('table_name', $to_update); now have make sure sql injection handled , no harm takes place when special charecters entered user. have give escape functionality array. have huge arrays above hundreds of elements. while saving saves special charecter, while fetching, there problem , data lost. have take care of escaping, , how suggestions please. all of activerecord's query-building methods like ,where, group, order, insert, update , on, safe against sql injection long not pass them raw sql strings. codeigniter recognize type ...

xamarin - How to use a Custom iOS View(located in a referenced Class Library) in an Interface Builder file? -

Image
i have 2 projects. first 1 ios-app referencing class library target framework xamarin.ios . in class library implemented customview inherits uiview . registered "register" attribute. so in interface designer prefilled information use class custom class after dragged uiview viewcontroller . when run app following information: "unknown class mycustomview in interface builder file." if move customview class library project first project run expected. does know how use customview , located in referenced class library, in interface builder file? i don't think it's possible register accross project boundaries. in tests, when use exact same namespace, still end error. what is possible, on other hand, use proxy class , make use of inheritance bring desired behaviour proxy. basically, boils down this: 1) in library, define custom uiview , implement behaviour want share: public class mycustomuiview : uiview { public mycustom...

javascript - how to run node js file from php using system command in mac -

i running node js file using system command in php. php code system('cd path && node sample'); when run code in windows working fine . when transported mac not executing . please tell me how can in mac. how run node js file php using system comand in mac

java - Null pointer exception in Simple Facebook library to getPosts? -

i imported this library posts set imports , so, have follow steps , wirte code,actually wanted show page's public posts in app.like apps or website keeps looks facebook's real page. possible or not in android? thanks. package algonation.com.myapplication; import android.graphics.paint; import android.os.bundle; import android.support.v7.app.actionbaractivity; import android.text.html; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.button; import android.widget.textview; import com.sromku.simple.fb.simplefacebook; import com.sromku.simple.fb.actions.cursor; import com.sromku.simple.fb.entities.post; import com.sromku.simple.fb.listeners.onpostslistener; import java.util.list; public class facebookactivity extends actionbaractivity { private final static string example = ""; private string mallpages = ""; onpostslistener onpostslistener = new onpostslistener() { @...

Universal Windows 10 - How to add button in title bar like Microsoft Edge? -

i use extend view titlebar this: coreapplication.getcurrentview().titlebar.extendviewintotitlebar = true; and xaml code is: <page x:class="projectx.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:projectx" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d"> <grid background="{themeresource applicationpagebackgroundthemebrush}"> <grid background="#263238" height="32" verticalalignment="top" requestedtheme="dark"> <textblock text="title bar" verticalalignment="center" horizontalalignment="center"/> <button width="50" height="32" click="button_click"/> ...

ios - An app that will show emergency Contacts on lock screen -

i have been researching regarding showing emergency contacts on lock screen in ios did not regarding this. basically want create app show emergency contact number on lock screen can useful in case if 1 injured or lost phone. can someone's family contact number. in case injured unconscious helper can contact family. you cannot show on lock screen (unless have jailbroken device). could though, create today widget . today screen accessible lock screen, without unlocking iphone.

ruby on rails 4 - sidekiq Cannot define multiple 'included' blocks for a Concern -

cannot define multiple 'included' blocks concern /home/andreydeineko/.rvm/gems/ruby-2.0.0-p643@app_name/gems/activesupport-4.1.9/lib/active_support/concern.rb:126:in `included' /home/andreydeineko/.rvm/gems/ruby-2.0.0-p643@app_name/gems/high_voltage-2.1.0/app/controllers/concerns/high_voltage/static_page.rb:4:in `<module:staticpage>' /home/andreydeineko/.rvm/gems/ruby-2.0.0-p643@app_name/gems/high_voltage-2.1.0/app/controllers/concerns/high_voltage/static_page.rb:1:in `<top (required)>' /home/andreydeineko/.rvm/gems/ruby-2.0.0-p643@app_name/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:443:in `load' /home/andreydeineko/.rvm/gems/ruby-2.0.0-p643@app_name/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:443:in `block in load_file' /home/andreydeineko/.rvm/gems/ruby-2.0.0-p643@app_name/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:633:in `new_constants_in' /home/andreydeineko/.rvm/gems/ruby-2.0.0-p643@a...

How to write copy() method for Simple Class in Scala -

i have class person class person(val name: string, val height : int, val weight: int) i want write copy() method class can work same copy method case classes(copy , update attribute of object) i know copy() comes case class not using them want same thing class please guide me how can this? just create copy method includes parameters fields class definition, uses existing values default parameters, create new instance using parameters: class person(val name: string, val height : int, val weight: int) { def copy(newname: string = name, newheight: int = height, newweight: int = weight): person = new person(newname, newheight, newweight) override def tostring = s"name: $name height: $height weight: $weight" } val person = new person("bob", 183, 85) val heavy_person = person.copy(newweight = 120) val different_person = person.copy(newname = "frank") list(person, heavy_person, different_person) foreach { println(_) } ...

scala - how to add adjacent values in Array[Double] -

val values = array[double].sliding(2).map(x => x.reduce(_ + _) / 2) this works successfully. if array contains 10000 or more values, take times values. there faster method find adjacent values? i think should faster: val values = (for(i <- 0 until array.length - 1) yield ((array(i) + array(i + 1)) / 2)).toarray

visualization - plotting different columns in r -

Image
data = 110 columns( x1: x100) (numeric) i trying plot columns using following code, x2=melt(x1) ggplot(x2,aes(x = value)) + facet_wrap(~variable,scales = "free_x") + geom_histogram(aes=(density)) +title(sub = s, line = 5.5) s<-summary(x1) i'm want append summary data every column in plot analysis . there alternate this? thanks. to knowledge, cannot add subtitles subplots of facet_wrap. change title accomodate want though. here example min, max, mean , median : data = data.frame(x1=rnorm(100), x2=rnorm(100), x3=rnorm(100), x4=rnorm(100), x5=rnorm(100), x6=rnorm(100)) library(dplyr) library(tidyr) library(ggplot2) x <- data %>% gather(variable,value) %>% group_by(variable) %>% mutate(mean=mean(value), median=median(value), min=min(value), max=max(value), ...

javascript - Get current values inside Sails' Waterline beforeUpdate hook -

in sails' waternline need able compare previous value new 1 , assign new attribute under condition. example: beforeupdate: function(newvalues, callback) { if(/* currentvalues */.age > newvalues.age) { newvalues.permission = false; } } how access currentvalues ? i'm not sure best solution can current record doing simple findone request: beforeupdate: function(newvalues, callback) { model .findone(newvalues.id) .exec(function (err, currentvalues) { // handle errors // ... if(currentvalues.age > newvalues.age) { newvalues.permission = false; } return callback(); }); }

javascript - How to use sweetalert in a .js file -

so have .js file, , i'm trying throw message user using sweetalert. moreover, want load .js , .css files of sweetalert, dynamically inside .js file. // load script var filerefjs = document.createelement('script'); filerefjs.setattribute("type", "text/javascript"); filerefjs.setattribute("src", "../../rotatescreen/dist/sweetalert.min.js"); // load css file var filerefcss = document.createelement("link"); filerefcss.setattribute("rel", "stylesheet"); filerefcss.setattribute("type", "text/css"); filerefcss.setattribute("href", "../../rotatescreen/dist/sweetalert.css"); if (window.innerheight < window.innerwidth){ window.onload = function(){ document.getelementbyid('b6').onclick = function(){ swal({title: "", text: "message", imageurl: "../../rotatescreen/example/images/...

python - Render HTML tags from variable without escaping -

this question has answer here: passing html template using flask/jinja2 3 answers i have html content want pass template render. however, escapes tags use html entities ( &lt; ), show code rather markup. how can render html passed template? tags = """<p>some text here</p>""" render_template ('index.html',tags=tags) {{ tags }} '&lt; text here &gt;' i want paragraph text though. some text here use jinja2 safe filter: {{ tags | safe }} safe filter tells template engine not auto-escape string (because escaped manually or you're sure string safe). so, if string introduced user , didn't escape it, rise security problems ("don't trust user"). edit as @davidism pointed there method - recomended 1 - pass html template: using markup object in python code...

ElasticSearch - How to display an additional field name in aggregation query -

how can add new key called 'agency_name' in output bucket. i running aggregation code shown below { "aggs": { "name": { "terms": { "field": "agency_code" } } } } i getting out put as "aggregations": { "name": { "doc_count_error_upper_bound": 130, "sum_other_doc_count": 39921, "buckets": [ { "key": "1000", "doc_count": 105163 }, { "key": "2100", "doc_count": 43006 } ] } } while displaying need show agency name, code , doc_count how can modify aggregation query below format. new elasticsearch, not sure how fix "aggregations": { "name": { "doc_count_error_upper_bound": 130, ...

php - Get and output ID from Mysql -

currently id <?= $store->id ?> , works fine but want id of mysql entry with $id = $_get['store_id']; $query = "select * store id = '$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result); or $id = $_get['$store->id']; $query = "select * store id = '$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result); and output <?php print $row["id"];?> but doesn't gives me id, remains empty. doing wrong? (i aware working mysql_... not best way, that's not problem now). if $store->id works fine you, means you're doing wrong, , defined $store earlier, in file. param url, need use $_get["param"] . if $_get["store_id"] doesn't work didn't set id in url. if want param name $store->id , use $_get[$store->id] , don't t...