Posts

Featured post

php - Is there a way to specify only some optional function args? -

i have function public function test($arg1, $arg2 = "a", $arg3 = "b") is there way call specifying $arg1 , $arg3 leaving $arg2 default value? function test($arg1, $arg2 = "a", $arg3 = "b") { if (is_null($arg2)) $arg2 = "a"; return $arg1.' '.$arg2.' '.$arg3; } echo test(1, null, 3); output: 1 3 will point out in javascript quite common: function test (input, callback) { $.post( "example.com/endpoint", input, function(err, data) { if (error || response.statuscode !== 200) { callback(true, response) } callback(null, data) }) } test({ 'id': 1, 'name': 'mary' }, function (err, data) { if (err) { console.log.error('error!!') console.log(data) } console.log.info(data) })

java - How to log everything in 'when' part of Drools rule? -

i have log responsible fire rule in drools objects, conditions etc. i able objects using agendaeventlistener , writing below code in beforeactivationfired method of it. @override public void beforeactivationfired(beforeactivationfiredevent event){ event.getactivation().getobjects(); } but how conditions , methods called on object? have object used global variable used validate values against values in cache i.e. in when part of rules different methods on global object(have hundreds of methods in it) called. now want have information on methods called can log information before hand because after execution values in cache might change. for example - if in when part below condition there wish know condition value of both sides in condition i.e. value of $val $cache.getcurrenttimestamp()(please note method called on cache not known beforehand). $val : timestamp, $val == $cache.getcurrenttimestamp() how can achieve task?

utf 8 - Mystery UTF-8-like encoding -

i've been given file supposedly in utf-8, there weird encodings of non-english characters. example, in mystery encoding, hangul string 한국경북영덕군강구면 is encoded as: 0xed959c 0xeab5ad 0xeab2bd 0xebb63f 0xec983f 0xeb3f95 0xeab5b0 0xeab095 0xeab5ac 0xeba9b4 (differences in bold) rather standard utf-8: 0xed959c 0xeab5ad 0xeab2bd 0xebb681 0xec9881 0xeb8d95 0xeab5b0 0xeab095 0xeab5ac 0xeba9b4" i'm seeing same phenomena cyrillic , chinese characters--some characters have same encoding utf-8, different. garbled characters have same byte width non garbled ones , i've verified aren't part of extension set. also, i've verified not java "modified utf-8". any other ideas may be? btw: don't have access code or people wrote file. also, i'm on mac 10.11.6 in case has it. your example string consists of utf-8, byte values (namely x81 , x8d) replaced ascii question mark ? (x3f). plausible explanation example

go - Twitter oauth golang getting Error "code":32,"message":"Could not authenticate you." -

i trying implement signing in twitter account in golang. first step in trying request token. reference used mrjones's code available @ below link. https://github.com/mrjones/oauth/blob/master/examples/twitterserver/twitterserver.go i getting following error. please let me know going wrong: {"errors":[{"code":32,"message":"could not authenticate you."}]} var twitterconf = &twitterconfig{ clientid: " consumer key", clientsecret: "my consumer key secret", redirecturl: "http://localhost:8080/oauth/twitteroauth2callback", endpoint: serviceprovider{ requesttokenurl: "https://api.twitter.com/oauth/request_token", authorizetokenurl: "https://api.twitter.com/oauth/authorize", accesstokenurl: "https://api.twitter.com/oauth2/token", }, } func handletwitterlogin(res http.responsewriter, req *http.request, _ httprouter.para

android - Can't build recovery image with AOSP 4.2.2 -

i trying build recovery.img aosp 4.2.2 following commands: cd myandroidsrc source build/envsetup.sh lunch make recoveryimage -j8 but keep running following error: find: `src': no such file or directory ... lot of "product_copy_files /frameworkds/base/data/.. .ogg ignored" messages ... cp -f /boot.img /device/myvendor/mydevice/boot/ cp: cannot stat `/boot.img': no such file or directory make: *** [out/target/product/mydevice/boot.img] error 1 make: *** deleting file `out/target/product/mydevice/boot.img' make: *** waiting unfinished jobs.... i tried build boot image with: make bootimage but results in same error @ make recoveryimage call. missing make call here or file structure wrong ? are using prebuilt boot.img if yes check path properly. cp -f /boot.img /device/myvendor/mydevice/boot/ can see above root of device tree should have boot.img being copied.

jquery datatables custom ajax client -

i have custom javascript client works remote api using ajax. suppose myapiclient below: var myapiclient = function() { this.invoke = function (config, callback) { // ... } } how can configure jquery datatables can use myapiclient rather built-in ajax working jquery datatables provides internally? that is, suppose loading remote data, need call client way: var client = new myapiclient(); client.invoke({ url: '/api/app/v1/some-entity/all', function(result, err) { // ... } }); thank already use ajax option define function retrieve data through own ajax call. as function, making ajax call left allowing complete control of ajax request. indeed, if desired, method other ajax used obtain required data, such web storage or firebase database. when data has been obtained data source, second parameter ( callback here) should called single parameter passed in - data use draw table. for example: $('#example').datatable( {

java - Spring boot with Spring Security and custom database -

sorry in advance bad english.. since have changed database configuration don't succeed log me on application. using spring security. before making changes worked. i have 2 entities : user.java userrole.java user.java package betizy.models; //imports @entity @table(name = "use_user") public class user { @id @generatedvalue(strategy = generationtype.auto) @column(name="use_id") private long id; @notnull @column(name = "use_username") private string username; @notnull @column(name = "use_password") private string password; @notnull @column(name = "use_email") private string email; //getters , setters } userrole.java package betizy.models; //imports @entity @table(name = "usr_user_role") public class userrole { @id @generatedvalue(strategy = generationtype.auto) @column(name="usr_id") private long id; @manytoone @joincolumn(name = "usr_use_id") private user user; @notnul