Posts

Showing posts from February, 2012

scala - Applying logical and to list of boolean values -

consider following list of boolean values in scala list(true, false, false, true) how using either foldright or foldleft emulate function of performing logical , on of values within list? val l = list(true, false, false, true) val andall = l.foldleft(true)(_ && _)

javascript - JS $.get method file with path -

i want load * .csv file path wich user can choose. path get: c:\\users\\... but $.get method can't read path. how path have like? $.get(pathandfile, function (data) {... if wanted read csv data in javascript computer need instruct user select file (there no way around this, possible exception of virus). once user selected file can read , parse csv data small amount of javascript ( demo ) with html: <input type="file" id="file" name="file" /> <table id="rows"></table> and javascript: var output = $('#rows'); $('#file').on('change', function(evt) { var files = evt.target.files; (var = 0, f; f = files[i]; i++) { // process text files. if (!f.type.match('text/.*')) { alert('unsupported filetype:'+f.type); continue; } var reader = new filereader(); reader.onloadend = function(evt) { var rows, row, cols, col, html;

Data cut in SQL Table -

i'm trying table basic data (last name, first name, id..) i have created table complete name doesn't appear in table, example: last name first name gonzalez rami margarita rami should ramirez. have declared last name longtext . how see complete last name in table or ensure not cut? i use varchar if want performance indexing , searching. such as: last_name varchar(30), the thirty how many characters allow in field. set number want under max(which escapes me @ moment somewhere beyond 60 varchar) excess automatically cut off.

MongoDB Positional Operator $ -

