Posts

Showing posts from May, 2010

web services - Set Jackson DeserializationContext Attribute in per-request, thread-safe manner -

i'm looking able add request-scoped attribute (a jax-rs containerrequestcontext because rather use jackson convert parameters objects jax-rs's ill conceived , clunky parameterconverterproviders ) deserializationcontext can obtained within jsondeserializer . must call convertvalue() rather readvalue() (not dealing actual json) not able create objectreader in each thread unless willing serialize map json string first , read -which incredibly inefficient. i'd able accomplishes following in per request manner: objectmapper om = new objectmapper(); //in request-scoped context: om.getdeserializationcontext().setattribute("requestcontext",containerrequestcontext) map<string,object> mapofrequestparameters = ... beanofvastimportance bean = om.convertvalue(mapofrequestparameters,beanofvastimportance.class) how can achieve without massive, superfluous overhead of needing create new objectmapper each individual request thread? this can achieve

How do I embed 2 css in 1 Html? -

head section <head> <meta charset="utf-8"> <title>kaffehaus mannfredo | home</title> <link rel="shortcut icon" href="../1_pics/favicon.ico" /> <link rel="stylehseet" type="text/css" href="../2_css/general.css"> <link rel="stylesheet" type="text/css" href="../2_css/nav.css"> <link href='fonts.googleapis.com/css?family=open+sans' ; rel='stylesheet' type='text/css'> first css ul { position: fixed; top: 0; left: 0; width: 100%; list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { font-family: 'open sans', sans-serif; margin:0px; float: none; display: inline-block; } li { display: block; color: white; text-align: center; padding: 15px 17px; text-decoration: none;} li a.active { background-color: #4caf50;} li a:hover:not(.active) { background-color: #

hibernate - is it possible to get a property by its value in c# -

i have code compare values of oldstate object currentstate in fluent inhibernate, want log property has been changed , value,here new , old values waant property name. if reflect @event.entity can properties , values there way property name value. public void onpostupdate(nhibernate.event.postupdateevent @event) { var entitytoaudit = @event.entity iauditable; string path = path.combine(appdomain.currentdomain.basedirectory, "auditlog.txt"); using (streamwriter sw = file.appendtext(path)) { (int = 0; < @event.oldstate.length; i++) { if (@event.oldstate[i] != null) { if (!@event.oldstate[i].equals(@event.state[i])) { sw.writeline("the value has ben changed " + @event.oldstate[i] + " " + @event.state[i]); } } else { if (@event.state[i] != null) {

r - Pipe a data frame to a function whose argument pipes a dot -

how can 1 pipe data frame function argument pipes dot? mpg %>% rbind(., . %>% rev()) error in rep(xi, length.out = nvar) : attempt replicate object of type 'closure' another example: mpg %>% { . %>% arrange(manufacturer) } functional sequence following components: arrange(., manufacturer) use 'functions' extract individual functions. wrap dot piped in parentheses (.) : mpg %>% rbind(., (.) %>% rev()) or, lambda function: mpg %>% { (.) %>% arrange(manufacturer) }

cordova - PhoneGap 2.9.0 Loading External Scripts -

preface: i'm using coffeescript , haml , testing on android phone using phonegap build. i attempting load external script being compiled on server phonegap app. when testing page locally works when testing on actual device doesn't seem getting script. have tried loading script in index.html: %script{:type => 'text/javascript', :src => "http://192.168.5.112:3000/assets/mobile.js"} i have tried using jquery's getscript, get, , ajax calls: $.getscript('http://192.168.5.112:3000/assets/mobile.js', alert('success')) $.get 'http://192.168.5.112:3000/assets/mobile.js', (data) -> alert 'success server' + data $.ajax 'http://192.168.5.112:3000/assets/mobile.js', error: (jqxhr, textstatus, errorthrown) -> alert('localerror: ' + jqxhr + textstatus + errorthrown) success: (data, textstatus, jqxhr) -> alert('localsuccess: ' + data + textstatus + jqxhr) all of give me succ

Get non-matching data when comparing python dicts and store them -

i have 2 python dicts... i'm checking if match. how can non-matched keys , values items , store them? data1 = {'first_name': 'john', 'last_name': 'doe', 'username': 'johndoe'} data2 = {'first_name': 'john', 'last_name': 'doe', 'username': 'johohoho'} (key, value) in set(data1.items()) & set(data2.items()): print(key, value) # returns matching data. how can grab non matched? thank in advance! you can use xor non matching entries catching matched entries: >>> (key, value) in set(data1.items()) ^ set(data2.items()): ... print(key, value) ... ('username', 'johndoe') ('username', 'johohoho') note: won't work nested dictionaries

javascript - ng-click not working in dynamic html of a directive -

my problem seems relatively similar ng-click not working in dynamically created content solution posted there not working me. the entire goal have directive generate html based on variable in controller's scope. generated html have replaced ${foobar} clickable span text foobar execute function on controller's scope when clicked. i have directive: .directive('markup', function($compile) { var convertparameters = function(text) { var matches = text.match(/\${.*}/); if(!matches) { return text; } for(var i=0;i<matches.length;++i) { var match = matches[i]; var label = match.substring(2,match.length-1) text = text.split(match).join('<span ng-click="expose(\'' + label + '\')">' + label + '</span>'); } return text; } var link = function(scope, element, attrs) { var text; if (scope.markup)

Rails 4.2+: Mapping PostgreSQL JSONB nested values to form fields -

i have users table settings field of type jsonb (using postgresql 9.5). i'm trying create form on settings page update user.settings["notifications"][...] values. class user < activerecord::base end user = user.create(settings: { notifications: { post_created: true } }) user.settings["notifications"]["post_created"] # => true to map nested jsonb values form, however, have this: # views/form.html.erb <input type="check" name="user[settings][notifications][post_created]" checked="<%= current_user.settings['notifications']['post_created']" %> class settingscontroller def update current_user.settings["notifications"]["post_created"] = params["user"]["settings"]["notifications"]["post_created"] current_user.save end end is there anyway utilize power of rails form builders such can do: # not work, undefi

c# - Simple Byte Encryption Not Working -

when message decrypted, characters 1 less original. example: h g i have tried debug code printing out values , goes until trying divide 100000 , multiplying date here code used: didn't include main method here public static string encrypt(string input) { string final; string date = datetime.now.date.toshortdatestring().tostring(); var datetime = int.parse(date.replace("/", "")); list<int> semi = new list<int>(); var bytes = encoding.utf8.getbytes(input.tochararray()); (int = 0; < bytes.length; i++) { int y = bytes[i] * datetime / 100000; semi.add(y); console.writeline(y); } console.writeline(string.join("", bytes)); final = string.join(":", semi.toarray()) + ":" + date; return final; } public static string decrypt(string input) { string final;

selenium webdriver - Nightwatch.js click not reflected in UI -

i trying click element in nightwatch: client .waitforelementvisible('.tt-suggestions div:nth-child(4)', 2000) .click('.tt-suggestions div:nth-child(4)', function(clickstatus) { console.log(clickstatus); }); i check clickstatus, , returns 'success' click being fired on element. however, not reflect in ui. suggestions? i have found need add pause in order click performed in browser. therefore try in test: client .waitforelementvisible('.tt-suggestions div:nth-child(4)', 2000) .pause(1000) .click('.tt-suggestions div:nth-child(4)', function(clickstatus) { console.log(clickstatus); });

pointers - In C: How to point to different members with offset at run time? -

i want use single pointer pt , offset size_t offp update value of either mynfo.valuea or mynfo.valueb depends on run time conditions. i can set pt &mynfo , not know proper type of pt , how should calculate offp . edited: i forget mention structures used allocated @ runtime. i using khash , need distinguish whether key exists. if use pt = &pnfo->valuea; , have write similar codes twice. want determine member first , turn hash. typedef struct { uint16_t valuea; uint16_t valueb; const char * filename; } __attribute__ ((__packed__)) info_t; info_t mynfo, *pnfo; pnfo = calloc(1,sizeof(info_t)); size_t offp = &(mynfo.valueb) - &(mynfo.valuea); if (ret==1) { pt = pnfo; } else { pt = pnfo + offp; } *pt = 100; use offsetof() size_t offp; if (some condition) { offp = offsetof(info_t, valuea); } else { offp = offsetof(info_t, valueb); } *(uint16_t*)((char*)pnfo + offp) = 100; you need pointer casting because o

ios - UIscrollview delegation -

i trying pass data between 2 view controllers in uiscrollview . trying use delegation send data between viewcontroller1 , viewcontroller2 . delegate viewcontroller , while delegator viewcontroller1 , viewcontroller2 . in code posted below, when switch in viewcontroller1 toggled, makes switch in viewcontroller2 put "off" state. keep on getting fatal error: unexpectedly found nil while unwrapping optional value error when run it, have no clue causing problem. ideas why? below viewcontroller contains uiscrollview , subviews/childviews import uikit class viewcontroller: uiviewcontroller, testing { var vc1 = viewcontroller1(nibname: "viewcontroller1", bundle: nil) var vc2 = viewcontroller2(nibname: "viewcontroller2", bundle: nil) @iboutlet weak var scrollview: uiscrollview! func test1() { vc2.switch2.on = false } override func viewdidload() { super.viewdidload() self.addchildviewcontroller(vc1) self.scrollvi

java - "variable is accessed from within inner class needs to be declared final" error -

i've got error while trying use local member of 1 class in inner class inside. know declare final solve issue read java 8 should handle automaticlly, i'm using intellij java 8 , still not compile. there other way fix without declare final? thanks. i know declare final solve issue read java 8 should handle automatically. java 8 handle if variable effectively final . i can think of 2 possible explanations: maybe variable not effectively final . try explicitly declaring final . if compilation error (e.g. saying trying modify final ) variable isn't final. maybe haven't configured intellij , project java 8; e.g. set source level; see @saman's answer check have right jdk selected: java 8 doesn't compile on intellij15

android - Controlling GPS ON/OFF from the app -

i seeking advice corona experts. control gps on/off app not quite sure can achieved using corona. i have couple of queries process- after installing app , open, app prompt enabling gps (if turned off on device , sharing location permission given), right? if sharing location permission denied user can app able ask permission again , prompt enabling gps? if turn on gps app settings , again turn off, possible show popup notification message turn on gps? someone said display permission notification prompt message once , after no way show prompt message control location service. looking forward expert advice. thanks in advance! you cannot of these corona sdk. need enterprise version play permissions , settings. have code in java not corona.

Javascript regex match Twitter username, but exclude colon -

using twitter api trying link @ symbols persons account eg. @stackoverflow goes https://twitter.com/stackoverflow . this working below except when looking @ retweets have syntax rt @stackoverflow: the first regex works keeps : remove last character if : . how can match @stackoverflow pattern remove : it. (i don't want remove : whole string may have links in it) var str = 'rt @stackoverflow: great ...' str = str.replace(/@(\s*)/g, '<a target="_blank" href="https://twitter.com/$1">@$1</a>') str = str.replace(/:$/,"") //doesn't console.log(str) // returns rt <a target="_blank" href="https://twitter.com/stackoverflow:">@stackoverflow:</a> great ... instead of /@(\s*)/g use /@(\w+)/gi , because twitter usernames confined \w represents: a-z , , 0-9 , _ . stated in twitter support article : a username can contain alphanumeric characters (letters a-

ios - Cannot find/click any elements on Apple Pay view in UITest -

i've been able run applepay in uitests, once pkpaymentauthorizationviewcontroller displayed, none of elements on view locatable , attempt select elements on underlying application view result in error "..... not frontmost". has else encountered problem and/or have idea how work around it? the apple pay ui presented out of process (even though trigger uiviewcontroller subclass), don't think you'll able pick ui testing. it's presented out of process app can't modify or manipulate apple pay views.

javascript - why does forEach function gives wrong output? -

challenge using javascript language, have function arrayadditioni(arr) take array of numbers stored in arr , return //the string true if combination of numbers in array can added //up equal largest number in array, otherwise return //string false. example: if arr contains [4, 6, 23, 10, 1, 3] //output should return true because 4 + 6 + 10 + 3 = 23. array //not empty, not contain same elements, , may contain //negative numbers. // sample test cases // input:5,7,16,1,2 // output:"false" // // input:3,5,-1,8,12 // output:"true" function findlargest(array){ var largest = array[0]; array.foreach(function(num){ if(num > largest){ largest = num; } }); return largest; } function arrayadditioni(array){ var largest = findlargest(array); var index = array.indexof(largest); array.splice(index,1); array.foreach(function(num,idx){ var sum = 0;

Using JavaScript function from HTML Button doesn't work -

i'm working xdk , want add html button should call js function. js file created in project , included <script type="text/javascript" src="app.js"></script> my button code is: <form> <input id="change_button" type="button" value="change" onclick="change();"/> </form> and js function: function change() { alert("hello! alert box!!"); } for reason nothing happens when press button. maybe i'm missing something. hints how solve problem. the function should work, check path of app.js file

java - Addition of Two Numbers represented by Linked List nodes -

i'm preparing interview. question got is: 2 numbers represented linked list, each node contains single digit.the digits stored in reverse oder, such 1's digit @ head of list. write function adds 2 numbers , returns sum linked list. suggested answer adds each digits individually , keeps "carry" number. example, if first digits of 2 numbers "5" , "7". algorithm records "2" in first digit of resulting sum , keeps "1" "carry" add 10th digit of result. however, solution traverse 2 linked lists , translate them 2 integers. add numbers , translate sum new linked list. wouldn't solution more straight forward , efficient? thanks! while solution may more straightforward, don't think it's more efficient. i'm assuming "correct" algorithm this: pop first element of both lists add them (with carry if there one) , make new node using ones digit pass carry (dividing sum 10 actual thing car

orientdb rename column with sql syntax -

i trying rename column name in orientdb version 2.1.14 sql having "user" vertex like +------+------+-----+ | cc | name | cod | +------+------+-----+ | 0001 | jhon | 123 | +------+------+-----+ | 0002 | paul | 567 | +------+------+-----+ i want change to +------+------+----------+ | cc | name | tax_code | +------+------+----------+ | 0001 | jhon | 123 | +------+------+----------+ | 0002 | paul | 567 | +------+------+----------+ (the column name " cod " changes " tax_code " , contents not change) looking in http://orientdb.com/docs/2.0/orientdb.wiki/sql.html appears sql code, nothing work column names. there procedure in sql in orientdb change column names?, or @ least "sp_rename" equivalent command? try this: alter property <class-name>.cod name tax_code hope helps regards.

android - why does my shouldOverrideLoading method never get called? -

i trying show toast on shouldoverrideloading , however, never gets called. code huge stripped down way smaller code still can't find mistake making. here code: public class mainactivity extends activity { private webview webview; private edittext urledittext; private progressbar progress; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); urledittext = (edittext) findviewbyid(r.id.urlfield); webview = (webview) findviewbyid(r.id.webview); webview.setwebchromeclient(new mywebviewclient()); cookiemanager.getinstance().setacceptcookie(true);// enable cookies webview.getsettings().setjavascriptenabled(true);// enable java script webview.setwebviewclient(new viewclient()); webview.getsettings().setpluginstate(pluginstate.on);// enable flash webview.getsettings().setloadsimagesautomatically(true); webview.setwebviewclient(new webviewclient() {// *

javascript - Jquery Validate Plugin is applying rules only including jquery.validate.min file -

i getting validation errors in forms , have not applied $('form').validate() method form. i understand after document loaded, have apply validate() method on form want apply validation functionality, in case, including plugin files, , validations been applied on forms. can me solve this? regards! (and sorry english) please more details issue.... version using , provide dummy code better understanding. have on below point may you: must have added attributes form inputs "required",'numbers'...etc

java - Trying to understand sage number system for BigInteger -

i have following sage code runs instantly (less second) , trying convert java (using java's built-in biginteger library). not successful. in short, initialized n biginteger , delta double , in order calculate power (biginteger ^ double) converted n bigdecimal (i.e. new bigdecimal(biginteger)) , then: i used this approach slow (extremely slow). i used this library lost precision. i used this library got overflow exception. n = 1626059520135677787668710205539285623036879947872543722541897078840409275154096682761488367506649238368814728874122323417444837889279456778955123583508702762653691940632014245567708474349914115582189410261057320734319919432700517283398948695843498239355632620648595422315180579862129496592606972881678098568304303037148584774661614655461200106655417554575376038898758459309171670178039871191088667992561283895585873610222971904229168245648043790842684973455685691789162873054372944624597489173537199158850542915263904572184021345187548703849

visual studio - Why following function cant be called with given argument list? -

Image
void conver(double&, int&); private: system::void cb1_selectedindexchanged(system::object^ sender, system::eventargs^ e) { a=1; if ((a==1)&&(b2==1)) {if(cb1->text=="celsius") { input=system::convert::todouble(cel->text); if (cb2->text=="celsius") { choice=1; conver(input,choice); } if(cb2->text=="fahrenheit") } } } i getting following error: error: function "project3::myform::conver" cannot called given argument list. argument types are: (double, int) i don't understand means. can't pass arguments reference in visual c++? you passing actual number - not variable - reference. cannot pass in numbers reference because numbers not have addresses assigned in registry (memory). have use

android - Firebase ANR - Not even using firebase -

with recent updates gms, new anr has been introduced. if exit app, , return, that's when anr initialized. thread trace seems point firebase, never started using firebase. guess must part of new gms package? 06-11 00:34:00.143: e/activitymanager(1487): anr in com.myapp 06-11 00:34:00.143: e/activitymanager(1487): pid: 19700 06-11 00:34:00.143: e/activitymanager(1487): reason: broadcast of intent { act=com.google.firebase.instance_id_event flg=0x14 cmp=com.myapp/com.google.firebase.iid.firebaseinstanceidinternalreceiver (has extras) } here dependencies: dependencies { compile filetree(dir: 'libs', include: ['*.jar']) testcompile 'junit:junit:4.12' compile 'com.android.support:design:23.4.0' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:recyclerview-v7:23.4.0' compile 'com.google.code.gson:gson:2.4' compile 'com.mindscapehq.android:raygun4

c - Getting error undefined reference -

diceroll.c /*diceroll.c -- dice roll simulation */ #include "diceroll.h" #include <stdio.h> #include <stdlib.h> //for library function rand() int roll_count = 0; //external linkage static int rollem(int sides) /*private file */ { int roll; roll = rand() % sides + 1; ++roll_count; return roll; } int roll_n_dice(int dice, int sides){ int d; int total = 0; if(sides < 2){ printf("need @ least 2 sides.\n"); return -2; } if(dice < 1){ printf("need @ least 1 dice.\n"); return -1; } for(d = 0; d < dice; d++){ total += rollem(sides); } return total; } header file //diceroll.h extern int roll_count; extern int roll_n_dice(int dice, int sides); the main program /*manydice.c -- multiple dice rolls */ /*compile diceroll.c */ #include <stdio.h> #include

swing - how to resolve ,"AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 -

public class queryresult extends javax.swing.jframe { int pos=0; string companyvalue; string colorvalue; string reviewvalue; public queryresult() { companyvalue=newjframe1.query_company; colorvalue=newjframe1.query_color; reviewvalue=newjframe1.query_review; system.out.println("vaule coming "+companyvalue); system.out.println("value "+colorvalue); system.out.println("value "+reviewvalue); initcomponents(); showitem(pos); } public void getconncetion() { connection conshow=null; string userquery=""; resultset showdata=null; try { class.forname("oracle.jdbc.driver.oracledriver"); conshow=drivermanager.getconnection("jdbc:oracle:thin:@localhost:1521:xe","system","ro

What is the reason for different value after reg add from within a C# application and query the value from within a cmd window? -

i have program coded in c# opens cmd console , adds/modifies registry value. after console outputs task completed, test reg query if registry value changed. there no problem. value 0x1 expected me. but when query registry outside current cmd window cmd executed me admin, value 0x0 on reg query . how possible? here c# code: string command = @"/k reg add hkey_local_machine\software\microsoft\windows\currentversion\appmodelunlock /t reg_dword /f /v allowdevelopmentwithoutdevlicense /d 1"; process proc = process.start("cmd.exe", command); query inside executed cmd program: reg query hkey_local_machine\software\microsoft\windows\currentversion\appmodelunlock hkey_local_machine\software\microsoft\windows\currentversion\appmodelunlock allowdevelopmentwithoutdevlicense reg_dword 0x1 from outside: reg query hkey_local_machine\software\microsoft\windows\currentversion\appmodelunlock hkey_local_machine\software\microsoft\windows\cu

mysql - Express query for SQL -

i dynamically trying pass name of table sql query in part of express code below background information:: what passing (key,value) string name of table in sql database why doing dynamically select table based on dynamic client request problem facing:: clearly not sunig sql query correctly how solve this [expresscode] app.get('/restaurantdesc/:key',function(request,response,next){ var keyname=request.params.key; var name_of_restaurants, restauranttimings; async.series( [ // first table contents function ( callback ) { connection.query('select * keyname', function(err, rows, fields) { console.log('connection result error '+err); name_of_restaurants = rows; callback(); }); }, // second table contents function ( callback ) { connection.query('select * restauranttiming

c# - Visual studio 2015 Properties panel -

i'm reading tutorial c# wpf projects , @ point tells me put tab control on project , set properties this: grid.rowspan="2" canvas.left="10" canvas.top="2" width="408" height="208" grid.row="1" my novice problem cannot find grid.rowspan property on properties panel in order change it. are properties available xaml editor? is there way find on properties panel also? you tabcontrol goes inside page's grid, grid.rowspan property inherited that. additionally, may have defined rows in grid in way similar this: <grid> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="auto" /> <rowdefinition height="*" /> so, basically, should work. rowspan written capital "r" , "s" btw, htat it?

php - modify string if specific regex matches -

working in php, have following mock string. "width 40cm height 70cm" if string not contain colon , have space followed number, want add colon before space. the end result i'm looking is: "width: 40cm height: 70cm" i tried bunch of ways regex , splitting string @ match add colon, removing match string. here attempt. if(strpos($s, ':') === false) { $array = preg_split('/([0-9])/', $s, -1, preg_split_no_empty); $array[0] = trim($array[0]) . ':'; $s = implode('', $array); } i think work (\w+)(?=\s+\d) <-------> lookahead match space followed digits regex demo php code $re = "/(\\w+)(?=\\s+\\d)/m"; $str = "width 40cm height 70cm\nwidth: 40cm height 70cm"; $result = preg_replace($re, "$1:", $str); print_r($result); ideone demo

sql - How to create a sequence with start with value that is a query -

i saw same question here create sequence start query not work. has 12 votes i'm not sure why it's not working me. this have: declare l_new_seq integer; begin select max(expense_detailid) + 1 l_new_seq expense_detail; execute immediate 'create sequence expense_detail_seq start ' || l_new_seq || ' increment 1'; end; / and error get: ora-06550: line 3, column 17: pls-00103: encountered symbol "create sequence expense_detail_seq start " when expecting 1 of following: := . ( @ % ; symbol ":=" substituted "create sequence expense_detail_seq start " continue. (dbd error: error possibly near <*> indicator @ char 27 in ' begin immediate <*>'create sequence expense_detail_seq start ' || l_new_seq || ' increment 1'; end; ') ora-00900: invalid sql statement any ideas? thanks! make text in single line. or @ least each lit

go - Unable to use cgo CFLAGS -

i have manually cloned go directory of tensorflow(a library working on ) in /home/arafat/go/src/github.com/tensorflow/tensorflow/tensorflow/contrib/go can take here . have made changes lib.go // #cgo ldflags: -ltensorflow // #cgo cflags: -i /home/arafat/go/src/github.com/tensorflow/tensorflow // #cgo cxxflags: -i /home/arafat/go/src/github.com/tensorflow/tensorflow -std=c++11 but getting error # github.com/tensorflow/tensorflow/tensorflow/contrib/go in file included go/src/github.com/tensorflow/tensorflow/tensorflow/contrib/go/tf_session_helper.cc:20:0: go/src/github.com/tensorflow/tensorflow/tensorflow/contrib/go/tf_session_helper.h:22:49: fatal error: tensorflow/core/public/tensor_c_api.h: no such file or directory #include "tensorflow/core/public/tensor_c_api.h" ^ compilation terminated. on doing go github.com/tensorflow/tensorflow/tensorflow/contrib/go i not able understand why not working. lik

listener - Can't use Spring ApplicationListener -

my project spring-boot(1.3.5 release),web project(spring-web 4.3.0 realese). want use "applicationlistener",when spring loaded,to something.but code doesn't work.there's code: package hello; import org.springframework.context.applicationlistener; import org.springframework.context.event.contextrefreshedevent; public class bootlistener implements applicationlistener{ @override public void onapplicationevent(contextrefreshedevent event) { system.out.println("spring启动监听器"); system.out.println(event.gettimestamp()); } } package hello; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootapplication; @springbootapplication public class application { public static void main(string[] args) { springapplication.run(application.class, args); } } http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 <groupid>org.springframework</groupid> <artifactid&

android - get path of video file selected from gallery getting NULL. How to get path of video file? -

get path of video file selected gallery getting null . how path of video file ? get uri in activity result give null. converting uri string getting null . intent intent; string selectedvideo1path, selectedvideo2path; edittext e1,e2; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.videos_activity); button button1 = (button) findviewbyid(r.id.video1_btn); button button2 = (button) findviewbyid(r.id.video2_btn); button1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { selectvideofromgallery(); startactivityforresult(intent, 101); } }); button2.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { selectvideofromgallery(); startactivityforresult(intent, 102); } }); } @override protected v

html - bootstrap embed-responsive does not work with css column count? -

Image
bootstrap embed-responsive not work css column-count. example: /** divide target element <number> columns */ .columns { -webkit-column-count: 4; -webkit-column-gap: 10px; /*-webkit-column-fill: auto;*/ -moz-column-count: 4; -moz-column-gap: 10px; /*-moz-column-fill: auto;*/ column-count: 4; column-gap: 15px; /*column-fill: auto;*/ } .video-box { border: 1px solid red; } <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <div class="container"> <div class=

mysql - Mysqli num rows shows 0 result -

i'm having 2 queries fetch return max voted , max voted down, first query returns 0 result , second return results indeed have quad checked results in database first return 0. have spent time debugging didn't come result. maybe 1 eye can't find wanted share eyes can find maybe or ? :) . my first code of top votes query --------> returns 0 select m.id ,cm.id ,cm.userid,cm.replyto,m.username ,cm.message,cm.edited,cm.date,cm.voteup,cm.votedown chat_messages cm inner join members m on m.id =cm.userid cm.voteup - cm.votedown = (select max(voteup - votedown ) chat_messages deleted != 1 , voteup - votedown >= 5 ) , cm.room_id = 1 order cm.votedown asc,cm.voteup desc,cm.id limit 1 --------> gives me 0 and second top down votes query--------> works; i'm getting result select m.id ,cm.id ,cm.userid,cm.replyto,m.username ,cm.m

php - Codeigniter vs MVC -

"codeigniter has loose approach mvc" mean other frame works have approach mvc? codeigniter model view controller framework. mvc, itself, object oriented design pattern . the mvc pattern fits web applications well. purpose of framework codeigniter handle mechanics of mvc you, can spend time working on functionality of actual application. you can continue use whatever oop patterns using before , integrate them codeigniter framework. however, using framework add constraints , limitations overall design. you'll need use codeigniter's models, views, , controllers example. codeigniter provides many utilities , features other aspects of developing application, however, aren't forced use them. this broad question, broad answer :)

oracle11g - How to debug PLSQL procedure being executed by a parallel task in PLSQL developer -

i have plsql procedure using dbms_parallel_execute create new task, create chunks row_id , execute task. procedure test begin dbms_parallel_execute.create_task('newtask'); dbms_parallel_execute.create_chunks_by_rowid('newtask','peeush','newtable',true,1000); dbms_parallel_execute.run_task(task_name => 'newtask', sql_stmt => 'begin peeush.test2(:start_id,:end_id); end;', language_flag => dbms_sql.native, parallel_level => 4); end; now want debug plsql developer, execution reaches @ run_task. comes out. there way step test2 procedure in plsql developer. i think you'll need remote debugger, dbms_debug_jdwp . unfortunately pl/sql developer doesn't support , you'll need install tool does, such sql developer .

matplotlib - To find the value on X axis corresponding to an arbitrary value of Y that doesn't contain in the list used to plot the data in python -

Image
i have set of values redshift , have corresponding set of values deceleration parameter of universe. plot given: now need value of z accurately graph q=0. have tried many commands , lead kind of errors. since not in python can't try how rectify those. when tried command: z1 = interp1d(z,q,0) the result was: scipy.interpolate.interpolate.interp1d object @ 0x051899f0 how can solve this? my code: while z0<zf:' ' z.append(z0) a.append(1/(1+z0)) term=((1+(omega/(b-1)))*a[k]**(3*(b-1))) h.append(((term-(omega/(b-1)))*h02)**0.5) q.append(-1-((h0*term*3*(b-1)*(term-(omega/(b-1)))-0.5)/(2*h[k]))) print '%.2f \t%.4f \t%.4f \t%.15f'%(z[k],a[k],h[k],q[k]) k=k+1 z0=z0+h your code had issues. have python 3 here if have problem understanding ask (changed bit print , input function parts). you did not define h02 stated equal h0 . correct if wrong. here corrected code (see comments important stuff): fro

java - How to port forawrd on AWS -

i have hosted simple udpserver program on aws ubuntu 14.04, it's working correctly their, when tried accessing system, not able connect it, surely is, aws firewall, how can make udp traffic pass through it! , port of udp server 2020. any appreciated! thanks. i looking possible workaround issue, it's quite easy irrespective of platform language using develop socket program on aws ec2, using node.js nginx in case, should work supporting platforms. configure security group in aws console, open ec2 tab. select relevant region , click on security group. you should have default security group if have launched elastic beanstalk instance in region app. click on actions button @ top, , select edit inbound rules. here in type column select udp, or can set custom udp rule listen @ socket port. and there enter port of udp server 2020. , that's it! note: if not working, check "events" tab in beanstalk application / environments , find out went wr

ruby on rails - The bucket you are attempting to access must be addressed using the specified endpoint -

i'm using paperclip 5.0.0.beta2 in latest rails (4.2.6) project. application hosted on heroku. can upload image , seems stored in bucket on amazon s3. in browser image appears have broken url, although it's point bucket on amazon s3, url is: http://s3.amazonaws.com/gigbnb/profiles/profile_pics/000/000/002/small/anthony_candaele-300x300.jpg?1464956858 when enter url in browser, xml page error message: the bucket attempting access must addressed using specified endpoint. please send future requests endpoint. it looks there issue s3 endpoint. however set region (eu-west-1) in configuration file: config/environments/production.rb config.paperclip_defaults = { storage: :s3, s3_region: env.fetch('aws_region'), s3_credentials: { bucket: env.fetch('s3_bucket_name'), access_key_id: env.fetch('aws_access_key_id'), secret_access_key: env.fetch('aws_secret_access_key'), } } my github repository at: https:/

python - Cleaning files with multiple duplicates -

i had copy in emergency database on website. i scraped using functions made in python using admin codes. database formated : name: phone number: has played game: everything copied in .txt file sometimes, find errors in file like: name: name: name: bob how can clean mess using shell command or python keeping same order (i want still name, phone number, etc) ? say have in db.txt phone number: phone number: phone number: phone number: 0118521358 name: name: name: name: bob has played game: name: name: name: name: bob you can try little script this import re #create new file called new_file new_file=open("new_file",'w') #open database file discrepancies file_with_error=open('db.txt','r') #make list of columns in db db_header=['name:','phone number:'] #iterate through each line in database file , find matches replace line in file_with_error: col_name in db_header: line=re.sub("(%s[ ]*)+&qu

regex - Add to the end of a line missing a pattern -

i have long, not maintained bash script on centos, many log lines using echo, , of third of them tee-ing log file. modify rest of echo lines tee log file. here example myscript.sh: command1 echo "hi1" echo "hi2" | tee -a my.log echo "hi3 tee" command2 after running on file, contents changed to: command1 echo "hi1" | tee -a my.log echo "hi2" | tee -a my.log echo "hi3 tee" | tee -a my.log command2 i thinking need use sed or awk regular expression, logic is, "if line contains ' echo ', followed not ' | tee ', append ' | tee -a my.log ' @ end of line". after lot of searching, best i've come far: sed --in-place=_backup '/^.*echo\(?!\| tee$\)*/ s/$/ \| tee -a my.log/' myscript.sh but appends | tee -a my.log end of each line containing echo . does have ideas? this should trick (although feel bunch of corner cases coming) : $ awk '/^echo/&&!/t

PHP MYSQL ranking gives first rank as a zero -

i presently working on php application ranks set of result mysql , displays them on web page. make 3 mysqli queries , display result in rank. seems fine @ times (without regular pattern), result displayed shows 0 first rank instead of 1, shows 1 though. i have tried debugging code past month there no headways, have had rewrite code performs query on different occasions 0 0 problem still persists. below code: this first section: $sql0 = "set @rank = 0, @prev_val3 = null;"; $pull_report_details5 = "select rank, score, student_number, subject_name, gender ( select @rank := if(@prev_val3=score,@rank,@rank+1) rank, @prev_val3 := score score, student_number, subject_name, gender uploaded_results `subject_name` = '$subject_name' order score desc ) result"; mysqli_query($dbc, $sql0)or mysql_error(); $push_pull_report_details5 = mysqli_query($dbc, $pull_report_details5)or die("error pu

java - Nullpointerexception when trying to send data from activity to class -

i need guys. i'm making quiz i'm stuck. first of got activity can choose between categories: package com.laurenswuytsjordipapen.cultural.pursuit; import android.app.activity; import android.content.intent; import android.content.sharedpreferences; import android.os.bundle; import android.preference.preferencemanager; import android.view.view; import android.widget.button; import com.laurenswuytsjordipapen.cultural.pursuit.library.userfunctions; public class dashboardactivity extends activity { userfunctions userfunctions; button btnlogout; button btneuropa; button btnamerika; button btnafrika; button btnazie; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); /** * dashboard screen application * */ // check login status in database userfunctions = new userfunctions(); if(userfunctions.isuserloggedin(getapplicationcontext())){