Posts

Showing posts from May, 2012

Unit test Laravel middleware -

i trying write unit tests middleware in laravel. know tutorial, or have example of ? i have been writing lot of code, there must better way test handle method. using laravel 5.2, unit testing middleware passing request input , closure assertions. so have middleware class getcommandfromslack parses first word of text field in post (the text slack slash command) new field called command , modifies text field not have first word more. has 1 method following signature: public function handle(\illuminate\http\request $request, closure $next) . my test case looks this: use app\http\middleware\getcommandfromslack; use illuminate\http\request; class commandsfromslacktest extends testcase { public function testshouldknowliftcommand() { $request = new illuminate\http\request(); $request->replace([ 'text' => 'lift foo bar baz', ]); $mw = new \app\http\middleware\getcommandfromslack; $mw->handle($request,function($r)

javascript - How to use draw:deletestart in leaflet -

i want perform operation when user clicks on delete button in leaflet. how doing : map.on('draw:deletestart', function(e) { alert("started"); }); but not triggering when click delete button. kindly suggest. i doing in internet explorer. ran same code in mozilla firefox , chrome , it's working fine.

html - Javascript: Uncaught ReferenceError -

<html> <head> <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.js"/> <script type="text/javascript"> $(document).ready(function(){ $('#name').val('name1'); }); function clickme(){ console.log('click me called'); } </script> </head> <body> person name: <input type="text" id="name" data-bind="value:personname"> <input type="submit" value="save" onclick="javascript:clickme()"/> </body> </html> in code above neither function inside document.ready getting executed nor "clickme" function getting executed when "save" button clicked. when click on "save" button, uncaught referenceerror: clickme not defined error message seen. because haven't closed script tag of jquery . <script> not self-closing tag. <script typ

python - Search in DBF and update record -

code: #!/usr/bin/python db = dbf.dbf("mest2.dbf") #line update: rec = db[0] #proest field of dbf. i'm assigning 1 field line 0 rec["proest"] = 1 rec.store() del rec db.close() image of dbf table: http://i.stack.imgur.com/1uhe1.jpg my problem can not change records rows, cause position of products (procod) may vary. any suggestions procod , change value of proest? updated: #!/usr/bin/python import dbf db = dbf.table('mest2.dbf') db: procod_idx = db.create_index(lambda rec: (rec.codigo, rec.procod)) match = procod_idx.search(match='000001') # should 1 product code record = match[0] record: record.proest = 23 but question is, how edit value based on codigo field (stock code). have multiples stocks id: (1, 2, 5, 11). code update first result, need update specific record based in codigo field. in sql be: "update proest set 32 codigo=11"... or codigo=2 solved ethan furman #!/usr/bin/py

STS 3.7.0 Eclipse 4.5 Mars to Support HTML5 and CSS3 -

i downloaded sts 3.7.0 using eclipse 4.5.0 mars. i have java web application. need use html5, css3 , angularjs. installed angularjs plugin. new version doesn't support css3. best plugin can use eclipse of now? saw post aptana.com appcelerator , i'm not able install plugin. i see this link on how install wtp . need know whether supports css3 , html5. because doesn't says that. if supports, how can install? do need install web, xml, java ee , osgi enterprise development that? because in sts 3.6.4 tried install listed features url , sts not opening. thought use latest version of sts. which best option?

git - Squash commits directly on feature without rebase or merge -

i've been reading little --squash ing commits, seem go hand in hand --rebase . i have feature branch set of commits this: (feature) --> b --> c --> d --> e --> f --> g / (master) m1 --> m2 --> m3 suppose want merge master branch, want clean commits on feature first. is possible to: pick commit b, e , f , squash them 1 commit? or can squash commits come in order, squash: (a, b , c), or squash (d, e , f) etc? either way, can squash directly on feature, without immidiately initializing merge or rebase it? if so, how can git? yes , no. yes, can avoid changing parent of commit 'a' believe can't avoid git rebase . can interactive rebase on same root: git rebase -i m2 feature then can whatever want , @ end branch feature still start commit m2.

Powershell script only converting last sAmAccountname to name -

just wrote quick script below convert samaccountname name. converts last samaccountname in list. why? doing wrong? $users = get-content .\tempuser.txt $results = @() foreach($user in $users) { $result = get-aduser -identity $user | select name, samaccountname } $result | out-file .\test12.txt change following line adding plus: $result += get-aduser -identity $user | select name,samaccountname

c# - sqlite in windows phone 8 runtime -

Image
i trying make sample sqlite db app in windows phone 8 using this example . now not able add sqlite.dll in project.

.htaccess - write htaccess to dynamic generate id core php -

i doing 1 project in core php, , have url theese www.domainanme.com?proid=125&name=some_name . how redirect 404 page error. if delete id 125(in admin panel) still shows page without contents. can me how write htaccess redirect 404 error page. i think should check in php if item exist , if not - redirect 404 page. apache doesn't know code , think return page 200 http response code , in case apache think right , show empty page.

c++ - how to define repeated field as required in google protocol buffer? -

how define repeated field required in google protocol buffer?i have field modifier repeated(repeated int32 ).how add required modifier field? in fact want have both modifier(required , repeated). sorry, there no way mark repeated field "required". in fact, required considered misfeature , being phased out in protobuf 3.0. extended explanation/rant of why case, see: https://capnproto.org/faq.html#how-do-i-make-a-field-required-like-in-protocol-buffers (that's link cap'n proto web site, competitor protobufs, author (namely, me) main author of protobuf v2.)

c# - WPF DataGrid shows no data -

this constructor of usercontrol includes datagrid element. public results(list<cartitem> items) { initializecomponent(); this.items.datacontext = items; } and xaml of datagrid. <datagrid autogeneratecolumns="false" name="items" isreadonly="true" minheight="300"> <datagrid.columns> <datagridcheckboxcolumn> <datagridcheckboxcolumn.headertemplate> <datatemplate> <checkbox style="{staticresource stylecheckbox}" ischecked="{binding isselected}"/> </datatemplate> </datagridcheckboxcolumn.headertemplate> </datagridcheckboxcolumn> <datagridtextcolumn header="abone no" binding="{binding subscriberno}" /> <datagridtextcolumn header="adı soyadı" binding=&quo

php - codeigniter, 404 not found error -

i have web site , have installed codeigniter 2 site under sub folder ( test ) users can access site using following link: http://www.example.com/test/ when user going access ( test ) site using above link url redirected following link , following error displayed. http://www.example.com/test/login not found the requested url /test/login not found on server. then add index.php above url, login page displayed. http://www.example.com/test/index.php/login when submit username , password again url redirected to, without logged on. http://www.example.com/test/login and again, not found. .htaccess : <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l] </ifmodule> config.php : $config['base_url'] = ''; $config['index_page'] = ''; $config['uri_protocol'] = "auto" ; i have tried

c++ - List functions in *.lib on Windows -

when run lib /list mylib.lib see contained .obj files, no information functions similar this: path\file1.obj path\file2.obj path\file3.obj if open .lib file archieve can see there number of files 1.txt, ..., n.txt in addition object files. txt files seem contain information functions in .obj files on format: : path\file1.obj ?function_name@... : thus info can retrieved way. but isn't there better way function info ? example using lib.exe , dumpbin.exe or tool ? in more readable/demangled format ? far had no luck finding that. there related question here not discuss object files contained in .lib file. you need use dumpbin . (see dumpbin on msdn more information.) dumpbin /symbols /exports mylib.lib you can use dumpbin followed undname . (see undname .) example: dumpbin /all /exports mylib.lib > mylib.txt undname mylib.txt of course need command prompt visual studio tools in path. install dumpbin , undname at: c:\program files (x86)\mic

sqlite - SELECT and ADD fields in SQL table -

i have db table created follows : create table mktdb( mktid number(19) not null, featureid number(20) not null, val varchar(100) not null, primary key (id) ); i want view records along additional field having current date each row in db. i tried following sqlite query erroneous : select *, current_date mktdb,date; don't know sqlite after typing "current date sqllite" in google shows me way https://www.sqlite.org/lang_datefunc.html and problem: select *, date('now') mktdb; p.s: wanted try sql fiddle. here is: http://sqlfiddle.com/#!7/92fd6/3

c# - Binding SelectedItems of ListView to ViewModel -

i have list view binding items property in viewmodel. <listview height="238" horizontalalignment="left" name="listview" verticalalignment="top" width="503" itemssource="{binding businesscollection}" selectionmode="multiple" > <listview.view> <gridview> <gridview.columns> <gridviewcolumn> <gridviewcolumn.celltemplate> <datatemplate> <checkbox ischecked="{binding relativesource={relativesource ancestortype={x:type listviewitem}}, path=isselected}" /> </datatemplate> </gridviewcolumn.celltemplate> </gridviewcolumn> <gridviewcolumn displaymemberbinding="{binding id}" he

javascript - how do I copy and paste images in php -

how copy , paste uploaded images in php. when click on copy button copy uploaded images. when click on paste button paste copy image using javascript , php <script type="text/javascript"> function clicked(){ var src = document.getelementbyid('copy').value document.getelementbyid('paste').value = src; } </script> html: <ul id="image_list"> <li><img src="elements/1.png" id="copy" width="640px" height = "480px" /></li> </ul> <button onclick="clicked();"> copy </button> check this, should you. else asked question way. search first, please. :) <script> function copy() { if(window.clipboarddata) { window.clipboarddata.cleardata(); window.clipboarddata.setdata("text", document.getelementbyid('txtacpy').value); } } function paste() { if(window.clipboarddata) { document.getelementbyid('txtapaste

C# Convert string to array -

so i'm working umbraco , using tag datatype. i'm trying take tags added given node , putting them array of strings when grab value seems come out this: "[\"tag1\",\"tag2\"]" how can convert string of array regular array? have gotten far string of individual characters the array format have provided example looks part of json object. you use json.net library parse array token of json object. var array = jarray.parse(tagstring).values<string>(); a complete example available here .

angularjs - Angular Unit Testing: How do i call a named function -

i have controller, contains named function. function controller($scope, ...){ function foo(data){ //logic other stuff $log(data); } //some promise stuff waiting.then(function(data){ foo(data); }); for way functions available, didnt want assign foo scope variable, since doing this: $scope.foo = function(data) {} was frowned upon? (not sure...but since not calling foo view, dont see why would) my issue is, how call foo function unit test "it" block? i.e it('expect calling function', function(){ foo(data); }); this gives me error call foo function outside controller impossible, because foo closure - inner function defined , available within controller function body. see https://developer.mozilla.org/cs/docs/web/javascript/closures#lexical_scoping i prefer controlleras syntax angular controller. controller ordinary object constructor properties , method defined on this. binding scope arises during evaluation ng-co

c - Console input in 32-bit Protected mode -

i working on os. i've started building since a-day before yesterday. os command-based. this kernel.c(the main file): #include "include/screen.h" #include "include/kb.h" #include "include/string.h" #include "data/userdata.c" kmain() { clearscreen(); print("halcyon os 1.05 beta "); while (1) { print("\nhalcyon@halcyon ~\n$ "); string ch = readstr(); if(streql(ch,"cmd")!=0) { print("\nyou in cmd\n"); } else if(streql(ch,"clear")!=0) { clearscreen(); } else if(streql(ch,"help")!=0) { print("halcyon help."); } else if(streql(ch,"")!=0) {

javascript - Chrome Extension: Interacting with iframe embedded within popup -

i writing chrome extension needs interact urls user not have open. therefore using hidden iframes embedded within popup, , attempting click button within iframe. however, receiving same origin policy error. know possible extension interact iframes of different domain via content scripts when iframe on tab user has open, not sure if possible use content scripts interact iframes directly in popup. here code: manifest.json "content_scripts": [ { "js": [ "bin/jquery.min.js", "interaction.js" ], "all_frames": true, "run_at": "document_start", "matches": [ "http://*/*", "https://*/*" ] }], "permissions": [ "activetab", "tabs", "http://*/", "https://*/" ], interaction.js $(document).ready(function() { $('div#iframes').append("<iframe id='shop' src=

Performance problems on BigQuery project: Resource exceeded -

suddenly see performance issues our project lately: aerobic-forge-504 job_nkhejdjbt1qn3z3iljep9c78mxc query failure 14 jul 10:12:11 0:18:52 job_qtv2mfotikzdzanhtbxrcot3thi query success 14 jul 10:10:32 0:21:48 job_8ekvsgqrke5ox6vbjhb4kpm7kvg query success 14 jul 09:41:09 0:14:53 job_eeuvmsshma3bkjtekyj0ob33blm query success 14 jul 09:00:51 0:15:09 usually response time around 30 seconds, queries take 15 minutes, , didn't modified queries months. we got also: resources exceeded during query execution thanks heads up. believe performance problem in our query planner, , we're working on fix. we'll track issue in bug filed on here: https://code.google.com/p/google-bigquery/issues/detail?id=283

symfony - FOS User Bundle: access other user profile: "This user does not have access to this section." -

i trying set simple action member details of other members of website; controller @ moment: public function modalprofileaction($id) { $usermanager = $this->get('fos_user.user_manager'); $user = $usermanager->finduserby(array('id' => $id)); if (!is_object($user) || !$user instanceof userinterface) { throw new accessdeniedexception('this user not have access section.'); } return $this->render('testuserbundle:profile:modal_short_profile.html.twig', array( 'user' => $user )); } this action triggered js (ajax method get). routing is: test_user_modal: pattern: /team-member/{id} defaults: { _controller: testuserbundle:user:modalprofile } methods: [get] requirements: id: \d+ i geeting follwong error: "this user not have access section." there way around that? using wrong method or there security issue should include? ideas welcome 1)if want curr

javascript - Hidden Field Value Not Getting Filled JQuery -

i have html table append using jquery follows fires on button click $("#listadd").click(function() { if (validatelistadd()) { var mcode = $("#mcodehidden").val(); if(checkitemduplicates(mcode)) { var mname = $("#mnamehidden").val(); var sellprice = $("#sellprice").val(); var cost = $("#cost").val(); var qty = $("#qty").val(); var remark = $("#remark").val(); var subtotal = sellprice * qty; alert(qty); $("#productlist tbody").append('<tr class="sumrow"><td><input id="hdqty" type="hidden" name="tblqty[]" value="' + qty + '"><input id="hdsubtotal" type="hidden" name="tblsubtotal[]" value="' + subtotal + '"><input type="hidden" name="tb

Crashlytics : Android Studio Gradle Error related to XML -

i getting error while building app crashlytics error:(2) error parsing xml: prefix must not bound 1 of reserved >namespace names there com_crashlytics_export_strings.xml added crashlytics automatically. mind file added module project inside main project . main project doesn't have file. use android studio plugin. has following content. <?xml version="1.0" encoding="utf-8" standalone="no"?> <resources > <!-- file automatically generated crashlytics uniquely identify individual builds of android application. not modify, delete, or commit source control! --> <string xmlns:ns0="http://schemas.android.com/tools" name="com.crashlytics.android.build_id" ns0:ignore="unusedresources,typographydashes" translatable="false">0acfc26a-32c4-4a2e-b19b-fullkey</string> </resources> while building following file generated. @ xmlns:ns0 turn xmlns:ns1 in generated ones &

Can I create an object that receives arbitrary method invocation in python? -

in python, can create class that, when instantiated, can receive arbitrary method invocation? have read this couldn't put pieces together i guess has attribute lookup . class foo : class foo(object): def bar(self, a): print the class attribute can obtained print foo.__dict__ , gives {'__dict__': <attribute '__dict__' of 'foo' objects>, '__weakref__': <attribute '__weakref__' of 'foo' objects>, '__module__': '__main__', 'bar': <function bar @ 0x7facd91dac80>, '__doc__': none} so code valid foo = foo() foo.bar("xxx") if call foo.somerandommethod() , attributeerror: 'foo' object has no attribute 'somerandommethod' resulted. i want foo object receive random invocations , defaults no-op, ie. def func(): pass how can achieve this? want behaviour mock object testing. from http://rosettacode.org/wiki/respond_to_an_unknown_

c++ - Why is std::unique_lock not derived from std::lock_guard -

std::lock_guard , std::unique_lock interfaces similar, in common part (constructors , destructor). why there no hierarchical relationship between them? they have non substitutable semantics: lock_guard guaranteed locked through of it's lifetime. unique_lock doesn't guarantee doesn't follow "is a"-rule ( unique_lock cannot lock_guard , offers fewer guarantees). also implementing unique_lock based on lock_guard wouldn't trivial (maybe impossible) reason. obviously same true other way round: although can implement lock_guard in terms of unique_lock (private inheritance), lock_guard doesn't provide same functionality ( lock()/unlock() ) unique_lock cannot publicly derived it.

android - "Error:Gradle: Content is not allowed in prolog" when running tests -

using android studio, when try run unit tests, fails following error in messages (gradle build): error:gradle: content not allowed in prolog. error:gradle: execution failed task ':module:mergedebugandroidtestresources'. > /users/me/path/to/my/project/src/test/resources/fixtures/activity_feed.json:0:0: error: content not allowed in prolog. seems yet variant of content not allowed in prolog error, doesn't makes sense, found out searching solution. in case, points json file, doesn't contain prolog code. find build variants view: left tool pane view -> tool windows -> build variants once there, locate: test artifact: android instrumentation tests and instead android instrumentation tests select: test artifact: unit tests

haskell - How to prevent profiling dependency issue before Genesis -

it know profiling large packages require destroying , rebuilding world . however, there anyway avoid when starting fresh? how can enable benchmark , profiling first time install ghc platform on new machine?

ruby - Rails 4 HABTM has_many :through -

team, looking specific (newbie) situation on rails 4 association. have 3 models: class brand < activerecord::base has_many :lines, dependent: :destroy has_many :products, through: :lines, dependent: :destroy end class line < activerecord::base belongs_to :brand has_and_belongs_to_many :products end class product < activerecord::base has_and_belongs_to_many :lines has_many :brands, through: :lines end this configuration works when trying check products under specific brand (or line ) , viceversa: different brands (or lines ) available specific product . however, when comes delete/destroy there issue. getting rspec error: activerecord::hasmanythroughcantassociatethroughhasoneormanyreflection: cannot modify association 'brand#products' because source reflection class 'product' associated 'line' via :has_and_belongs_to_many. we have made research on exception, checked rails api, no luck, examples found showing different model configu

javascript - Jquery appended item click function not working -

this question has answer here: event binding on dynamically created elements? 19 answers ok have button when clicks appends info section. like so: function() { $(".blend-tile").click(function() { $(this).hide(); var li = $('<li><div class="align-table"><div class="color-img t-align"></div><div class="t-align"><div class="infora"></div><div class="percent-mix"></div><div class="mix-value"></div></div></div><div class="clear-tile">x</div></li>'); $('#mixers').append(li); $('.tpic', this).clone(true, true).contents().appendto(li.find('.color-img')); $('.infora', this).clone(true, true).contents().appendto(li.find('.infora')

opencl - Knapsack algorithm: strange behavior with pown() on the gpu -

the version on cpu ocl produces right results, gpu ocl in places gives different results in places after influence correctness of result. have debugged on intel ocl sdk right results. haven't spotted race condition or concurrent access memory. problem has appeared after have introduced in kernel (one line of code) pown function. void kernel knapsack(global int *input_f, global int *output_f, global uint *m_d, int cmax, int weightk, int pk, int maxelem, int i){ int c = get_global_id(0)+cmax; if(get_global_id(0)<maxelem){ if(input_f[c] < input_f[c - weightk] + pk){ output_f[c] = input_f[c - weightk] + pk; m_d[c-1] = pown(2.0,i); *//previous version: m_d[c-1] = 1;* } else{ output_f[c] = input_f[c]; } } } the purpose of pown compress m_d buffer holds outcomes. for example 1 0 1 0 2^0+2^2, 2^1, 2^0, 2^1 0 1 0 1 => 1 0 0 0 on gpu this: 2^0+2^2, 2^1, 2^0+2^2, 2^1 in 3rd column access pown 1 more again, whe

debian - How can I use the kernel function in my C code? -

first, want apologize english, it's not mother language best. i'm new developer in debian, before cross-plateform code. since cross-plateform isn't in constraint anymore, want close possible kernel. for example, want use aes crypt file. aes exist in kernel , prefer use aes kernel rather aes (i trust more kernel source code). there way use kernel function in user space ? more precisely, exist method, or documentation ? if want have doc of c function, "man function". there equivalent kernel ? i hope doesn't make mistake question. thank reading, stack overflow me dozen , dozen time in past, thank you. edit : sorry, edit post , hope it's better time. is there way use kernel function in user space? no, kernel function cannot called directly user space. you can write kernel module, calls desired function responce request user space.

javascript - How to start using yoda speak web service -

i web programming beginner programming knowledge level cannot handle problem , googled lot still no result. using yoda speak api http://www.yodaspeak.co.uk/webservice/yodatalk.php?wsdl it xml file. xml file documentation file? how can set text box , button call program? wrote codes not work. html: <p><h1>here converter changing sentences yoda's style</h1></p> <input type="text" id="input"> <button class="button" onclick="convert()">convert</button> javascript: function convert(){ var input = document.getelementbyid('input').value; } and sorry not know how continue. sorry. have checked ws.js. more info @ http://www.ibm.com/developerworks/webservices/library/ws-wsajax/ you may better off using rest style api's such this, http://funtranslations.com/api/yoda since integrating javascript easy. here functional example using funtranslations yoda api. $

java - Run my integration tests with a different *.properties file using Spring 4.0.6.RELEASE -

i using spring 4.0.6.release , have following spring configuration file: @configuration @propertysource({"classpath:config.properties"}) public class myserviceconfig { ... i wondering if there way run integration tests component-annotated-classes different properties file (let's test-config.properties ) in order give different values value , autowired annotated properties , methods. note: know spring 4.1.x comes @testpropertysource helps achieve it. upgrading spring later versions not option. yes. specify "profile" integration tests. @configuration @propertysource({"classpath:test-config.properties"}) @profile("integration-test") public class myservicetestconfig { ... in order use profile when testing repository use @activeprofiles annotation @activeprofiles("integration-test") @runwith(springjunit4classrunner.class) public class myrepositorytest { ...

Need some inputs in feature extraction in Apache Spark -

i new apache spark , trying use mlib utility analysis. collated code convert data features , apply linear regression algorithm that. facing issues . please , excuse if silly question my person data looks like 1,1000.00,36 2,2000.00,35 3,2345.50,37 4,3323.00,45 just simple example code working import org.apache.spark.sparkcontext import org.apache.spark.sparkcontext._ import org.apache.spark.sparkconf import org.apache.spark.mllib.linalg.{vector, vectors} import org.apache.spark.mllib.regression.labeledpoint case class person(rating: string, income: double, age: int) val persondata = sc.textfile("d:/spark/mydata/persondata.txt").map(_.split(",")).map(p => person(p(0), p(1).todouble, p(2).toint)) def preparefeatures(people: seq[person]): seq[org.apache.spark.mllib.linalg.vector] = { val maxincome = people.map(_ income) max val maxage = people.map(_ age) max people.map (p => vectors.dense( if (p.rating == "a") 0.7 else if

I want to add my class name with each element in css using php -

i want create css parse type.. parse add class name each element in css. for example i've following css .class1 {font-size:10px} .class2 {font-style:italic} body {height:100%} html {width:100%} after parser this. .myclass .class1 {font-size:10px} .myclass .class2 {font-style:italic} .myclass body {height:100%} .myclass html {width:100%} i created function doesn't work when @media queries come in css nested elements. can provide me css parsers/solutions. tried available css parsers. not enough solution. for this, recommend sabberworm's php-css-parser . i've used myself , it's fantastic tool. can install via composer adding code beneath composer.json { "require": { "sabberworm/php-css-parser": "*" } } after installing it, it's pretty straight forward. can either pass in css-code variable containing css in string, or reading file specific directory. in example, read directory. $ocsspars

Hovering over div and adding HTML/CSS is breaking the flow of my page -

when hover on div js inserts new html, breaks flow in page. think css margin in title class, want title centered. best way fix this? .title { width: 100%; height: 30px; text-align: center; margin: 0 auto; background-color: black; color: snow; margin-top: 23%; margin-bottom: 0; } fiddle http://jsfiddle.net/lee45276/t8xfto77/ just add vertical-align: top: .project { //your stuff vertical-align: top; } here fiddle working: http://jsfiddle.net/t8xfto77/1/

Select max of one date after getting max of other date -

i using oracle's psquery tool not have access actual code. generate list of students maximum dropped course . however, if student has more 1 dropped course on same max date, want return 1 max deadline date. so, max drop dates duplicates narrowed down further max deadline date. select s.studentid, s.name, max(s.date), (s.deadlinedate), max(d.droppedcourse) droppedcourse student s join deadlinedate d on s.studentid = d.studentid group s.studentid, s.name, s.date having max(d.deadlinedate);

sql - regexp in PySpark -

i trying reproduce results of django orm query in pyspark: social_filter = '(facebook|flipboard|linkedin|pinterest|reddit|twitter)' collection.objects.filter(social__iregex=social_filter) my main problem should case insensitive. i have tried this: social_filter = "social ilike 'facebook' or social ilike 'flipboard' or social ilike 'linkedin' or social ilike 'pinterest' or social ilike 'reddit' or social ilike 'twitter'" df = sessions.filter(social_filter) which result in following error: py4jjavaerror: error occurred while calling o31.filter. : java.lang.runtimeexception: [1.22] failure: end of input expected social ilike 'facebook' or social ilike 'flipboard' or social ilike 'linkedin' or social ilike 'pinterest' or social ilike 'reddit' or social ilike 'twitter' and following expression: social_filter = "social ~* (facebook|flipboard|linkedin|pi

awk - Replace all instances of - with . until A or G or T or C from both ends of a string -

so example if input is: -------a--gg---ccaat---a------ output should be: .......a--gg---ccaat---a...... prefer in awk. this going bit complicated because awk not allow call function matched string, need manually take out matched strings ( l , r ), further process them, , replace $0 original string plus matched strings: awk '{ if (match($0, /^-*/)) { l = substr($0, 1, rlength); gsub("-", ".", l); $0 = l substr($0, rlength + 1); } if (match($0, /-*$/)) { r = substr($0, rstart); gsub("-", ".", r); $0 = substr($0, 1, rstart - 1) r; } print $0; }' or using gsub again mutate matched strings in $0 instead of concatenating: awk '{ if (match($0, /^-*/)) { l = substr($0, 1, rlength); gsub("-", ".", l); gsub(/^-*/, l, $0); } if (match($0, /-*$/)) { r = substr($0, rstart); gsub("-", ".", r); gsub(/-*$/, r, $0); } print $0; }'

java - Antlr4 doesn't recognize identifiers -

i'm trying create grammar parses file line line. grammar comp; options { language = java; } @header { package analyseur; import java.util.*; import component.*; } @parser::members { /** line write in new java file */ public string line; } start : objectrule {system.out.println("obj"); line = $objectrule.text;} | anystring {system.out.println("any"); line = $anystring.text;} ; objectrule : objectkeyword id ; anystring : any_string ; objectkeyword : 'object' ; id : [a-za-z]+ ; any_string : (~'\n')+ ; whitespace : (' '|'\t') -> skip; when send lexem 'object o' grammar, output instead of obj. 'object o' => 'any' // obj i know any_string longer wrote lexer tokens in order. problem ? thank ! ;) for lexer rules, rule longest match wins, independent of rule ordering. if match length same, first liste

javascript - Polymer icons not showing in Chrome -

i using meteor backend , polymer frontend. have imported icons not showing in chrome: <link rel="import" href="/bower_components/paper-icon-button/paper-icon-button.html"> <link rel="import" href="/bower_components/iron-icons/iron-icons.html"> <link rel="import" href="/bower_components/iron-icon/iron-icon.html"> <link rel="import" href="/bower_components/iron-pages/iron-pages.html"> they show in safari , firefox on mac 10.10.3. chrome version 43.0 this not work in chrome: <paper-icon-button icon="favorite"></paper-icon-button> i have cleared cache , restarted both server , mac shows in firefox , safari. im reinstall mbp im losing more hairs in young age. possible duplicate of this. working on fix, in meantime can use solution in thread: polymer 1.0 default icon set in iron-icons not working using blaze (meteor) templating engine

osx - Command-line alias for Visual Studio Code on OS X with CSH? -

the vs code editor nice, , i'm looking forward using learn bit more javascript , node.js. installation instructions describe setup bash -like shells, savage , use csh . can hack together, there obvious translation of code () { vscode_cwd="$pwd" open -n -b "com.microsoft.vscode" --args $* } into csh alias ? i think sort of works: alias code "setenv vscode_cwd ${pwd} && open -n -b "com.microsoft.vscode" --args $*" but think want way make vscode_cwd "local" alias, in bash version. you can create code script in path contents: #!/bin/sh vscode_cwd="$pwd" open -n -b "com.microsoft.vscode" --args $*

html - Javascript code only works in debugging Mode in Internet Explorer -

i've tryed execute next block of code, worked in internet explorer debugging mode open. haven't added console.log or that. problem? in google chrome , firefox works fine without opening debugging mode. working 64 bit version of internet explorer: var validation = false; var val = $('#profilepicture')[0].value; var regex = new regexp("(.*?)\.(jpg|jpeg|bmp|png|tif)$"); if (regex.test(val)) { validation = true; } else { errordialog('extension not allowed', null); $('#profilepicture').val(''); $('#profileimage').val(''); $("#sicform .bootstrap-filestyle > input").val(""); document.getelementbyid('profileimage').src = "images/sat-placeholder.png"; } var tgt = evt.target || window.event.srcelement, files = tgt.files; var uploadcontrol = document.getelemen

asp.net mvc - Display a bootstrap alert in a modal after submitting a form -

i work asp.net mvc 4 , have issue bootstrap modal. have modal form containing 4 dropdownlist (in partial view), when submit form action check in database if reference exist. i want display alert in modal if reference doesn't exist without leaving modal, please tell me if possible , how ? this part of view @using (html.beginform("afficherbobine", "home")) { <div class="modal fade" id="choisirbobine" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-body"> <div class="container-fluid"> <section class="row"> @html.partial("partialformbobine") </section> <section class=&

c++ - Searching for an int inside a file -

so supposed take ints in source3.txt , check of them occur in source.txt. if of them don't occur, i'm supposed print corresponding line source2.txt output.txt (source2.txt contains descriptions of numbers in source 3, in same order, each description 1 line). wrote code, prints last line source2.txt, furthermore wrong line. have no idea might wrong. can me? #include <bits/stdc++.h> using namespace std; int main() { ifstream source ("source.txt"); ifstream source2 ("source2.txt"); ifstream source3 ("source3.txt"); vector<int> tab(1051,0); vector<string> tab2(857,*new string); vector<int> tab3(857,0); ofstream output("output.txt"); for(int i=0;i<1050;++i) { source>>tab[i]; } for(int i=0;i<856;++i) { string a; getline(source2,a); tab2[i]=a; source3>>tab3[i]; } for(int i=0;i<856;++i) {

php - How to display custom post type as a gridview using wordpress code -

i have custom post type "events" , want display events in table of 3 columns pagination using code in wordpress. this did far displays list. $loop = new wp_query( array( 'post_type' => 'events' , 'posts_per_page' => 3) ); $count = $loop->post_count; if ( $loop->have_posts() ) : ?> <h2 style="position:relative;top:100px" align="center"> news & events</h2> <div id = "menu" style="position:relative;top:100px;left:350px"> <ul> <li class = "aa"><a class="anchor" id="all" href="#">all</a></li> <li class = "aa"><a class="anchor" id ="videos" href="#">videos</a></li> <li class = "aa"><a class="anchor" name = "links" id="links" href="#">l

PayPal error 580001 HTTP Request from iOS -

having difficulties in implementing adaptive payments in ios , unfortunately there little documentation on paypal's website or response. code: - (void)makepaymentsandbox{ nserror *error; //nsurlsessionconfiguration *configuration = [nsurlsessionconfiguration defaultsessionconfiguration]; //nsurlsession *session = [nsurlsession sessionwithconfiguration:configuration delegate:self delegatequeue:nil]; nsurl *url = [nsurl urlwithstring:@"https://svcs.sandbox.paypal.com/adaptivepayments/pay"]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:url cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:30.0]; //setting [request sethttpmethod:@"post"]; //headers [request addvalue:@"alex.rietmann-facilitator_api1.fastwebnet.it" forhttpheaderfield:@"x-paypal-security-userid

OpenCV camera calibration(compute [R|T]) with lines instead of points -

Image
i'm working on football(soccer) robot this tutorial . machine has 2 cameras while ground map has 6 points recognizable in front of goal. i'm doing: take photos , intrinsic parameters(focal length,distortions); while moving, find the points , use solvepnp [r|t]; use projectpoints real coordinate. as have tried, (in chessboard of 6*9 inner corners) 10 points worked fine, 5 bad result(haven't considered when vision bad or when ball blocks vision). i'm thinking presetting [r|t](with vision of full map),and while moving, utilize old [r|t](as initial approx.) better [r|t]. after sometime, [r|t] gets less accurate, it's unlikely i'll approx. value. another solution though, it's try using lines generate [r|t]. example, after detecting set of points of line, relate x=0 or y=0... , use them compute [r|t] generate better result. there way this? or i'm getting wrong? ideas or appreciated! i'd contribute, have questions settings:

android - can I show coming notification always on top of status abr -

can show coming notification on top of other notification . in new version lollipop default...but others previous versions .i using samsung note 2 device. in order put there have add flag layoutparams of windowmanager , after add notificationview. windowmanager.layoutparams lp = new windowmanager.layoutparams( windowmanager.layoutparams.type_system_error); mwindowmanager.addview(mheadsupnotificationview, lp);

python - Perfect font size to fit in specific width and height -

what wanted function given image width , height , text fit text image perfect font size. achieved trial-error method. here's code: # -*- coding: utf-8 -*- pil import imagefont def get_total_area(width, height): return width * height def get_font(name, size): return imagefont.truetype(font, size) def fit(width, height, font, size, text): font = get_font(font, size) text_w, text_h = font.getsize(text) text_area = get_total_area(text_w, text_h) total_area = get_total_area(width, height) if total_area>text_area: action(size) return true else: return size def action(size): print("succes!") counter = 0 text = """one way of doing pass text default font size of, 20, imagettfbbox , retrieve width it. can calculate how smaller or bigger text should fit size want calculating scale factor:""" size = 60 font = 'my-font.ttf' while true: counter += 1 ans = fit(500,