Posts

Showing posts from April, 2015

antlr4 - ANTLR - how to skip missing tokens in a 'for' loop -

Image
i'm developing 'toy' language learn antlr. my construct for loop this. for(4,10){ //program expressions }; i have grammar think works, it's little ugly. i'm not sure i've handled semantically unimportant tokens well. for example, comma in middle there appears token, it's unimportant parser, needs 2 , 3 loop bounds. means when see child() elements parts of loop token, have skip unimportant ones. you can see best if examine antlr viewer , @ parse tree this. red arrows point tokens think redundant. feel should making more use of skip() feature am, can't see how insert grammar tokens @ level. loop: 'for(' foridxitem ',' foridxitem '){' (programexpression)+ '}'; foridxitem: num #forindexnumÌ | var #forindexvar; the short answer antlr produces parse-tree, there cruft step on or otherwise ignore when walking tree. the longer answer there tension between skip...

Cannot import com.google.android.maps.MapView -

i wanna import com.google.android.maps.mapview to project in android studio, prompt error "cannot resolve symbol 'maps'". class mapoverlay extends com.google.android.maps.overlay { .... } how solve it? thanks change compile 'com.google.android.gms:play-services:5.+' in build.gradle compile 'com.google.android.gms:play-services:6.1.11' or use: supportmapfragment here example: http://www.truiton.com/2013/05/android-supportmapfragment-example/

android - How to save app data on Google Drive? -

i want use google drive as server store app data. so, have written data file , upload file drive. code: try { // outputstream.write(bitmapstream.tobytearray()); outputstream.write(text.getbytes()); } catch (ioexception e1) { log.i(tag, "unable write file contents."); } metadatachangeset metadatachangeset = new metadatachangeset.builder() .setmimetype("text/txt").settitle("testfile.txt").build(); intentsender intentsender = drive.driveapi .newcreatefileactivitybuilder() .setinitialmetadata(metadatachangeset) .setinitialdrivecontents(result.getdrivecontents()) .build(mgoogleapiclient); try { startintentsenderforresult(intentsender, request_code_creator, null, 0, 0, 0); } catch (sendintentexception e) { log.i(tag, "failed launch file chooser."); ...

How to assign textfield or any delegate in Swift Language? -

i new born developer swift language. want assign textfield delegate view controller. tried assign this class loginviewcontroller: uiviewcontroller <uitextfielddelegate> it's returning following error "cannot specialize non-generic type 'uiviewcontroller'" you need add protocols want conform using comma: class loginviewcontroller: uiviewcontroller, uitextfielddelegate you can extend only 1 class, conform many protocols want: class loginviewcontroller: uiviewcontroller, uitextfielddelegate, uialertviewdelegate from apple doc : class someclass: somesuperclass, firstprotocol, anotherprotocol { // class definition goes here }

email - gitlab] how the disable the user confirmation e-mail -

currently, using gitlab, , love using great one. however, users cannot receive confirmation email , cannot loggin. 1) confirm them through admin privilege or 2) configure system not send email confirmation. any ideas? thank in advance. like @shin-haeng-kang said, new user, setting signup_enabled: false in site settings , creating users admin menu , editing password after creating user work. if users exists, found following issue request shows how edit postgres database manually. from gitlab server: sudo -u git -h psql -d gitlabhq_production gitlabhq_production=> update users set confirmation_token=null, confirmed_at=now() confirmed_at null;

Splitting objects inside Java stream -

i wondering possible split object inside stream. example employee : public class employee { string name; int age; double salary; public employee(string name, int age, double salary) { this.name = name; this.age = age; this.salary = salary; } public string getname() { return name; } public int getage() { return age; } public double getsalary() { return salary; } } i perform operation in stream. simplicity, let (assume code architecture not allow put inside employee class - otherwise easy): public void someoperationwithemployee(string name, int age, double salary) { system.out.format("%s %d %.0f\n", name, age, salary); } now looks this: stream.of(new employee("adam", 38, 3000), new employee("john", 19, 2000)) // conversations go here ... .foreach(e -> someoperationwithemployee(e.getname, e.getage(), e.getsalary)); the question - possible put code inside stream...

