Posts

Showing posts from April, 2014

c# - Use Url.Action to generate fully qualified anchor -

i'm using url.action generate link in e-mails (with postal mvc framework) sent application, however, links generates showing "localhost" name, , not domain name. i'm using following code: @url.action("alterarsenha", "account", null, this.request.url.scheme) the result following: http://localhost/account/alterarsenha after that, tried following code: @url.action("alterarsenha", "account", null, this.request.url.scheme, request.servervariables["http_host"]) and got same result. how can link domain like: http://www.servicili.com/account/alterarsenha assuming want use domain name in url when application runs on localhost, use overload of url.action : public virtual string action( string actionname, string controllername, routevaluedictionary routevalues, string protocol, string hostname ) and pass domain name hostname . https://msdn.microsoft.com/en-us/library/system

excel - Loop through range, if match copy specific cell -

i have formula working, looks value , if there match between sheets prints out row match in. if match if found copy value column b in same row value found. so if match found between a2 in sheet1 , range a:a in sheet2, , lets row 5, want copy b5. possible? =if(iserror(match(a1;indata!a:a;0));""; match(a1;sheet2!a:a;0)) =if(iserror(match(a1,sheet2!a:a,0)),"",index(sheet2!b:b,match(a1,sheet2!a:a,0)))

python - Sum same column in different ways depending on other column - Django ORM -