i got following document { _id : 91, "myarray" : [ { "a" : "1", "b" : true }, { "a" : "1", "b" : true }, { "a" : "1", "b" : true } ] } and want update each myarray.b element false b true . running following query: db.mydb.update({"arr.b" : true},{$set : {"arr.$.b":false}},false, true) and getting first array element updated not subdocuments. { _id : "91", "myarray" : [ { "a" : "1", "b" : false }, { "a" : "1", "b" : true }, { "a" : "1", "b"

exchange server - Cannot use EWS.dll with ExchangeWebServices namespace -

this link outlines trying do http://msdn.microsoft.com/en-us/library/aa494212(v=exchg.140).aspx how right dll this? hard reason.... i trying use class getuseravailabilityresponsetype the dlls can have exchange microsoft.exchange.webservices.dll for while thought ews.dll, not contain namespace 'exchangewebservices'. need access class, contains microsoft.exchange.webservices.data namespace not have required classes. can please tell me how can right namespace? thanks. you have right dll, link refer type defined older ews proxy classes, don't have dll per se, defined via wsdl command. being equal, don't want use these old classes, rather new ews managed api, provided dll in question. equivalent functionality (availability) provided there, , placed start looking how use here:

regex - Match from the third word onwards in a string with PHP -

i'm trying return dolor sit amet following string - $title = 'lorem ipsum dolor sit amet'; preg_match('/^(?:\w+\s+){2}(.)+/', $title, $matches); it's matching last letter. you need put repetition operator inside group: preg_match('/^(?:\w+\s+){2}(.+)/', $title, $matches); otherwise, group captures 1 character.

Displaying other peoples facebook timelines on my site -

i've got website i'm doing around bunch of athletes. all of these athletes have facebook account. the client wants show each of these athletes facebook timelines on individual profile pages using facebook profile handle provide. i'm unfamiliar facebook api 99% sure isn't possible each of athletes have go facebook developers portal , set app right? is there way achieve @ all? nop, you're wrong. athletes don't have setup app. but, on other hand, or developer responsible project, must setup app @ facebook developers website. i'm not going explain process, since facebook docs quite easy understand. https://developers.facebook.com/docs/ after setup facebook app , integrate website, it's time start asking athletes authorization have plenty of ways that, can either use facebook login , dialogs or even manually build login flow . keep in mind have different permissions, here's full list of permissions , small description explai

html - MVC : Not render css class for certain view? -

i new css , don't have knowledge it. i have mvc application uses theme built based on bootstrap. and in _layout view have code <div class="container body-content"> @html.partial("_alerts") @renderbody() <hr /> <footer> <p>&copy; @datetime.now.year -myapp</p> </footer> </div> i'm guessing view wrapped container body-content class. which fine, because web app's content not displayed in full width stretched. but home page(landing page) let's say. has slider , because of container body-content class not being shown in full width. this how home page starts <div class="fullwidthbanner-container" style="overflow:visible"> <div class="fullwidthbanner"> <ul> <!-- slide 1 --> <li data-transition="slideright"> ... ... ... </div> and here

r - What exactly happened when predict() is used in lines()? -

when doing linear modeling, can use predict() within lines() , nice plotting. example year <- 1:15 sales <- c(301,320,372,423,500,608,721,826,978,1135,1315,1530,1800,2152,2491) yearsales <- data.frame(year,sales) logyearsales.fit <- lm(log(sales)~year) plot(year,log(sales)) lines(year,predict(logyearsales.fit),col="red",lwd=2) however, when combine nls() , lines(), odds happen, this: library(mass) survey1<-survey[!is.na(survey$pulse)&!is.na(survey$height),c("pulse","height")] expn <- function(b0,b1,x){ model.func <- b0 + b1*log(x) z <- cbind(1,log(x)) dimnames(z) <- list(null, c("b0","b1")) attr(model.func,"gradient") <- z model.func } survey1<-as.data.frame(survey1) aa=nls(height~expn(b0,b1,pulse), data=survey1,start=c(b0=180,b1=2),trace=true) plot(survey1) lines(survey1[,1],predict(aa),col="red",lwd=2) you can see red

java - Get XSD type while SAXParser -

i trying parse xml document saxparser. have xsd document validates against. while parsing e.g. in startelement/endelement method know type xsd e.g. xsd:integer etc. possible? thanks mike you can use attributes.getvalue(string qname) method on attributes object passed parameter in startelement method, value of of element's attributes including type: attributes.getvalue("type") . depending on if in xml using qualified names or not, might have use attributes.getvalue(i) , i index of "type" attribute in element' attributes list. see https://stackoverflow.com/a/8451023/3132058 . you can find more info on how use in sax api documentation .

node.js - angular is not defined -

Image
i have problem in file route.js when i'm running node.js shows me "angular not defined " route.js var app = angular.module('myapp', ['ngroute']); app.config(function($routeprovider){ $routeprovider .when('/', {templateurl: 'views/login.html'}) .when('/login', {templateurl: 'views/home.html'}) .otherwise({redirectto : '/'}); }); error : have "imported" angular.js scripts? script(src='//ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js') script(src='//ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular-resource.min.js') this page gives info on how mean stack (mongo, express, angular, node). perhaps has usefull information you.

vim - How can I map ctrl to space in normal mode? -

i use heavily scrolling commands ctrl+e ctrl not reachable on keyboard. possible replace these space can type space+e scroll ? have tried nnoremap <space-e> <c-e> , nnoremap <space> <c> doesn't work. thanks. inside vim, regular modifier keys shift , ctrl , , alt can used , combined other keys. <space-e> doesn't work, cp. :help key-notation . when ctrl key awkward use, have use features of operating system switch keys (usually globally applications, though tools autohotkey on windows support application-specific remappings). that, key received vim still ctrl, you've triggered pressing different physical key on keyboard. these pages vim tips wiki should started: map caps lock escape in windows map caps lock escape in xwindows

Cygwin C program not accepting command line arguments -

i writing program in c uses sdl2 on cygwin. problem having argc 1, when command line contain other arguments. this bit difficult replicate can't post code program, can include main source here make sure main function correct. my question if there known reason why argc 1 , not include other command line arguments (weather intentionally or side effect using sdl2 etc)? this code i'm using: #include <stdlib.h> #include <stdio.h> #include "config.h" #include <string.h> #ifdef signal_avail #include <signal.h> #endif #include "process.h" #include "nvconsole.h" #include "stringutils.h" #include "nova.h" struct novacontext_s *context; // nova system context #ifdef signal_avail // #### signal handler #### void sig_handler(int signo) { if (signo == sigint) { nvconsole_print(nvinfo,"terminated user"); nvconsole_println(nvinfo,""); no

ExtJs 4 Firefox css conditional -

i need give particular style in css firefox in extjs 4.2 looking in web found extjs give particular class when in browser tried: .x-body.x-gecko .x-btn-action-nav-large.x-btn-inner { font-size: 5em; } or .x-body.x-gecko { .x-btn-action-nav-large.x-btn-inner { font-size: 5em; } } but nothing work , showed in firefox suggestion? try: .x-body.x-gecko .x-btn-action-nav-large .x-btn-inner { font-size: 5em; } you need space between last 2 rules inner element child of button. you do: .x-gecko .x-btn-action-nav-large .x-btn-inner { font-size: 5em; }

Strange files in every directory named "." and ".." in osx 10.9.2 -

anywhere ls -a folder contains files called "." , "..". anybody knows stuff? system files? kind of virus or something? have hard time googling because of such file names. here example: drwx------+ 12 mih staff 408 4 янв 16:49 . drwxr-xr-x+ 91 mih staff 3094 20 мар 15:28 .. -rw-r--r--@ 1 mih staff 6148 4 янв 16:49 .ds_store -rw-r--r-- 1 mih staff 0 10 ноя 2011 .localized -rw-r--r--@ 1 mih staff 181 27 ноя 2011 desktop.ini -rw-r--r--@ 1 mih staff 8198298 29 июл 2013 dizzee rascal - bassline junkie.mp3 yes, system files. a subdirectiry contains 2 directory entries used navigate between folders in days of dos. the . entry directory reference same directory. the .. entry directory reference parent directory. those regular subdirectories, instead point directories exist. nowadays wouldn't needed, system interpret . , .. anyway, in days needed system find way parent directory.

hadoop - Merging MapReduce output -

i have 2 mapreduce jobs produce files in 2 separate directories so: directory output1: ------------------ /output/20140102-r-00000.txt /output/20140102-r-00000.txt /output/20140103-r-00000.txt /output/20140104-r-00000.txt directory output2: ------------------ /output-update/20140102-r-00000.txt i want merge these 2 directories in new directory /output-complete/ 20140102-r-00000.txt replaces original file in /output directory , of "-r-0000x" removed file name. 2 original directories empty , resulting directory should follows: directory output3: ------------------- /output-complete/20140102.txt /output-complete/20140102.txt /output-complete/20140103.txt /output-complete/20140104.txt what best way this? can use hdfs shell commands? need create java program traverse both directories , logic? you can use pig ... get_data = load '/output*/20140102*.txt' using loader() store get_data "/output-complete/20140102.txt" or hdfs c

c# - extracting a list of strings that match a pattern for the beginning of each string -

i have pretty long string want extract strings match pattern beginning of each string. example, suppose have this: string thelongstring = lorem ipsum "somewordone" dolor sit "somewordtwo" amet; how extract string strings in quotes , start someword? instance, in case, list should contain "somewordone" , "somewordtwo" . thanks. assuming pattern searching not single word ( kd.'s answer work that), use regex match want: regex regex = new regex("\"someword[^\"]*\""); var matches = regex.matches(thelongstring); list<string> mymatchedstrings = new list<string>(); foreach (match match in matches) { mymatchedstrings.add(match.value); } if don't want double quotes included in results, use following drop-in replacement uses regex behind find opening quote, won't show in result: regex regex = new regex("(?<=\")someword[^\"]*"); or if wanted exclude "

c# - performance of parallel for loop -

this question has answer here: limit number of parallel threads in c# 5 answers i need set number of processor's threads parallel "for-loop". want work 3 threads of 8 (4-cores processor) ..... i'm using 8 threads. system.threading.tasks.parallel.for(0, exponentstring.length, (i, loopstate) => { int y = my_function (a, exponent[i], modulo); string str = y.tostring(); if (str == numbers[0]) { loopstop = 1; loopstate.stop(); } }); thanks ideas. there overload takes paralleloptions object: var options = new paralleloptions(); options.maxdegreeofparallelism = 3; parallel.for(0, exponentstring.length, options, (i, loopstate) => { ... });

c++11 - Intel compiler and "cannot have an in-class initializer" when using constexpr -

the following test program compiles , runs fine g++. intel icpc (14.0.2) compile , run if use explicit type double instead of template. template version icpc produces error: icpc -g -o2 -i. -std=c++0x -c main.cc -o main.o main.cc(10): error: member of type "const t [9]" cannot have in-class initializer static constexpr t dx_[9] = { test code template<typename t> class myclass { public: static constexpr t dx_[9] = { 1.5, 2.0, -0.5, -0.5, 0.0, 0.5, 0.5, -2.0, -1.5 }; }; template<typename t> constexpr t myclass<t>::dx_[9]; int main(int argc, char *argv[]) { return 0; } // main why receiving error "cannot have in-class initializer" when using constexpr ? this bug of intel compiler, submitted intel , fixed in future versions. also see multiple constexpr bugs , sfinae bug intel c++ compiler 15 , method constexpr bug c++ compiler 15 on intel forums.

node.js - elasticsearch node client using mget on index alias bringing back docs not in alias -

i using node js client es. i doing mget using alias index field , not actual index. works in sense brings results 1 of documents not in alias in underlying index i.e. should fail alias test , not come come in result is. itemids = ['3504479-4-41','3504700-4-41'];//test, second id not in alias esclient.mget({ index: 'live_articles', _source: ['id','itemtypeid','headline','itemurl','startdate','summary', 'onlinestatus'], body: {ids: itemids} }, function (err, resp) { var items = []; console.log(resp.docs); }); does mget in usage instance ignore conditions of alias , use alias index? i'm afraid hitting issue: https://github.com/elasticsearch/elasticsearch/issues/3861 . an alias can hold filter, used filter search results, default filter. tricky part when use api (or multi_get), implies real-time , not executing search id, ca

winforms - Is it possible to have a Resource folder in a published C# project? -

i have question quite vague. i'm developing windows forms application in c# can read , write games access database. every game has attribute links image in resource folder. while debugging able read , write screenshots following path: "..\\..\\resources\\screenshots\\"; i tried publishing application earlier today test if still work , if not, locate path resource folder when published. so far have feeling resources burned exe file or 1 of other files generates. is in way possible have real folder in published version of application can keep reading , writing images did while debugging? thanks in advance. yes screenshots compiled assembly resources when publising. as real folder, can absolutely that. make sure give app right path folder.

node.js - sails-mysql: ER_NO_DB_ERROR: No database selected -

when trying use sails-mysql er_no_db_error: no database selected exception. though followed instructions able find closely possible. looked related issues: sailsjs - how use mysql https://github.com/balderdashy/sails/issues/632 http://dustinbolton.com/error-er_no_db_error-no-database-selected/ nothing seemed far. this doing: i started out fresh project: sails new sql-test cd sql-test installed sails-mysql sudo npm install sails-mysql i changed config: // config/adapters.js module.exports.adapters = { 'default': 'mysql', mysql: { module : 'sails-mysql', host : 'localhost', port : 3306, user : 'root', password : 'supersecret', database : 'testdb' } }; created model: // api/models/user.js module.exports = { attributes: { name: 'string' } }; and when try run project's root: sails lift i following: logic error in mysql orm. { [erro

Why when an Android activity is killed does the app still run in memory? -

why, when android activity killed app still run in memory? i've read postings on stackoverflow , android documentation cannot find answer. no. when app killed it's no longer running. you can of course program parts of app run background service

javascript - Need google apps script to iterate through an array -

Image
i have modified code found cannot figure out how run whole spreadsheet. the modified code copies spreadsheet, renames based on spreadsheet , files document in appropriate folder. function generatemonthlyreport() { var data = spreadsheetapp.openbyid(customer_spreadsheet); // fetch variable names // column names in spreadsheet var sheet = data.getsheets()[0]; var columns = getrowasarray(sheet, 1); logger.log("processing columns:" + columns); var customerdata = getrowasarray(sheet, customer_id); logger.log("processing data:" + customerdata); // assume first column holds name of customer var customername = customerdata[1]; var customercitystate = customerdata[2]; spreadsheetapp.getactivesheet().getsheetid() var target = createduplicatedocument(source_template, "csmr - " + customername + ", " + customercitystate ); logger.log("created new document"); } not sure understood wanted final resu

visual studio - Restrict nuget package updates to current versions for some packages -

is there way disable updates of specific nuget packages installed in project? i have made local modifications couple of javascript library packages , not want run risk of updating on top of changes in future. i've never created own nuget package, i'm guessing 1 option might fork existing packages? you try constraining package project allow particular version used. updates newer version prevented. you can editing project's package.config file. example, line below should allow version 2.1.0 used. <package id="somepackage" version="2.1.0" allowedversions="[2.1.0]" />

How do I model a "Connections" relation between Doctor-Patient on Ruby on Rails -

i'm using ruby on rails dissertation creating e-health monitoring web application doctors , patients. question is: is there simple approach creating connection option seen on linkedin can use between doctors , patients? i have been thinking , approach create new entity in database called connection store doctor_id , patient_id attributes. how create necessary validations required? e.g example if patient not connected doctor cannot send message doctor or if not connected cannot see information. i'm looking approach or guide how can solve problem. thank you one way approach write method in model make checking relationship nice , clean. example, if wanted check if patient connected doctor, add patient model: patient model def connected?(doc) return true if connection.where(:patient_id => self.id, :doctor_id => doc.id).count > 0 false end then, whenever have instance of patient , doctor in app, can check if connected passing connected

php - Wordpress Mysql database find and replace - Replace only content based on parent -

not super skilled @ mysql commands. used running commands in mysql similar update wp_posts set post_content = replace (post_content,'item replace here','replacement text here'); for finding old urls , various small pieces of content. command searches of posts, , finds/replaces. want argument finds/replaces content based on parent. i'm trying effect of: update wp_posts set post_content post_parent = 4860 = replace (post_content,'old content','new content'); without luck. doing wrong? update wp_posts set post_content = replace (post_content,'old content','new content') post_parent = 4860;

HTML variable for URL -

i have web page 6 streaming ip cams. part of code below: <a target="_blank" href="http://172.28.###.##:102"><img src="http://172.28.###.##:102/videostream.cgi?user=username&pwd=password" width="400" height="300"> when ip changes, need edit above ip times 6. i've searched kind of variable use make 1 change 6 cams. below not work included show i'm trying do. <head> <script type="text/javascript"> var server = "172.28.###.##"; var url = "http://" + server + ":102/videostream.cgi?user=username&pwd=password"; </script> </head> <body> <a href = "<script>" url "</script>" </body> </html> can done? or other way? you're on right track, you're mixing javascript html. doesn't interpret way think would: <a href = "<script>" url "</scrip

python - Is it possible to delete an instance of a class that automatically removes it from all lists in which it is an element? -

i have instance of class appears element in multiple list s. want delete instance , simultaneously remove every list in element. possible? one answer allow objects putting lists manage list membership. example, rather saying lista.append(objecta) you use objecta.addtolist(lista) this allow internally store list of list contain objecta . then, when want delete objecta , need call method this: def cleanup(self): listtoclean in mylists: listtoclean.remove(self) this put strong limitations on program though - example, if copy made of 1 of these lists, objects not have reference copy. have work assumption copy of list (don't forget slices copies, too) may have obsolete objects in it, mean want working original lists possible.

sql - Oracle Select query with dynamic table name -

i m trying create complicated select query uses temp tables , syntax below with table1 ( select start_date, end_date ....somequery - returns 1 row ), table2 ( select ... somequery use table1 columns in clause.. ), table3 ( select ... use table1 columns in clause .. ) select * select case when ( start_date < sysdate -1000 , end_date > sysdate ) 'table2' else 'table3' end table1 rownum < 10 so logic simple based on return value table1 may want query table 2 or may want query table3 problem: oracle doesnt allow table name dynamically generated in sql query i know can write procedure , use execute immediate reason have via single query. appreciated. you can main select : select * table1 cross join table2 start_date < sysdate - 1000 , end_date > sysdate , rownum < 10 union select * table1 cross join table3 not (start_date < sysdate - 1000 , end_date > sysdate) , rownum &

python - adwords api and MCC account and how to add customer ID in report -

i using python adwords api v201402. i have mcc account. report_downloader = self.client.getreportdownloader(version='v201402') # create report definition. report = { 'reportname': 'last 7 days criteria_performance_report', 'daterangetype': 'last_7_days', 'reporttype': 'criteria_performance_report', 'downloadformat': 'csv', 'selector': { 'fields': ['campaignid', 'adgroupid', 'id', 'criteriatype', 'criteria', 'impressions', 'clicks', 'cost'] }, # enable rows 0 impressions. 'includezeroimpressions': 'false' } if dont add customer id below error: output, return_money_in_micros) file "/usr/local/lib/python2.7/dist-packages/googleads-1.0.1

java - Map<String, Entity> with composite key in Entity -

i've got following 2 tables: table a: int id varchar x primary key (id) table b: int a_id varchar locale varchar z primary key (a_id, locale) it's simple onetomany relation. table b contains the id ( a_id ) of referenced row in table a plus locale . means: every entry in a can have 0..* entries in table b , each 1 distinct locale value. i have following 2 classes, should represent tables: @entity @table(name="a") class { @id @column(name="id") int id; @column(name="x") string x; @onetomany(mappedby="a") // ??? @mapkey... // ??? map<string, b> bmap; } @entity @table(name="b") class b { @manytoone @joincolumn(name="a_id") a; @column(name="locale") string locale; @column(name="z") string z; } now 2 things missing: the annotations map<string, b> bmap . don't know if should use @mapkey or @mapkeycolumn , ho

c# - How get primary keys & values in EntityFramework? -

i use following code primary keys of entity in ef : objectcontext objectcontext = ((iobjectcontextadapter)_datacontext).objectcontext; objectset<tentity> set = objectcontext.createobjectset<tentity>(); ilist<string> pkeys = set.entityset.elementtype .keymembers .select(k => k.name).tolist(); but problem here above code retun name of primary keys need values too eg : id,123 so must use reflection purpose obj[i] = entity.gettype().getproperty(pkeys[i]).getvalue(entity, null); is there way do not use reflection values? (more speed)

Chrome extension that turns on/off mobile profile -

is there extension allow me turn profile of running chrome window desktop mobile? is, automatically renders pages in mobile layout switch profile on, , desktop profile when switch off. any ideas? take @ extension allows switch user-agent: https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg regards

bash - Using selfwritten .sh file in another .sh file -

i writing small .sh program in bash. the problem extremely simple, i.e, dind primefactors of number. i've done written .sh file check if number prime or not. here code : if [ $# -ne 1 ]; exit fi number=$1 half=$(($number / 2)) (( i=2;i<$half;i++ )) rem=$(($number % $i)) if [ $rem -eq 0 ]; echo "0" exit fi done echo "1" and second .sh file generate prime factors : clear echo "enter number : " read number half=$(($number / 2)) for(( i=1;i<=$half;i++ )) rem=$(($number % $i)) if [ $rem -eq 0 ]; ok=`prime.sh $rem` if [ "$ok" == "1" ]; echi $i fi fi done this line , ok=`prime.sh $rem` gives following error : primefactor.sh: line 10: prime.sh: command not found so, not possible divide program smaller modules , use in other modules other programming languages ? on how achieve helpful. call script this: ok=`./prime.sh $rem

java - proper way to capture meaningful sql exception -

in java try - catch clause, want able capture exact cause of sql exception (i using postgres, question applies jdbc drivers). had is } catch (throwable ex) { // rollback ex.printstacktrace(); string message = ex.getmessage(); throwable cause = ex.getcause(); if (cause instanceof constraintviolationexception){ sqlexception exc = ((constraintviolationexception)cause).getsqlexception(); if (exc instanceof batchupdateexception){ sqlexception nextex = ((batchupdateexception)exc).getnextexception(); if (nextex instanceof psqlexception){ message = ((psqlexception)nextex).getmessage(); } } } throw new recordserviceexception(message); } this awful, , works specific type of exception. isn't there more valid way capture meaningful sql exception? from oracle docs: http://docs.oracle.com/javase/tutorial/jdbc/basics/

javascript - different colors for different routes on google maps importing multiple KML files build in google engine? -

i loading multiple kml layers files google maps. becomes difficult read since different bus routes on map. possible have them in different colors example kml1 file in red , kml2 file in blue etc. used google engine build these kml files did not option use different colors on line/markers. function initialize() { var abby = new google.maps.latlng(49.051078,-122.314221); var mapoptions = { zoom: 11, center: abby } map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); var ctalayer = new google.maps.kmllayer({ url:'https://dl.dropboxusercontent.com/u/143598220/1.%20blueridge-mckee%20goline.kml' }); var ctalayer2 = new google.maps.kmllayer({ url:'https://dl.dropboxusercontent.com/u/143598220/2.%20bluejay-huntingdon%20goline.kml' }); var ctalayer3 = new google.maps.kmllayer({ url:'https://dl.dropboxusercontent.com/u/143598220/3.%20clearbrook%20-%20ufv%20goline.kml' }); ctalayer.setmap(

c# - JWT and Web API (JwtAuthForWebAPI?) - Looking For An Example -

i've got web api project fronted angular, , want secure using jwt token. i've got user/pass validation happening, think need implement jwt part. i believe i've settled on jwtauthforwebapi example using great. i assume method not decorated [authorize] behave does, , method decorated [authorize] 401 if token passed client doesn't match. what can't yet figure out how send token client upon initial authentication. i'm trying use magic string begin, have code: registerroutes(globalconfiguration.configuration.routes); var builder = new securitytokenbuilder(); var jwthandler = new jwtauthenticationmessagehandler { allowedaudience = "http://xxxx.com", issuer = "corp", signingtoken = builder.createfromkey(convert.tobase64string(new byte[]{4,2,2,6})) }; globalconfiguration.configuration.messagehandlers.add(jwthandler); but i'm not sure how gets client initially. think understand how handle on client, bonus points if c

php - Data not displaying -

i have link links page echoes out information depending on id of link not echoing out information. in advance help. if($connect) { mysql_selectdb('phplogin'); $id = $_get['id']; $query = mysql_query("select * forum id = '$id'"); $data = mysql_fetch_array($query); echo "<div class='post'>" . "<div class='leftside'>" . "<h3 class='by'>" . $data['user'] . "</h3>" . "<h5 class='date'>" . $data['time'] . "</h5>" . "</div>" . "<div class='after'>" . "</div>" . "<div class='rightside'>" . "<h2 class='title'>" . htmlspecialchars($data['title']) . "</h2>" . "<p class='description'>" . htmlspecialchars($dat

.net - LINQ Datatable and Select columns -

sorry english. i have list column names need select. i have datatable(nr1) many columns(40) , rows(2000) i need new datatable(nr2) data, have columns from; datatable(nr1).column.name = list items , data column. i have; token_datatable_ data.datatable and; token_columnlist list(of string) and dim rettable datatable = new datatable 'this new table need dim query = element in datatable_, element_ string in token_columnlist select element.field(of object)(element_) 'something need? you don't need linq @ all. just use dataview , totable method, like dim newtable = new dataview(originaltable).totable(false, columnlist.toarray()) this create new datatable columns of originaltable names in columnlist .

javascript - How add automatically [img] tag in my links? -

how add [img] tag in links. want load in box link e.g. like: http://site com/images/image1.jpg http://site com/images/image2.jpg http://site com/images/image3.jpg then want url converted automatically to [img]http://site com/images/image1.jpg[/img] [img]http://site com/images/image2.jpg[/img] [img]http://site com/images/image3.jpg[/img] if use code works first image displayed [xfgiven_screenshot] <div id="section-screenshot" class="fullfeature"> <div class="clear"></div> <div class="screenshots"><img src="[xfvalue_screenshot]" alt="" /></div> <div class="clear"></div> </div> [/xfgiven_screenshot] what should display rest of links images? thanks help!

Scala Parser Combinators: Parsing terms with optional initial character -

i'm working on parser parses few terms have optional initial character same terms. problem is, of terms first character same initial character. i'm trying avoid rewriting each term , without initial character. figured packrat parser sounded solution i've yet working way want. below minimal example of i'm trying accomplish. import scala.util.parsing.combinator._ import scala.util.parsing.input._ object test extends app { object myparser extends regexparsers packratparsers { lazy val p1:parser[string] = "ab" lazy val p2:parser[string] = "cd" lazy val parser:packratparser[string] = ("a".?) ~> ( p2 | p1 ) } def parsing[t](s: string)(implicit p: myparser.parser[t]): t = { import myparser._ val phraseparser = phrase(p) val input = new packratreader(new charsequencereader(s)) phraseparser(input) match { case success(t, _) => t case nosuccess(msg, _) => throw new illega

javascript - Liquid Grid - How do people refer to it -

Image
i've been playing google apps console , has fluid page there grids of items. when user makes window bigger , smaller width of grid items gets smaller , smaller until drops 1 onto next row when cant make each grid item smaller. can tell me technique called can find tutorials. bonus points, require javascript? the technique known liquid or elastic layout. achieved via css, no javascript required. if you're looking tutorials, might article useful: "70+ essential resources creating liquid , elastic layouts" zoe mickley gillenwater

java - CustomLinkedList with generics -

i implementing linkedlist generics. i'm getting "multiple markers @ line - type myiterator not generic; cannot parameterized arguments " @ return statement. figure interface public iterator<figure> iterator() { class myiterator implements iterator<figure> { private node current; private myiterator(node n) { current = n; } public boolean hasnext() { return current.next != null; } public figure next() throws nosuchelementexception { if (current.next == null) throw new nosuchelementexception(); current.setnext(current.next); object c=current; return (figure) c; } public void remove() { throw new unsupportedoperationexception(); } } return new myiterator<figure>(); } clearly myiterator not generic. you've use generic type. change return sta

java - How to set parsed image as background instead of src -

i have customized list view parses images lists reads them in src <imageview android:id="@+id/list_image" android:layout_height="420dp" android:layout_width="fill_parent" android:src="@drawable/posty" android:clickable="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignparentright="true" android:layout_alignparentend="true"/> is there anyway set android:src="@drawable/posty" can android:background="@drawable/posty" parsed image thanks. the adapter: public class lazyadapter extends baseadapter { private activity activity; private arraylist<hashmap<string, string>> data; private static layoutinflater inflater=null; public imageloader imageloader; public lazyadapter(activity a, arraylist<hashmap<string, string>> d) { activity = a; d

Google Maps API v3, Gray Box, no map -

i want show multiple point database ,i'm getting gray box, controls , google logo/copyright code follows, <? $dbname='usedb' ; //name of database $dbuser='user' ; //username db $dbpass='pwd' ; //password db $dbserver='localhost' ; //name of mysql server $dbcnx=m ysql_connect ( "$dbserver", "$dbuser", "$dbpass"); mysql_select_db("$dbname") or die(mysql_error()); ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>google map api v3 markers</title> <style type="text/css"> body { font: normal 10pt helvetica, arial; } #map { width: 350px; height: 300px; border: 0px; padding: 0px; } <script src=&

Small bug when I resize image proportionally using jquery. -

( 10 reputation showing images??... really?...) hi guys. the problem i'm undergoing that, when resize images, resized more once believe. for example, i uploaded square image, result rectangle. when wrong result comes, refresh page f5 key, , square. only height og resized image problem. below code used resize images. function thumbnail_resize(obj) { var maxw = 50; var maxh = 50; var wid = obj.width(); var hei = obj.height(); if( wid > maxw ) { hei *= (maxw / wid); wid = maxw; } if( hei > maxh ) { wid *= (maxh / hei); hei = maxh; } obj.attr('width', wid); obj.attr('height', hei); delete maxw, maxh, wid, hei; return; } currently believe resizing ratio ( i.e => hei *= maxw / wid; ) applied several times when resizing height of images. please give me wisedom!!! it appears part of problem looking @ image's height , width in $(document).ready()

How can I generate a alphanumeric series in Python -

i want generate alphanumeric series printing invoice number. example: mt00001, mt00002, mt00003 it should not random. please me. looks pretty straight forward >>> class letter_generator: ... def __init__(self, prefix, places): ... self.prefix = prefix ... self.places = places ... current = 0 ... def get_unique_id(self): ... self.current+=1 ... return "%s%s" % (self.prefix, str(self.current).zfill(self.places)) ... >>> >>> l = letter_generator('tm',5) >>> l.get_unique_id() 'tm00001' >>> l.get_unique_id() 'tm00002' >>> l.get_unique_id() 'tm00003' >>> l.get_unique_id() 'tm00004' >>>