c# - WinRT decimal to string formatting -

i have decimal value need display in xaml. the problem win rt not support stringformat in xaml. i trying use converter then: public class decimaltocurrencyconverter : ivalueconverter { public object convert(object value, type targettype, object parameter, string language) { if (value decimal) { return value.tostring("c2", system.globalization.cultureinfo.currentculture); } } public object convertback(object value, type targettype, object parameter, string language) { throw new notimplementedexception(); } } the problem above approach not work. what need convert numbers like: 1234.78 1.234,78 or 1 234.78 or 1 234,78 depending on parameters how can in winrt? thank you! try understand here. numberformatting supporting in winrt/ https://msdn.microsoft.com/en-us/library/windows/apps/windows.globalization.numberformatting.aspx

List volumes of Docker container -

how can list volumes of docker container? understand should easy cannot find how. also, possible volumes of deleted containers , remove them? you can use docker ps, container id , write: $ docker inspect container_id like here: "volumes": { .. }, "volumesrw": { .. } it give volumes of container.

python - Invalid syntax error in Django form class -

syntaxerror @ / invalid syntax (forms.py, line 5) request method: post request url: http://127.0.0.1:8000/ django version: 1.6.1 exception type: syntaxerror exception value: invalid syntax (forms.py, line 5) exceptionlocation: c:\users\chiragbagla\desktop\skillshare\src\signups\views.py in <module>, line 5 python executable: c:\users\chiragbagla\desktop\skillshare\scripts\python2.exe python version: 2.7.9 a part of view.py code follows from django.shortcuts import render, render_to_response, requestcontext # create views here. .forms import signupform def home(request): form = signupform(request.post or none) if form.is_valid(): save_it = form.save(commit=false) save_it.save() return render_to_response("signup.html", locals(), context_instance=requestcontext(request)) a part of forms.py code follows from django import forms .models import signup class signupform(forms.modelform): class meta: model=signup a part of url.py...

How to revoke specific (or all) user permissions in Android for Facebook Login SDK -

Image
i using latest version of facebook sdk (may 2015). how can programatically revoke/remove user's specific permission (or all) after user has logged in via facebook login sdk in android application? found following in developer documentation, not sure how programatically this. thank you. revoking permissions easy new 4.x.x versions of facebook sdk android for read permissions loginmanager.getinstance().loginwithreadpermissions(fragmentoractivity, arrays.aslist("user_likes")); //multiple loginmanager.getinstance().loginwithreadpermissions(fragmentoractivity, arrays.aslist("user_likes", "user_friends")); for publish permissions loginmanager.getinstance().loginwithpublishpermissions(fragmentoractivity, arrays.aslist("publish_actions")); the delete or revoking not necessary, ask permissions whenever want revoke them for example if user has denied permission, can use above commands ask permission again. note: must comply...

xml - xpath multiple conditions with different tags -

i have problem validate xml document, need arrive target tags <templateid root="2.16.840.1.113883.10.20.33.4.4"/> , <entryrelationship> , both conditions must achieve, because if these 2 conditions achieve ,i able check if entryrelationship has <templateid root="2.16.840.1.113883.10.20.33.4.2"/> . have done this: <rule context="//cda:entry/cda:organizer/cda:component/cda:observation[(./templateid/*[@root='2.16.840.1.113883.10.20.33.4.4']) , (./entryrelationship/*[@typecode='refr'])]"> <!--<rule context='*[cda:templateid/@root="2.16.840.1.113883.10.20.33.4.4"]'>--> <assert test="self::cda:entryrelationship[@typecode='refr']"> fail: conf-qr-176: entryrelationship, if present, shall contain 1 [1..1] @typecode="refr" (codesystem: hl7actrelationshiptype 2.16.840.1.113883.5.1002). line: <value-of select="@_line"/> ...

java - Read JSON file from assets -