i have following table assignment structure: | employee | product | process | qty | | swati | prod1 | issue | 60 | | rohit | prod1 | issue | 30 | | rohit | prod2 | issue | 40 | | swati | prod1 | receive | 40 | | swati | prod2 | issue | 70 | i want final table each employee (say employee = 'swati' ): | product | sum_issued | sum_received | prod1 | 60 | 40 | | prod2 | 70 | 0 | the sql query is: select product , sum(case when process='issue' qty else 0 end) sum_issued , sum(case when process='receive' qty else 0 end) sum_received assignment employee = 'swati' group product; what should django query be, corresponding result? i guess model name ' assignment '. can use below query from django.db.models import case, value, when, sum, integerfield, count result = assignment.objects.filter(employee="swati").values('

converter - How to convert an MP3 file to an OGG OPUS file? -

is there converter can convert mp3 file ogg opus ? can recommend me 1 can it? so far i've tried adobe audition , xilisoft audio converter pro , winavi video converter , aimersoft video converter pro ...and none of them useful try ffmpeg -acodec libopus

svg - How to print inkscape exported file to standard output and read from standard input -

i use inkscape generate custom google markers application i'm creating. since google maps don't support svg files directly, i'm planning change parameters inside svg file then, redirect file inkscape , print exported png standard output, cgi script can use sending results browser display. do have suggestions on how achieve that? in unix/linux environment, can use pseudofiles /dev/stdin , /dev/stderr achieve this, e.g. bash shell: cat file.svg | awk -f script.awk | inkscape /dev/stdin -e /dev/stderr 2> file.png note inkscape sends text output /dev/stdout (which weird choice), hence have use stderr not image mixed text.

How to prevent opening a new instance of MATLAB when multiple times run a Java program -

i'm calling matlab program eclipse java interface. have used matlabcontrol it. when run java program multiple time, every time opens new instance of matlab, , makes computation slower. is possible can prevent opening new instances of matlab? if possible, how can this? if have opened terminal of matlab, possible computation can use terminal, instead of opening new instance of matlab? any appreciable. the matlabcontrol can not connect open instance of matlab, can create new one. to prevent multiple matlab instances being opened, can use proxy.exit() instead of proxy.disconnect() close matlab when closing application. to further use single instance of matlab across multiple instances of java program, see different possibilities no one. matlab comes it's own jvm , start java applications matlab console using . officially documented, can call java functions matlab, other way round possible well . please matlab uses it's own jvm might outdated. implem

ios - Realm can't decrypt database error in background thread -

i using realm objective-c swift supporting ios7 in app. i use function write block of code realm in background thread. wanted add encryption modified function so: class func updaterealmwithblockinbackground(block: () -> void) { let priority = dispatch_queue_priority_default dispatch_async(dispatch_get_global_queue(priority, 0)) { { let config = rlmrealmconfiguration.defaultconfiguration() config.encryptionkey = utils.getkey() let realm = try rlmrealm(configuration: config) realm.beginwritetransaction() block() realm.commitwritetransaction() } catch { dispatch_async(dispatch_get_main_queue(), { txnotificationsystem.postglobalnotification(text: "\(error)", textcolor: uicolor.redcolor()) }) } } } i getting error code 2: unable decrypt realm. if use 1 write on main thread don't seem getting error. anyone know why it's givin

java - How to access data from RestTemplate as List -

i want access data spring boot service. return type of data list , every time access it, list empty. this code: map<string, string> params = new hashmap<string, string>(); params.put("firstname", "test" ); params.put("lastname", "test1"); responseentity<person[]> response = resttemplate.getforentity(url, person[].class, params); in case, response.getbody() empty [] . @requestmapping(value = "/search", method = requestmethod.get) public list<person> searchusers( @requestparam(value = "firstname", required = false) string firstname, @requestparam(value = "lastname", required = false) string lastname, @requestparam(value = "email", required = false) string email { return personservice.search(firstname, lastname, email, company); } i tried string , , person[] , nothing worked. thanks in advance! @get @path("statement") @pro

conditional - How do I perform an action on a field for Swift UI Tests based on the contents/state of the field? -

i have usernamefield. on initial state, field empty. if log in successfully, , log out, remembers username me. trying create test case ios (in swift) clear out field (use cleartext button) if field has content , enter desired string. if it's empty, needs skip cleartext button action (since doesn't exist when field value nil) , go straight entering username. it skips if statement, when it's true. looks cleartext button, , fails. works if there's value in field, though. tried lots of different approaches, here's best current working code. open suggestions, have no 1 me learn stuff. i'm sure i'm missing fundamental: let staffusernameloginfield = app.scrollviews.otherelements.textfields["staffusernameloginfield"] staffusernameloginfield.tap() func checkusernamefieldcontents() { if staffusernameloginfield == (content:nil) { staffusernameloginfield.typetext("owner") } else {

swing - Java JTextPane auto-scroll stops working after selecting text -

so issue has been bugging me long time now, , renders game unplayable if triggered. situation have 4 items in gui: private jpanel panel; private jtextpane content; private jscrollpane scroll; private jtextfield input; the whole thing setup in borderlayout, caret update policy automatically scrolls screen whenever text reaches bottom. however, if select text in jtextpane, of sudden autoscroll stops working, , new text added pane remains invisible until user manually scrolls scrollbar. i've attempted reapplying caret update policy every time text appended didn't work. haven't clue how fix this, , attempts google problem have been fruitless. reference, here relevant code constructor: setdefaultcloseoperation(jframe.exit_on_close); setsize(width, height); setresizable(false); panel = new jpanel(); input = new jtextfield(30); input.setbackground(color.black); input.setforeground(color.green); input.setfont(new font(font.sans_serif, font.plain, width / 40)); input.adda

performance - Speed up for loop in Matlab -

i have following for loop makes program runs slow when file size big. best way vectorize it. i read data ply file here using command, data = textread(filename, '%s','delimiter', '\n'); . data n*1 cell array. each element in data 7*1 cell array of char values. sample data file here . for = 1:length(data)-1 pc(i, 1) = (str2double(cellstr(data{i,1}{1,1}))); pc(i, 2) = (str2double(cellstr(data{i,1}{2,1}))); pc(i, 3) = (str2double(cellstr(data{i,1}{3,1}))); pc(i, 4) = (str2double(cellstr(data{i,1}{4,1}))); pc(i, 5) = (str2double(cellstr(data{i,1}{5,1}))); pc(i, 6) = (str2double(cellstr(data{i,1}{6,1}))); end this want >> pc = str2double([data{:}].') pc = 0.1033 -0.2737 0.8570 221.0000 196.0000 174.0000 255.0000 0.1054 -0.2731 0.8550 220.0000 195.0000 173.0000 255.0000 ... 0.1139 -0.2803 0.8490 221.0000 194.0000 172.0000 255.0000 0.1117 -0.2829 0.8500 225.000

java - Maven seems to be using an older version than the one I expect -

i'm having strange problem maven. i'm not sure yet seems when compiling project (with mvn clean compile) somehow wrong version of dependency seems included. the library want include commons-io version 2.4 . when check ide looks correct version loaded. compiling in ide works fine. however when compile project maven line of code fails: fileutils.write(new file(propertyservice.getstatuspagelocation()), "some string value"); because of error: [error] /c:/projects/my-project/client-externalclient/src/main/java/be/roots/myproject/client/externalclient/jobs/writestatuspagejob.java:[60,22] cannot find symbol [error] symbol: method write(java.io.file,java.lang.string) as far can tell class have method signature. problem seems happen on pc. a dependency:tree command shows following info: [info] --- maven-dependency-plugin:2.8:tree (default-cli) @ shared-internal --- [info] be.roots.myproject:shared-internal:bundle:3.40-snapshot [info] +- be.roots.myproject

javascript - Select boxes not getting displayed on iteration -

trying select boxes through loop. 1 item getting displayed. <table> <tbody id="addto_tb"></tbody> </table> var nodeslist = ['node1','node2','node3']; var select = $('<select/>'); $('<option />', {value: 'node1', text: 'node1'}).appendto(select); $('<option />', {value: 'node2', text: 'node2'}).appendto(select); $(nodeslist).each(function(iter,elem){ alert(elem); var trele = $(document.createelement("tr")); trele.addclass(" "+iter); var tdele = $(document.createelement("td")); $(tdele).append(select); trele.append(tdele); $('#addto_tb').append(trele); $($($('#addto_tb').find("."+iter)).find('select')).val(elem); }); in case 3 select boxes should come. 1 displays. when put alert, can see 3 select boxes coming 1 gett

jquery - How to add checkboxes dynamically using javascript? -

i use bootstrap , have form 2 textfields , 2 checkboxes. add-button, want add (per click) additional textfield checkbox. i'm using js: $("#addbutton").click(function () { var newtextboxdiv = $(document.createelement('div')) .attr("id", 'textboxdiv' + counter); /* todo: patterns festlegen */ newtextboxdiv.after().html('<div class="form-group label-floating">' + '<label class="control-label">answer' + counter + '</label>' + '<input type="text" class="form-control"/>' + '</div><div class="togglebutton"><label><input type="checkbox" checked="">toggle on</input></label></div>'); newtextboxdiv.appendto("#answergroup"); counter++; }); it adds textfield, checkbox isn't showing up, text "toggle o

sql - Select a specific number of rows in a loop when the key is not number but an alphanumeric value -

i @ trying select 1000 rows tables in sql server , in cases easy because have key bigint. thus, store last number of key have fetched , add 100. see below: --get last loaded record declare @startindex bigint set @startindex = 1 + (select [storedindex] [db].[dbo].[masterdata] [status] = 'lastload') --declare , set last record loaded declare @endindex bigint --retrieve next @step+1 or less records , store them in temporary table select t1.* #tempresults --get next @step+1 or less records (select * anotherdb.[tablename] [tables_id] between @startindex , @startindex + 1000) t1 --set index of last record inserted set @endindex = (select max([tables_id])--the next record fetched largest id #tempresults) however how when key alphanumeric value? what equivalent for where [tables_id] between @startindex , @startindex + 1000 if @startindex nvarchar , example 123g7_56y7f ? thank you!

osx - mongo shell not showing all dbs -

good day. i've been developing meteorjs uses mongodb. no problems there. i've been using mongo shell access database on dev machine (osx 10.11). first project mongo , when shell load, connect db.test , i'd show dbs , list of database, use myapp . yesterday whenever go shell , type show dbs 1 shown local 0.078gb . app still working , pulling , pushing data database. i've checked dbpath in mongod.conf , seems ok. i'm not entirely sure exact order of things, 2 things different (i'm not sure if these happened prior show dbs not showing or after, , i'm not sure came first): when loading mongo shell getting error: warning: soft rlimits low. number of files 256, should @ least 1000" i followed these directions seemed stop error appearing ( https://github.com/basho/basho_docs/issues/1402 ) i use meteor toys , first time update user.profile.companyname (which custom field within standard profile within meteor toys widget. just odd

python - How to identify more than one label for an entity using Stanford NER -

i want identify word or entity 2 labels. for example: john works in india. output should be: john per nnp works o o in o o india loc nnp so should identify named entity pos tags . i have created own set of training data. i using below property file trainfile = training.tsv serializeto = model.ser.gz map = word=0,answer=1,tag=2 useclassfeature=true useword=true usengrams=true nomidngrams=true maxngramleng=6 useprev=true usenext=true usesequences=true useprevsequences=true usetags = true usewordtag = true usegenericfeatures = true mergetags = true maxleft=1 usetypeseqs=true usetypeseqs2=true usetypeysequences=true wordshape=chris2uselc usedisjunctive=true the training file looks this: john per nnp works o o in o o india loc nnp i using below code run ner in python: tagging_ner = stanfordnertagger('.../model.ser.gz','.../stanford-ner.jar',encoding='ut

c# - how to add many colors to single paragraph -

Image
i try make multi color in same line list wrong result i need make below image : my current code : paragraph = range.paragraphs.add(); paragraph.range.text = "test"; paragraph.range.font.color = word.wdcolor.wdcolorskyblue; paragraph = range.paragraphs.add(); paragraph.range.text = "word"; paragraph.range.font.color = word.wdcolor.wdcolorred; paragraph = range.paragraphs.add(); paragraph.range.text = "color"; paragraph.range.font.color = word.wdcolor.wdcolorbrown; the result show 3 lines since need 50 rep comment, i'll mark answer. reading, should make sentence class , when you're done sentence add paragraph.

android - Handling screen rotation in WebView -

my web app works great in chrome handles configuration changes (such screen rotation) excellent. preserved. when loading web app webview in android app web app loses state on screen orientation change. partially preserve state, i.e. preserves data of <input> form elements, javascript variables , dom manipulation gets lost. i webview behave way chrome does, i.e. preserving state including javascript variables. should noted while chrome , webview derives same code base chrome not internally use webview. what happens on screen orientation change activity (and eventual fragments) gets destroyed subsequently recreated. webview inherits view , overrides methods onsaveinstancestate , onrestoreinstancestate handling configuration changes hence automatically saves , restores contents of html form elements back/forward navigation history state. state of javascript variables , dom not saved , restored. proposed solutions there have been few proposed solutions. of them

javascript - jquery convert time from english to french -

i need change time on site english french ie 7:15 pm = 19 h 15. not have access end change time format. using indexof , .replace. works first pm in p how can loop them. here code far. <script> function myfunction() { var str = "12:00 test text @ 9:10 pm se second 6:00 pm doe not works."; var matchs = str.match(/pm/gi); //can used loop amount var n = str.indexof("pm")-6; //first digit before pm var n2 = str.indexof("pm")-5; //second digit before pm var res = str.charat(n) + str.charat(n2);// add var myinteger = parseint(res)+12;// make ind , add 12 var str1= str.replace(res ,' '+myinteger).replace('pm','').replace(/pm/g,'').replace(/:/g,' h ').replace(/00/g,' ').replace('am','');// replace alert(str1); document.getelementbyid("demo").innerhtml = str1 } thanks maybe this: var str = $('#time').text(); var t = str.match(/[\d:]+(?= pm)/

c# - Repository as parameter -

i created generic dropdown list use in controller: genericdropdownlist("mydropdown"); private void genericdropdownlist(string dropdownname, object selecteddepartment = null) { var dropdownquery = unitofwork.salesrepository.get(orderby: q => q.orderby(d => d.firstname)); viewdata[dropdownname] = new selectlist(dropdownquery, "lastname", "lastname", selecteddepartment); } this seems work fine. i'm trying make unitofwork.testrepository dynamic, can use every available repository in function: genericdropdownlist("mydropdown", salesrepository); private void genericdropdownlist(string dropdownname, object repository, object selecteddepartment = null) { var dropdownquery = repository.get(orderby: q => q.orderby(d => d.firstname)); viewdata[dropdownname] = new selectlist(dropdownquery, "lastname", "lastname", selecteddepartment); } the above doesn't work. following

ecmascript 6 - Is "type" a keyword in JavaScript? -

i came across using "type" in a piece of es6 code . export type action = { type: 'todo/complete', id: string, } | { type: 'todo/create', text: string, } | { type: 'todo/destroy', id: string, } | { type: 'todo/destroy-completed', } | { type: 'todo/toggle-complete-all', } | { type: 'todo/undo-complete', id: string, } | { type: 'todo/update-text', id: string, text: string, }; couldn't find sheds light on it. keyword? do? as mentioned pitaj , type symbol here not part of es6, rather part of flow static type checker . here docs type symbol .

ios - I am receiving a "cannot initialize a parameter of type" error with theos -

i getting error while trying compile project. error "tweak.xm:37:21: error: cannot initialize parameter of type 'uiview * _nonnull' lvalue of type 'uitapgesturerecognizer *' [content addsubview:singletap];" this image of error link about comment on alexander-li's answer, add line in makefile : tweakname_frameworks = uikit and add #import <uikit/uikit.h> tweak.xm file. and please, learn how code before launching in theos development. it's not easiest environment there lot of pages can you.

c++ - Destructor for LinkedList of LinkedLists -

for assignment in 1 of programming classes have make adjacency list linked list of linked lists this. a->b->c ↓ b->a->d ↓ c->d ↓ d->a->b->c i'm having trouble memory leak when trying free memory allocated in destructor. i've been trying figure out while haven't found/come solutions work. also, please ignore implementation included in header file. told ok assignment. valgrind error message: ==2316== heap summary: ==2316== in use @ exit: 48 bytes in 2 blocks ==2316== total heap usage: 3 allocs, 1 frees, 64 bytes allocated ==2316== ==2316== 48 (32 direct, 16 indirect) bytes in 1 blocks lost in loss record 2 of 2 ==2316== @ 0x4c2b0e0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==2316== 0x4012ee: main (main.cpp:34) ==2316== ==2316== leak summary: ==2316== lost: 32 bytes in 1 blocks ==2316== indirectly lost: 16 bytes in 1 blocks ==2316==

c++ cli - Pass native array as managed array from C++/CLI -

i have 3rd party lib controls camera. written in c++ , want consume c#. lib grabs image byte*. there ways pass c#. pass byte* directly c# unsafe statement. in case, c# code can't change image size crop operation. use marshal.copy create managed byte array , pass it. gives flexibility c#, there overhead , additional memory usage. so, question is: there way convert byte* managed byte[] without copy? because managed byte array fixed statement "blittable", think there can "reverse direction" method. any appreciated, thank you.

windows - Monitoring memory addresses in Python -

i need know how monitor memory address , values in python. example: have game written in c. want write python script read memory address of current hitpoints , take actions based on values. i can memory addresses cheatengine, don't know how use in python. here's read_process function. result either bytes (2.x str ), or array of ctypes structures. default read 1 byte process. optional dtype parameter must ctypes type, such ctypes.c_cint or ctypes.structure subclass. reads array of given type , length . be careful avoid dereferencing pointer values. example, if pass dtype=c_char_p , indexing result array try dereference remote pointer in current process, crash python. in previous answer wrote read-only remotepointer class if need handle case. ctypes definitions import ctypes ctypes import wintypes kernel32 = ctypes.windll('kernel32', use_last_error=true) process_vm_read = 0x0010 size_t = ctypes.c_size_t psize_t = ctypes.pointer(size_t) def

Random position in string array? Java -

working on building tic tac toe game. i'm trying use simple of methods possible. i'm working on getting cpu randomly choose spot in array place "o" at. how go doing this? have far. import java.util.scanner; import java.util.random; public class player { string player = "x"; string cpu = "o"; //private int[][] theboard= new int [3][3] ; private string[][] theboard= {{" "," "," "}, {" "," "," "}, {" ", " "," "}};; random cpuinput = new random(); private board board1; public static scanner scan = new scanner(system.in); public player(board board, string inboard ) { theboard = theboard; } public void computermove() { string spacing = " "; (int = 0; < theboard.length; i++) { (int j = 0; j < theboard[i].length; j++) { //i

ruby on rails - Is it possible to associate records N-N multiple times via different name? -

i'm using mongoid. if task has list of writers, task has_many :writers , writer has_many :tasks . what if want task has_many :editors well, have writer model act editor? in other words, there way relate same model twice? something this, please check correctness , adjust if needed has_many :editors, class_name: "writer", inverse_of: :writter so should use inverse_of , class_name

javascript - Owl Carousel 2 - how to get a current item? -

i working on web site owl carousel 2. want detect item displayed on front. it used this. http://owlgraphic.com/owlcarousel/demos/owlstatus.html $(document).ready(function() { var owl = $("#owl-demo"), status = $("#owlstatus"); owl.owlcarousel({ navigation : true, afteraction : afteraction }); function updateresult(pos,value){ status.find(pos).find(".result").text(value); } function afteraction(){ updateresult(".currentitem", this.owl.currentitem); } }); but example of version 1. in version 2, above doesn't work, , seems should use "info" according official document. http://owlcarousel.owlgraphic.com/docs/api-options.html#info i tried figure out it, there no example or documents. went through .js file, couldn't it. wonder if "info" not implemented yet. i don't want know info, want data of current item. i tried way below, doesn't work correctly. have possibl

visual studio - Xamarin Sport App - Unknown Identifier -

Image
i looking @ sample application sports leagues found here: https://github.com/xamarin/sport i put breakpoint here: but when hover/do quick watch on athleteid and/or registraitoncomplete, get unknown identifier: settings the thing is, can step settings know can find – heck shouldn’t compile without it… no answers yet, here solution still looking for settings static class, somehow visual studio(xamarin) not recognize static class actual path , namespace not match. so, access settings namespace below, need use sport.mobile.shared.settings. namespace sport.mobile.shared { public static class settings this applies static class use in project.

r - lubridate, calculate years, return NA -

hello have problem calculation age of subject knowing date of birth, using the lubridate package, sample: > head(df$hs_dob1c) [1] 2002-01-30 2004-12-29 2005-09-15 2002-12-20 2005-07-28 1995-08-28 firstly set: df$hs_dob1c <- as.date(df$hs_dob1c, format='%y-%m-%d') then: today <- as.date(sys.date(), format="%y-%m-%d") ref_date <- as.date(df$hs_dob1c, format="%y-%m-%d") the problem when set reference because: > head(df$hs_dob1c) [1] na na na na na na not sure used lubridate , try df$hs_dob1c <- as.date(df$hs_dob1c, format='%y-%m-%d') instead of df$hs_dob1c <- as.date(df$hs_dob1c, format='%y-%m-%d') %y indicates 2-digit year, have 4-digit year should referred %y

linux - Get SD card serial / oemid from U-boot on RaspberryPi3 -

i'm using u-boot on raspberry pi 3 , want obtain sd card oemid or serial number. "normally" can done accessing /sys/block/mmcblk0/device/ or running udevadm info -a -n /dev/sdx on linux site, wonder: is possible via u-boot (i.e. without running kernel) ? so, in order enough information device able use root=partuuid= syntax linux kernel need have few commands enabled in u-boot. functional example of can found here . shell prompt command just: => part uuid interface device:partition variable-to-store-in and requires have config_cmd_part set in turn requires config_partition_uuids.

haskell - Type mismatch between FileInfo and Text -

i'm following this tutorial , got type mismatch error while creating function builds form. i don't know import should post here, there's all: import control.applicative import data.text (text, unpack) import qualified data.text t import qualified data.bytestring.lazy dbl import data.conduit import data.conduit.list (consume) import yesod import yesod.static import yesod.form.bootstrap3 import data.time (utctime, getcurrenttime) import control.monad.logger (runstdoutloggingt) import database.persist import database.persist.sqlite import system.filepath import system.directory (removefile, doesfileexist) and code: data page = page share [mkpersist sqlsettings, mkmigrate "migrateall"] [persistlowercase| image filename text description textarea date utctime deriving show |] instance yesod page type form = html -> mform handler (formresult a, widget) uploadform :: form image uploadform = renderdivs $ image <

asp.net - Deleting is not supported by data source 'SqlDataSource1' in c# -

this cs: protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { sqlconnection con = connection.dbconnection(); if (e.commandname == "editrow") { gridviewrow gr = (gridviewrow)((button)e.commandsource).namingcontainer; textid.text = gr.cells[0].text; textusername.text = gr.cells[1].text; textclass.text = gr.cells[2].text; textsection.text = gr.cells[3].text; textaddress.text = gr.cells[4].text; } else if (e.commandname == "deleterow") { gridviewrow gr = (gridviewrow)((button)e.commandsource).namingcontainer; sqlcommand com = new sqlcommand("storedprocedure4", con); com.commandtype = commandtype.storedprocedure; com.parameters.addwithvalue("@id", gr.cells[0].te

php - How to convert quotes(',") from special char to general with other tags remaining special? -

in string have quotes (',") , < tags > . used htmlspecialchars($str, ent_quotes); to convert single , double quote general text . unfortunately converting tags < , > . reason have strip_tags("$desc","< b >< font >< >< u >< br >"); those allowed tags displaying general < , > sign not working html tags . in conclude , want display single , double quote regular text , allowed tags working html does. thank you. why don't run strip_tags() before htmlspecialchars() ? sample: <?php $input = '<b>allowed tag</b> " <font>not allowed tag</font>'; // xxx $tmp = htmlspecialchars($input, ent_quotes); $result = strip_tags($tmp, '<b>'); var_dump($result); // string(78) "&lt;b&gt;allowed tag&lt;/b&gt; &quot; &lt;font&gt;not allowed tag&lt;/font&gt;" // improved $tmp = strip_tags($input

powershell - Determine folder IDs with Invoke-RestMethod on Office 365 -

when provide in powershell: invoke-restmethod -uri " https://outlook.office365.com/api/v1.0/users/andrew.stevens@mydomain.com/folders/ " -credential $cred | foreach-object{$_.value |select displayname,id} i determine folder ids, not folders visible. how complete listing of folders (the 1 particular want recoverable items). i'm thinking once id can see messages folder contain..? thanks //a did mean deleted items folder? if understand correctly, should listed rest calling. , can use well-known folder names: deleteditems messages. here example reference: get: https://outlook.office.com/api/v2.0/me/mailfolders/deleteditems/messages update to use office 365 rest api, need use bearer token need register app first. below sample access token via powershell reference(refer obtaining access token ): #region construct azure datamarket access_token #get clientid , client_secret https://datamarket.azure.com/developer/applications/ #refer obtaining

javascript - jQuery - hide an element inside bootstrap modal -

i trying hide button (assume buttona) inside bootstrap modal popup. here have buttonb , buttonc @ different places , both used trigger same popup problem have hide buttona when popup triggered buttonb , show when triggered buttonc. i tried below generic code in jquery not working me, there way make happen while using bootstrap modal popup. $('#buttonb').click(function() { alert('test'); $('#buttona').hide(); }); if #buttonb dynamically created element use jquery's .on() function in following format: $(staticancestors).on(eventname, dynamicchild, function() {}); staticancestors closest parent element static. $(staticancestors).on('click', '#buttonb', function() { alert('test'); $('#buttona').hide(); });

python - Counting dates in a range set by pandas dataframe -

i have pandas dataframe contains 2 date columns, start date , end date defines range. i'd able collect total count dates across rows in dataframe, defined these columns. for example, table looks like: index start_date end date 0 '2015-01-01' '2015-01-17' 1 '2015-01-03' '2015-01-12' and result per date aggregate, like: date count '2015-01-01' 1 '2015-01-02' 1 '2015-01-03' 2 and on. my current approach works extremely slow on big dataframe i'm looping across rows, calculating range , looping through this. i'm hoping find better approach. currently i'm doing : date = pd.date_range (min (df.start_date), max (df.end_date)) df2 = pd.dataframe (index =date) df2 ['count'] = 0 index, row in df.iterrows (): dates = pd.date_range (row ['start_date'], row ['end_date']) date in dates: df2.loc[

javascript - Make a Secure PhoneGap/Cordova App (Android) -

i developing new app android. tested phonegap last days , think platform develop app. started developing , have security concerns. online all javascript gets hosted on server , app needs them start. offline i have javascript in app , validates files before startup. i want app working online , offline. problem if files offline every user (with root) can edit code. user can remove example in-app purchase , file validation offline mode. i searched through internet , need didn't found answer how secure app. i hope here can give me tips or ideas make app working online , offline beeing secure. thanks! probably there no bulletproof solution make hybrid apps secure, obfuscate code using tools https://github.com/mishoo/uglifyjs . although not safe reverse engineering, uglification willl make more difficulty modify code.

c# - How to create command in usercontrol? -

i'm developing first application in wpf pattern mvc , have question. i have created usercontrol type grid made custom title bar. grid contains x button , want associate button command. my grid in xaml: <grid x:class="views.titlebarview" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" style="{dynamicresource titlestylegrid}" x:name="barview"> <label x:name="labelappname" style="{dynamicresource titlestylelabel}" content="title"/> <button x:name="bttnclose" style="{dynamicresource buttonstyleclosewindow}" command="{binding closecommand}"/> <

wampserver - Alter language settings for PHP application - WAMP server -

Image
alter language settings php application - wamp server. firefox not regognize language in php-application , replace letters in language small <?>-icons (with appropriate quotes, of cause). not write <html lang=nb-no> or <html lang=no> @ start of php application file , not using <meta charset=iso-8859-1> in header either. the letter substitution not occur in php-admin , not in local installed wordpress. in wamp server 3.0.0. text in english. data stored in mysql have been stored correct. right click on wamp-server icon in system tray , language menu choice gives language list v-mark before english. how can settings altered firefox/ie/opera/... interpret application correct , display characters in alphabet? your problem not language, language not influence anything. problem charset. commons issues in enconding it common when working accents find strange characters such as: like é ( é character in unicode), because character unicode, p

arduino - Can you explain me (int i=0; i<8; i++, data>>=1)? -

i know loop needs in form of (initialization; condition; increment) in case there fourth part, know does? there no fourth part. third part contains comma operator allows put various statements if 1 can't use {} . pretty time i've ever used them (and while ) have single place want more 1 thing. in case, last part of loop both incrementing ( i++ ) , shifting data right once (dividing 2) @ end of each iteration

php - Mysql Update Query increases server load -

i working in dictionary type website, main table all_english_words contains 9 million records. in table id primary key , word column unique key. in word view page fetch record word , put 1 update query increase view count +1 using id condition. problem website hosted in dedicated linux server , avg server load 2.5 3 if remove update query server load drops 0.5 0.8 . problem? there mistake in update query or how optimize or there alternative methods? update query below update all_english_words set viewcount=viewcount+1 id=8878151

swift - What does "fatal error: unexpectedly found nil while unwrapping an Optional value" mean? -

Image
my swift program crashing exc_bad_instruction , error. mean, , how fix it? fatal error: unexpectedly found nil while unwrapping optional value this post intended collect answers "unexpectedly found nil" issues, not scattered , hard find. feel free add own answer or edit existing wiki answer. this answer community wiki . if feel made better, feel free edit it ! background: what’s optional? in swift, optional generic type can contain value (of kind), or no value @ all. in many other programming languages, particular "sentinel" value used indicate lack of value . in objective-c, example, nil (the null pointer ) indicates lack of object. gets more tricky when working primitive types — should -1 used indicate absence of integer, or perhaps int_min , or other integer? if particular value chosen mean "no integer", means can no longer treated valid value. swift type-safe language, means language helps clear types of values cod