i trying read json file assets in fragment using getassets() , ide says "can not resolve method (getassets())". code public string loadjsonfromasset() { string json = null; try { inputstream = getassets().open("moods.json"); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); json = new string(buffer, "utf-8"); } catch (ioexception ex) { ex.printstacktrace(); return null; } return json; } try this: create class loaderhelper.java public class loaderhelper { public static string getjson(context context, string json){ string jsonstring=parsefiletostring(context, json); return jsonstring; } public static string parsefiletostring( context context, string filename ) { try { inputstream stream = context.getassets().open( filename ); int size = stream.a...

javascript - How do I keep the this context of my original function after calling .apply()? -

i have functiona accepts function parameter. want manipulate arguments of function in functiona , return functionc. found can .apply(), original context of functionb lost , instead replaced functiona. for example, var factory = { return { fnb: function() {} } }; fna(fn) { return fnc(params) { var customparams = [params, {something: else}] return method.apply(null, customparams); } } var load = fna(factory.fnb); load(params); however when execute load(params), lose functionb's context. functionb defined method factory. how can go this? thanks! i'm going assume method fn , , functionb function assigned object property, , various syntax errors aren't present in actual code: var obj = { name: "foo", functionb: function() { console.log(this.name); // <== using `this` refer `obj` } }; function functiona(fn) { return function functionc(params) { var customparams = [params...

java - JFrame or JApplet? -

i trying make tiny application translate text light patterns. set want top left side of application going text box enter button. text fed through program translation. right below output code it. "hello" come out r - g - b - b - rg. on right side of applet going have 3 circles colored, or if can find 3 lights. going flickering on , off based on code input. , put variable speed it's not necessary. i don't have experience either jframe or japplet , messed around bit both. application type fit needs better?

How to Find SSRS report version in report server -

could tell me how find out version of report in report server, whether ssrs 2012 or ssrs 2008 r2. thanks. download report , open .rdl file notepad or xml editor, second row should this: <report xmlns:rd="http://schemas.microsoft.com/sqlserver/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"> you can find info related reportdefinition hope helps you

c# - Disable Main Window WPF -

i working on wpf application running scan in main window , scan section running in thread. after completion of scan,it shows window modal popup. now want disable main window when popup comes out after scan gets completed user can not click on main window untill close popup.but unable so. thanks set parent window owner child window (popup) , open child window showdialog() below: create " navigationservice.cs " class , put below code in class. public void showpopupwindow(popupwindowviewmodel popupwindowviewmodel) { popupwindowview= new popupwindowview(); popupwindowview.datacontext = popupwindowviewmodel; popupwindowview.owner = parentwindowview; popupwindowview.showdialog(); } now, call above method in viewmodel class below: popupwindowviewmodel popupwindowviewmodel = new popupwindowviewmodel (); popupwindowviewmodel.name = "this popup window"; navigationservice navigationservice = n...

xcode - Taking a Parse Date, Converting to String and Display in Cell Detail -

i trying take column createdat parse class, , display date in cell detail label (subtitle styled cell). i doing following way: if let createddate: anyobject = object["createdat"] as? nsdate { var dateformatter = nsdateformatter() dateformatter.dateformat = "mmm d, yyyy" var datestring = dateformatter.stringfromdate(createddate as! nsdate) if datestring.isempty { cell?.detailtextlabel?.text = "undefined" } else { cell?.detailtextlabel?.text = datestring } } however, word "detail" below title label because @ runtime appears evaluate first let createddate: anyobject , skips rest of code, including label assignment. what doing wrong here? lets start getting createdat date. createdat special value provided pfobject 's property. should reading this: if let object = object as? pfobject { let createddate = object.createdat } now gi...

Why are files are different when downloading from an ASP.NET (AJAX download with Blob) -

using mvc 4.0, have used following code create download files server ajax source (using latest firefox): this works fine if output involves textual files such csv or txt files, however, when comes files zip or xlsx, seems downloaded file different original source (i.e. zip generated within server 15k, 1 downloaded 26k) i have been struggling few days, can ask if should shred light on why works csv/text files, not zip or xlsx files? many thanks controller: public function download(datain myobject) actionresult 'some processing 'generated zip files , return full path dim zipfullpath = generatefiles(datain) response.clear() response.contenttype = "application/zip" response.addheader("content-disposition", "attachment; filename=out.zip") dim filelength = new io.fileinfo(zipfullpath).length 'filelength reads 15k of data response.addheader(...

sql - What to modify in my query to fix literal format string error? -

literal not match format string select to_date(to_char(a.date,'dd/mm/yyyy') || to_char(a.time),'dd/mm/yyyy hh24:mi:ss') dual , tab how modify query not produce above error ? a.time type varchar2(20) , a.date date i have condition select to_date(to_char(a.date,'dd/mm/yyyy') || to_char(a.time),'dd/mm/yyyy hh24:mi:ss') < to_date('20/04/2015','dd/mm/yyyy') +1 dual , tab its producing error how modify it try this select to_date(to_char(a.date,'dd/mm/yyyy') || ' ' || a.time,'dd/mm/yyyy hh24:mi:ss') dual , tab this work if data in a.time column in format hh24:mi:ss. should use case-when deal boolean expressions in select list. select case when to_date(to_char(a.date,'dd/mm/yyyy') || a.time,'dd/mm/yyyy hh24:mi:ss') < (to_date('20/04/2015','dd/mm/yyyy') +1) 'y' else 'n' end dual , tab

Convert a JSON of different type of objects into java List object -

i have json object stored in db in form of string. using create dynamic form in ui. problem want change values in based on other changes happening on application. suppose updated label field, have json , change here. easy if have stored same type of objects in json, json follows: [{ "name": "somename", "xtype": "keyvaluecombo", "fieldlabel": "some title", "reftype": "yes_no", "multiselect": false, "helptext": "" }, { "name": "somename2", "xtype": "keyvaluecombo", "fieldlabel": "some title2", "reftype": "yes_no", "multiselect": false, "helptext": "" }, { "xtype": "datefield", "fieldlabel": "joining date", "name": "joiningdate", "s...

zend framework - ZF 2.4 File Validator Required False Doesn't Work -

today updated zf 2.4 use float validator unfortunately realized file upload form field gives unexpected error messages. here form object $this->add([ 'name' => 'profileimage', 'type' => '\zend\form\element\file', 'attributes' => [ 'id' => 'profileimage', 'class' => 'styled', ], ] ); and here validator $inputfilter->add([ 'name' => 'profileimage', 'required' => false, 'allow_empty' => true, 'priority' => 300, 'filters' => [ ['name' => 'striptags'], ['name' => 'stringtrim'], ], 'validators' => [ [ ...

angularjs - How to retrieve all instances on the JHipster API for entities -

when calling generated api when using paginator, there way can call generated rest-api retrieve instances of object, insted of first 20,30,40 etc? i find since using pagination entity-creation , management, when want utilize these entities in other views (self created), api not provide instances when calling entity.query() in angular/js. is limitation jhipster, or can call rest-api in other way supplying info discard paginator? you can modify existing rest controller entity. here example center entity. i return centers if there no value offset , limit. @requestmapping(value = "/centers", method = requestmethod.get, produces = mediatype.application_json_value) @timed public responseentity<list<center>> getall(@requestparam(value = "page" , required = false) integer offset, @requestparam(value = "per_page", required = false) integer limit) throws urisyntaxexception { if(...

c++ - Reading from a file with multiple columns of integers and putting them into arrays -

i creating command-line minesweeper game has save , continue capability. code generates file called "save.txt" stores position of mines , cells player has opened. separated 2 columns delimited space left column represents row of cell , right column represents column of cell in matrix generated code. following contents of save.txt after sample run: 3 7 3 9 5 7 6 7 8 4 mine end 2 9 1 10 3 5 1 1 cell open end you may have noticed mine end , cell open end . these 2 separate numbers 2 groups first 1 position of mines , latter position of cells opened player. have created code generates array each column provided text file contains integers: int arrayrow[9]; int arraycol[9]; ifstream infile("save.txt"); int a, b; while(infile >> >> b){ for(int = 0; < 9; i++){ arrayrow[i] = a; arraycol[i] = b; } } as can see, won't quite work text file since contains non-integer text. basically, want create 4 arrays: minerow , minecol...

docx - Unable to connect the LibreOffice on port 2002? -

i using docvert 5.1 convert .doc html.when run "tests (run all)" during getting error message under following parts: " ✘unable run tests due exception. failed connect libreoffice on port 2002. connector : couldn't connect socket (success) if don't have server read readme 'optional libraries' see how set 1 up." footnotes heading , paragraphs images lists i have found here : https://github.com/holloway/docvert/ i think have start server using command : sudo apt-get install libreoffice python-uno python-lxml python-imaging pdf2svg librsvg2-2 /usr/bin/soffice --headless --norestore --nologo --norestore --nofirststartwizard --accept="socket,port=2002;urp;" (from https://github.com/holloway/docvert/blob/master/readme.md )

javascript - Can I use an empty string as an object identifier? -

i've been tinkering objects , seemingly can have '' (an empty string) property name, so: o = { '': 'hello', 1: 'world', 'abc': ':-)', }; console.log(o['']); seems work fine, i'm curious know, is valid? i've poked @ ecma specs , asked our ever-knowledgeable friend google variations of question , conclusion i don't know . my sources http://www.jibbering.com/faq/faq_notes/square_brackets.html yes, technically totally valid , can safely use it. object key needs "string", not exclude empty string. if convinient , useful story. see should use empty property key? since 'empty string' 1 of falsy values in ecmascript, consider following example: var foo = { ':-)': 'face', 'answer': 42, '': 'empty' }; object.keys( foo ).foreach(function( key ) { if( key ) { console.log(key); } }); that ...

regex - Regular expression for invalid characters in XML -

i trying figure out way can find invalid characters in xml. according w3 recommendation these valid characters in xml: #x9 | #xa | #xd | [#x20-#xd7ff] | [#xe000-#xfffd] | [#x10000-#x10ffff] converting decimal: 9 10 13 32-55295 57344-65533 65536-1114111 are valid xml characters. i trying search in notepad++ using appropriate regular expression invalid characters. a snippet xml: <custom-attribute attribute-id="iscontendfeed">fal &#11; se</custom-attribute> <custom-attribute attribute-id="pagenofollow">fal &#3; se</custom-attribute> <custom-attribute attribute-id="pagenoindex">fal &#13; se</custom-attribute> <custom-attribute attribute-id="rrrecommendable">false</custom-attribute> from above example want regular expression finds &#11; , &#3; me because these not allowed in xml. i not able construct regular expression this. ...

c - strcat() could not concatenate -

i have two-dimensional character array concatenated array. has error: error c2664: 'strcat' : cannot convert parameter 1 'char *[80]' 'char *' here's code: char *article[5] = {"the", "a", "one", "some", "any"}; char *sentence[80]; num = rand() % 5; for(int x = 0; x < strlen(article[num]); x++){ strcat(sentence, article[num][x]); //a random element concatinated sentence array } here's fixed code might want, it's hard tell want sure... srand(time_t(0)); // seed random number generate once // use const when handling pointers string literals const char* article[5] = {"the", "a", "one", "some", "any"}; char sentence[80]; // 80 character buffer in automatic storage - no pointers sentence[0] = '\0'; // empty asciiz string start (int x = 0; x < 5; ++x) { int num = rand() % 5; strcat(sentence, article...

android - How to upload apk file to sauce labs and get saucelabs url of temporary storage? -

i new saucelabs.when tried following in cmd prompt upload apk file saucelabs, getting following error.can pls in this? c:\curl -u gkyrreport:e4fc33sfdsf45--41b2-9eeed6638 -x post –h “content-type:application/octet-stream” “ https://saucelabs.com/rest/v1/storage/gkyrreport/mine.apk?overwrite=true ” –data-binary @mine.apk curl: (6) not resolve host: -h; host not found curl: (6) not resolve host: "content-type:application; host not found curl: (1) protocol "https not supported or disabled in libcurl curl: (6) not resolve host: -data-binary; host not found curl: (6) not resolve host: yourreport.apk; host not found it looks used en-dash -h option , --data-binary option. when type command, make sure use minus key options. if copy , paste somewhere may have edit line convert en-dash characters minuses. en-dash, curl interprets argument host name rather option. and note how --data-binary 2 minus characters @ start. (people commonly call - "dash...

openlayers 3 - feature convert to geoJSON string failed -

i got geometry featureoverlay,and create feature geometry, when setid , setgeometryname feature ,i failed writefeature , bug ? var poly = featureoverlay.getfeatures().item(0); if (poly != null) { var feature = new ol.feature({ geometry: poly }); feature.setid('bd355df3fd916d30'); feature.setgeometryname('test'); var extent = [0, 0, 749, 638]; var projection = new ol.proj.projection({ code: 'xkcd-image', units: 'pixels', extent: extent }); var geojson = new ol.format.geojson({ defaultdataprojection: projection }); //this success var geojsontext = geojson.writefeature(poly, { featureprojection: projection, dataprojection: projection }); //this failed var geojsontext = ...

networking - Powershell script to copy file to network runs manually, but not from Task Scheduler -

i running script copy file local network location. script works if call myself via powershell, not task scheduler. have looked @ this , many other articles, cannot work. right can @ task scheduler, "last run result" , says task running couple minutes before stop it. when end task don't exception (code in try/catch) i have serverlocation , serverfullpath broken because trying few different examples. the code follows (with domain/username/password substituted): set-variable servercredentials -option constant -value "<domain>/<username> <password>" set-variable serverlocation -option constant -value "\\<domain>" set-variable serverfullpath -option constant -value $serverlocation"\path\path" $latest = get-childitem -path .\ | sort-object lastwritetime -descending | select-object -first 1 net use $serverfullpath /user:$servercredentials copy-item .\$latest $serverfullpath -force i new powershell, thoughts on...

java - Binding Keys to Move an Image -

i working on game school project , 1 step have bind keys image add/subtract x-y axis. way have done not seem work , instead of adding small amount increases x/y lot , teleports image away off of screen. the keylistener code public void keypressed(keyevent e) { if (e.getkeycode() == 87) { = true ; if (e.getkeycode() == 65) { left = true ; } if (e.getkeycode() == 68) { right = true ; } if (e.getkeycode() == 83) { down = true ; } } } @override public void keyreleased(keyevent e) { if (e.getkeycode() == 87) { = false ; } if (e.getkeycode() == 65) { left = false; } if (e.getkeycode() == 68) { right = false ; } if (e.getkeycode() == 83) { down = false ; } } the game loop public void run() { while(running) { //player movement if (up) { y++ ; } if (left) { ...

How to write a case statement with nested JSON in rails -

i have app integrated easypost api (for shipping stuff, cool). i'm using tracking information webhooks fire events in app. i'm using ruby case statements accomplish this. here's link easypost's api doc: https://www.easypost.com/docs/api#webhooks i match case statement result.status key value in json. using description, need more specific. take look: { "id": "evt_qataijdm", "object": "event", "created_at": "2014-11-19t10:51:54z", "updated_at": "2014-11-19t10:51:54z", "description": "tracker.updated", "mode": "test", "previous_attributes": { "status": "unknown" }, "pending_urls": [], "completed_urls": [], "result": { "id": "trk_txyy1vam", "object": "tracker", "mode": "test", "tracking_code": "ez4000000...

android - Volley Server Error with null Network response -

every time try use post method volley, sever error. null value in getcause, , default value in getnetworkresponse.tostring(). if use method, works fine (i response url). can can do? map<string, string> jsonparams = new hashmap<string, string>(); jsonparams.put("teststr", "abd"); requestqueue requestqueue = volleysingleton.getinstance().getrequestqueue(); jsonobjectrequest request = new jsonobjectrequest( request.method.post, url, new jsonobject(jsonparams), new response.listener<jsonobject>() { @override public void onresponse(jsonobject response) { try { toast.maketext(getapplicationcontext(), "success"+response.tostring(), toast.length_long).show(); }catch(exception e){ toast.maketext(getapplicationcontext(), "json error", toast.lengt...

bash - Using sed to get the content of a file that is not between two lines -

i have file like: name 1 name 2 name 3 #start# no name 1 no name 2 #end# name 4 and i'm looking opposite of sed -n '/#start#/,/#end#/p' result: name 1 name 2 name 3 name 4 what's secret? sed '/#start#/,/#end#/d' delete lines within range specified.

c# - wcf basic authentication request to display the wsdl -

i using usernamepasswordvalidator consumption of wcf service, display wsdl authenticated users, implement basic authentication validate user , password , show wsdl service, through https, how that? using basichttpbinding, need interoperability other languages.

Escape parts of string with a character in c# using regex -

i have string such this: /one/two/three-four/five 6 seven/eight/nine ten eleven-twelve i need first replace dashes spaces, , able escape grouping of words have space between them "#" symbol, above string should be: /one/two/#three four#/#five 6 seven#/eight/#nine ten eleven twelve# i have following extension method works great 2 words, how can make work number of words. public static string queryescape(this string str) { str = str.replace("-", " "); return regex.replace(str, @"(\w*) (\w*)", new matchevaluator(escapematch)); } private static string escapematch(match match) { return string.format("#{0}#", match.value); } so guess need proper regex takes account that there number of spaces there may or may not trailing slash ("/") takes account words grouped between slashes, exception of #2 above. dashes illegal , need replaced spaces thank in advance support. ...

javascript - Defined array value shows as undefined -

i getting following error on console. uncaught typeerror: cannot read property '1' of undefined age= 55; array = new array(); array[55] = [8.7, 7.5]; array[56] = [8.9, 7.6]; array[57] = [9, 7.7]; array[58] = [9.2, 7.8]; array[59] = [9.4, 7.9]; array[60] = [9.6, 8]; data = array[age]; console.log( data[0] + " | " + data[1] ); i test code,but doesn't have mistake , output "8.7 | 7.5" correctly.however,when test in strict mode,it has mistake because lack of "var" when define variable.

scala - Resolve spark-avro error = Failed to load class for data source: com.databricks.spark.avro -

i trying use spark-avro library process avro files. using sbt: build.sbt: librarydependencies ++= seq( "org.apache.spark" %% "spark-sql" % "1.3.0", "com.databricks" %% "spark-avro" % "1.0.0") tester.scala: import org.apache.spark.sparkcontext import org.apache.spark.sparkcontext._ import org.apache.spark.sparkconf import org.apache.spark.sql._ import com.databricks.spark.avro._ object tester { def main(args: array[string]) { val conf = new sparkconf().setappname("simpleapplication").setmaster("local") val sc = new sparkcontext(conf) // creates dataframe specified file val df = sqlcontext.load("episodes.avro", "com.databricks.spark.avro") } } when run tester in intellij ide, following stack trace: exception in thread "main" java.lang.noclassdeffounderror: org/apache/avro/mapred/fsinput @ com.databricks.spark.avro.avrorelation...

c# - Connect to an Existing MVC 5 DB (Identity model) From External Project -

background: i've web app offers service customers. motivation: want expose service of api (wcf & web api). consumers of service need authenticate. the problem: of consumers of api customers of web app. i don't want 1 client have 2 passwords, 1 web app , 1 api. how can share web app (mvc5) db other projects? wcf example. i need in wcf 2 methods run web app: register. login. this methods implement in project follow: register: public async task<actionresult> register(registerviewmodel model) { if (modelstate.isvalid) { var user = new applicationuser { username = model.username, email = model.email, organizationid = "10", datejoin = datetime.now, lockoutenddateutc=datetime.utcnow.addyears(5),lockoutenabled=false}; var result = await usermanager.createasync(user, model.password); if (result.succeeded) { identityresult resultclaim = await usermanager....

regex to concatenate two strings in C# -

is possible concatenate 2 sub strings input string using regex example : input string "abttpqr 00100300250000" , want take first 2 characters "ab" , first 9 digits "001003002" , concatenate these 2 string 1 "ab001003002" much shorter variation using references: regex.replace("abttpqr 00100300250000", @"^(\w{2})\w*\s(\d{9})\d+$", @"$1$2") // = "ab001003002"

html - I'm trying to replace an image with a square (div shape) in this carousel -

using code: http://jsfiddle.net/ybrx3/1022/ i'm trying insert green square (currently below carousel) carousel. whenever try replace 1 of images square's script, however, other items in carousel end line below. believe has .imagediv img { portion of css script, i'm not sure how modify that. appreciated. thanks! html: <body bgcolor="#e6e6fa"> <div id="alternatewrapper" class="wrapper"> <div class="scrolls"> <img style="width:80px;" src="http://placehold.it/50x50" /> <img src="http://placehold.it/50x50" /> <img src="http://placehold.it/50x50" /> <img src="http://placehold.it/50x50" /> <img src="http://placehold.it/50x50" /> <img src="http://placehold.it/50x50" /> <img src="http://placehold.it/50x50" /> <img src="http://placehold.it/50x50" /> ...

php - PDO and mysql_connect at same time - performance -

i working on 7+ year old site made extremely extensive use of mysql_connect/mysql_query. begin tedious project of converting on pdo, cannot afford take time go through entire project @ once. i have done research , searches , see possible connect 2 @ same time, not able find information on performance hit cause. am going slow site crawl while connect both methods? you asked am going slow site crawl while connect both methods? no. long as mysql server configured sufficient simultaneous connections allow 2 each of php pages, and the queries issue simultaneously 2 connections don't deadlock each other. this should fine. i've done similar things success. avoiding deadlock should easy if you're careful overlapping queries same table.

php - What does HTTP 2 mean for Web Developers -

when comes building web applications, know http 2 going recommended traffic coming site. understand security concerns , reason why recommended/forced used now. when comes web-based languages code in , understand such ruby, php, , perl. is there special functions have produce secure connection server or need redirect traffic https:// on http:// ? basically, autoloading class in php load classes , functions web application operate. need create ssl.class.php allowing connection secure within php? the changes in http/2.0 on http/1.1 relevant if application streams large amounts of data many simultaneous users. is there special functions have produce secure connection server or need redirect traffic https:// on http:// ? no. http/2.0 not require tls. if want tls (which, personally, i encourage ), still need send clients https:// . basically, autoloading class in php load classes , functions web application operate. need create ssl.class.php allowing connec...

java - Working with Ads I get the message: The application (Appname) has stopped unexpectedly. Please try again -

hi guys working google ads got error when trying run app on mobile " sorry- application (appname) has stopped unexpectedly. please try again " note app run no problem in eclipse ! any cool here manifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mased1.appflix" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="18" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage"/> <uses-permission android:name="android.permission.access_wifi_state" /> <app...

sql - SQLite: Inserting values from table in database1 to table in database2 without overwriting -

i can't wrap head around this. we're 2 dudes manually writing textbits in conflicting databases (i know, it's not cool), , need integrate our work. sorry if it's duplicate, don't other answers. please patient, need here. two different databases needs merge 1 column, , if possible, avoid overwriting. his database: database: result: database 1 database 2 database 2 table1 table1 table1 column column column blah null blah null bla bla bla bla bla bla i'm guessing inner join mixed insert into? we're working in gui named valentina studio sql editor. try like insert tab3 (col1) select col1 tab1 col1 not null union select col1 tab2 col1 not null

security - How do you Encrypt and Decrypt a PHP String? -

what mean is: original string + salt or key --> encrypted string encrypted string + salt or key --> decrypted (original string) maybe like: "hello world!" + "abcd1234" --> encrypt --> "2a2ffa8f13220befbe30819047e23b2c" (may be, e.g) "2a2ffa8f13220befbe30819047e23b2c" --> decrypt "abcd1234" --> "hello world!" in php, how can this? attempted use crypt_blowfish , didn't work me. before further, seek understand the difference between encryption , authentication , , why want authenticated encryption rather encryption . to implement authenticated encryption, want encrypt mac. the order of encryption , authentication important! 1 of existing answers question made mistake; many cryptography libraries written in php. you should avoid implementing own cryptography , , instead use secure library written , reviewed cryptography experts. use libsodium if have pecl access (or sodium_c...