Posts

Showing posts from August, 2014

xml - Android - Calculator support all screen sizes -

i'm beginner on android app developing , have problem cannot find solution. i'm working app on nexus 5 , works perfect, no empty spaces between layouts, when switch nexus 4, happens ( using colors separate layouts) : https://scontent.fath3-1.fna.fbcdn.net/v/t34.0-12/20403684_1379424475444386_454511879_n.jpg?oh=440d7b9ab5670c8cad87133475ec0cb6&oe=5979cded if switch pixel xl : https://scontent.fath3-1.fna.fbcdn.net/v/t34.0-12/20403737_1379426118777555_859609190_n.jpg?oh=61ccd01da7a4470491fb4125da8db43c&oe=597996e4 can doesn't have empty spaces on right?(below there xml code posted in case need it). <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:orientation="vertical" android:weightsum="1"&

vb.net - textbox matching pattern from database table -

i have name textbox , want find names included in typed text in database table patient details name column. know how use operator if know letters want search start/end etc. time want textbox. think issue quotations; tried play around didn't work! from x in patientdetails ( x.patient_name '%" textbox1.text "%' ) for example: if patient name in database is: john matt and user typed matt, above record john matt should returned. p.s tried looking in google discuss characters not entered text box thank all. something c# var query = (from x in patientdetails x.patient_name.contains(textbox1.text) select x).tolist(); vb.net - converted using codeconverter dim query = (from x in patientdetails x.patient_name.contains(textbox1.text)x).tolist()

python - django minimize frequent database load -

i have question generalized , applied other problems, , explore possibilities i've got in django. let's have classical ecommerce scenario. it's relationships , basic field definitions class basket: lines (manytomanyfield basketline model) class basketline: product_option (foreignkey productoption model) quantity (integerfield) class productoption: option_name (charfield) product (foreignkey product model) price (decimalfield) class product: name (charfield) in addition have basket view accepts basket line modifications (like increment / decrement quantities, delete lines). in view i've noticed pattern in each time try perform modifications each time 1) query user basket 2) target line modified (using basket.lines.filter) 3) update target line modified (line.save()) with individual queries (using django orm). each operation may end retrieving productoption entry check available quantities, , go deep retrieve product entry handle prices.

theano - Error during NER Tagger compilation -

i new python, conducting ms research in deep learning. trying run ner tagger provided https://github.com/glample/tagger in anaconda prompt , cmd got following error on windows 7 32 bit-python 2.7 numpy , theano installed. sorry pasting such long error unable fix this. 00878 { 00879 // save references outputs prior updating storage containers 00880 assert (self->n_output_vars >= self->n_updates); 00881 py_decref(rval); 00882 rval = pylist_new(self->n_output_vars); 00883 (int = 0; < (self->n_output_vars); ++i) 00884 { 00885 py_ssize_t src = self->output_vars[i]; 00886 pyobject * item = pylist_getitem(self->var_value_cells[src ], 0); 00887 if ((output_subset == null || output_subset[i]) && 00888 self->var_computed[src] != 1) 00889 { 00890 err = 1; 00891 pyerr_format(pyexc_assertionerror, 00892 "the compute map of output %d should cont ain " 00893 "1 @ end of execution, not %d.", 00894 i, self->var_computed[src]); 00895 bre

regex - regexp: how to remove the beginning of the path -

i have regular expression parse gcc compilation output: ^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$ the first sub expression - ^(..[^:]*) mark file error occurs. for example, input: main.c:1156:13: error: invalid storage class it mark main.c and input: folder/main.c:1156:13: error: invalid storage class it mark folder/main.c how can change first sub expression mark file name without full path? i suggest replacing (..[^:]*) (?:[^\r\n:]*/)?([^:\r\n]*) : ^(?:[^\r\n:]*/)?([^:\r\n]*):([0-9]+):?([0-9]+)?:? (.*)$ ^^^^^^^^^^^^^^^^^^^^^^^^^^ see regex demo the change part matches: (?:[^\r\n:]*/)? - 1 or 0 occurrences of: [^\r\n:]* - 0 or more chars other : , cr , lf , then / - / char ([^:\r\n]*) - group 1: 0 or more chars other : , cr , lf

php - Laravel cannot connect to dockerise database -

i created 3 containers (php-nginx-mysql) support default laravel project located on host machine. when try connect db laravel error: route::get('/', function () { dd(app\user::all()); return view('welcome'); }); sqlstate[hy000] [2002] php_network_getaddresses: getaddrinfo failed: name or service not known (sql: select * users ) here .env in laravel-5.3.16 db_connection=mysql db_host=127.0.0.1 db_port=33061 db_database=homestead db_username=homestead db_password=secret and ansible-playbook: --- - hosts: localhost environment: pythonpath: /usr/local/lib/python2.7/site-packages/ tasks: - name: currernt location command: pwd register: my_way - set_fact: host_dir="{{my_way.stdout}}" - name: create image nginx docker_image: path: /home/demaunt/jun/dock_click/engie dockerfile: engie.dockerfile name: engie_image - name: create image php docker_image: path: /home/demaunt/jun/do

c# - Partial view not found after editing while debugging -

i have partial view on page, included with @html.partial("~/views/report/_locationfilter.cshtml", "dashboardoverview") when start debugging using visual studio, loads fine, no errors. however, if edit partial in ide (remove letter in string, example) , reload page, following error: the partial view '~/views/report/_locationfilter.cshtml' not found or no view engine supports searched locations. following locations searched: ~/views/report/_locationfilter.cshtml what expected happen either edge load unedited page (if editing not allowed while running), or load edited page. is there way edit partials on fly while debugging?

python - Django how to get in model the value from another model -

how in django models class value of blogpagegalleryimage image or foreign key or parental key? class blogpage(page): date = models.datefield("Дата публикации" , default=datetime.date.today ) body = richtextfield(blank=true) name = models.charfield(max_length=80, default='Лучший') class blogpagegalleryimage(orderable): page = parentalkey(blogpage, related_name='gallery_images') image = models.foreignkey('wagtailimages.image', on_delete=models.cascade, related_name='+') caption = models.charfield(blank=true, max_length=250) panels = [ imagechooserpanel('image'), fieldpanel('caption'), ] class another(blogpage): page = parentalkey(blogpage, related_name='instagram_post') image = blogpagegalleryimage.objects.get(blogpagegalleryimage.) caption = models.charfield(blank=true, max_length=250) panels = [ imagechooserpanel('image'),

c# - Automapper map recursive menu tree -

this question has answer here: how ignore property of property in automapper mapping? 2 answers i followed instructions on https://www.mikesdotnetting.com/article/255/entity-framework-recipe-hierarchical-data-management now i'm trying map entities dtos failing. i saw many issues releated none of them has "clean" way of mapping. started this... createmap<menuitem, dto.menuitem>() .formember(d => d.children, opt => opt.mapfrom(src => src)) .formember(d => d.parent, opt => opt.mapfrom(src => src.parent)) .formember(d => d.menutext, opt => opt.mapfrom(src => src.menutext)) .formember(d => d.linkurl, opt => opt.mapfrom(src => src.linkurl)) .formember(d => d.menuorder, opt => opt.mapfrom(src => src.menuorder)) .formember(d => d.parentmenuitemid, opt => opt.mapfrom(src =&g

java - Sonarqube No language plugin error when upgraded from 6.0 to 6.4 -

i upgraded sonarqube 6.0 6.4 on jenkins sonar analysis working fine 6.0 after upgrade got error saying: no quality profiles have been found, don't have language plugin installed what's going wrong here? notice when sonarqube installed, bundled plugins automatically installed, see whcih plugins installed automatically , maybe need upgraded. there's upgrade instructions, when upgrading need install plugins use see plugin versions sonarqube plugin jenkins dependencies: maven-plugin (version:2.14, optional) workflow-cps (version:2.25, optional) configurationslicing (version:1.40, optional) jquery (version:1.11.2-0)

java - Data received from Activity bundle is not being displayed on BarChart in Fragment -

i making app i'm making api call data through volley , set parcelable arraylist , send parcelable arraylist through bundle fragment contains barchart used mpchart library. problem : data not populated in barchart. static data populating in graph not dynamic data (parcelable arraylist) parse so, i'm wondering if have somehow notify adapter or data set being changed. don't know i'm going wrong. appreciated have been stuck since yesterday. i tried refresh data in viewpager fragment main activity public class mainactivity extends appcompatactivity implements viewpager.onpagechangelistener { radiogroup reports_criteria; edittext sdate, edate; textview reportsdate; string url = "https://xyxyxyx.php/api/performance_api/graphchart"; string db_name = "xxxxxx", user_id = "xxxxx", from_date = "xxxxx", to_date = "xxxx", comp_fk = "xxxxx"; requestqueue queue; public arraylist&

java - Convert Android.Widget.Button to JSON -

i making app have save dynamically created android.widget.button-objects , attributes, id, when app closed , opened again. these buttons saved in arraylist. my idea convert button-objects json , save them in sharedpreference. my problem cant convert buttons json, using following code this, if found on stackoverflow: (for tryouts using new button-object) button btn = new button(this); gson gson = new gson(); string json = gson.tojson(btn); its working string-object or integer-object not button-object. can me? if create buttons dynamically means set color, text, ... them. when want save them need know how many buttons had , custom attributes you've set each of them. so can that: manage 2 lists, 1 buttons , 1 custom attributes. make easier can use custom buttonbuilder manage attributes. each time want new button, create new buttonbuilder, set attributes, generate button , store both builder , button in 2 separated lists. can store list of builders in shar

swift - What Does The relative(to:) Function Actually Do? -

this swift standard library documentation : relative(to:) returns range of indices within given collection described range expression. here method signature: func relative<c>(to collection: c) -> range<self.bound> c : _indexable, self.bound == c.index along explanation: parameters collection the collection evaluate range expression in relation to. return value a range suitable slicing collection. returned range not guaranteed inside bounds of collection. callers should apply same preconditions return value range provided directly user. finally, here test code: let continuouscollection = array(0..<10) var range = 0..<5 print(range.relative(to: continuouscollection)) //0..<5 range = 5..<15 print(range.relative(to: continuouscollection)) //5..<15 range = 11..<15 print(range.relative(to: continuouscollection)) //11..<15 let disparatecollection = [1, 4, 6, 7, 10, 12, 13, 16, 18, 19, 22] range = 0..&l

android get json response -

hey guys new android networking concepts.i want send username,password,imei number , location php server android app.i done sending part.now question how receive response.i want status (1 or 0) according want move next page.so know how welcome. private static final string register_url="http://vpc70.com/app/login.php"; username = edittextusername.gettext().tostring().tolowercase(); userpassword=edittextpassword.gettext().tostring().tolowercase(); loc="11.295756,77.001890"; imeino = "12312312456"; register(username, userpassword, imeino, loc); private void register(final string username, final string userpassword, string imeino, string loc) { string urlsuffix = "? username="+username+"&userpassword="+userpassword+"&imeino="+imeino +"&location="+loc; class registeruser extends asynctask<string,string , string>{ progre

akka.net - Finding a previously persisted Akka actor with an indirect reference -

there quite few places in system building in there multiple ways reach same actor. instance, if have persistent car actor, use vin or registration plate. as need single "true name" use actor name/persistence id when recreating actor, these "lookups/references" actors, named after key, persisting id of actor reference. does seem right way it? seems lot of actors aren't actors, proxies. edited update answer. it sounds have repository contains collection of cars, , each car can have vin or reg number (or serial number, or chassis number... things uniquely identify car). id | vin | reg car1 | abc | 123 car2 | def | 456 we have persistent caractor encapsulates state , logic car. public class caractor : persistentreceiveactor { string _id; public override string persistenceid { { return _id; } } public caractor(string id) { _id = id; } public static props props(string id) { return

python - Is this correct to import module only in function, not in a start of file? -

so, have itchy question import modulename , should put operator. in start of file or in function? import some_module def main(): some_module.somestuff() or: def main(): import some_module some_module.somestuff() but if i'll use in more 1 function? correct or stupid ? or need create class __init__ function this: self.module = some_module.somestuff() ? , call in other functions under class? creating class import not pythonic it's bad. should import module name space calling functions in module or can import specific functions: from some_module import somefunc1, somefunc2 # or import some_module some_module.somefunc1() import statement must @ top of source file(look pep8)

IBM Watson Slots won't accept 0 -

i'm trying out slots feature in ibm watson conversations , have hit issue i'm not sure how work around. i have use case collecting number of pieces of information user using slots feature makes sense. unfortunately when add slot @sys-number system not accept 0 valid input. slot in fact required 0 valid value. anyone have idea of how have required slot of type @sys-number accepts 0 value? the condition @sys-number in fact short hand syntax condition entities['sys-number'].value . when 0 sent condition evaluated false 0 treated false expression language evaluator in watson conversation service. not desired behavior in case. prevent happening 1 can use entities['sys-number'] in condition return true every time @sys-number entity recognized in input. when using in slot 1 might want edit gets stored in context variable changing condition change stored in variable. can done json editor - click configure slot gear next slot specification , in

JavaScript random generate time in 12-hour format -

i tried random generate time in 12 hours format. here code in javascript: randomtime = (hrs, mins) => { hrs = math.round(math.random()*hrs); mins = math.round(math.random()*mins); var hformat = (hrs<10 ? "0" : ""); var mformat = (mins<10 ? "0" : ""); var ampm = (hrs<12 ? "am" : "pm"); return string(hformat+hrs+ ":" +mformat+mins+ " " +ampm); } the part execute random generate time: var mydate = new date(); var hour = mydate.getutchours(); var minute = mydate.getminutes(); var resulttime = this.randomtime(hour, minute); i tried loop 30 times minute printed out either in 00 or 01 etc. hour working fine values 9.00am, 12.00pm etc. any ideas? you shouldn't mix current date in answer. gives results not purely random. use this: randomtime = () => { hrs = math.round(math.random() * 24); mins = math.round(math.random() * 60); var hformat = (hrs

groovy - Grails .save(flush: true) behaves the same with .save() -

we have been testing different way of saving. however, results weren't expected. have create-survey method, , each survey has multiple questions. tested few cases , committed queries same way. @transactional class service { survey createnewsurvey(newsurveycommand command) { survey survey = new survey() survey.properties[] = command.properties survey.save(flush: true, failonerror: true) //save survey , flush (newquestioncommand questioncommand : command.questions) { question question = new question() question.properties[] = questioncommand.properties question.save(flush: true, failonerror: true) // save each questions , flush } return survey } } the second removing transactional , saving without flush class service { survey createnewsurvey(newsurveycommand command) { survey survey = new survey() survey.properties[] = command.properties survey.save() //save su

captivenetwork - Captive Portal inside Android App -

can suggest how open captive portal inside android app? i have gone through below links https://developer.android.com/reference/android/net/captiveportal.html using action_captive_portal_sign_in can have complete guide use captive portal inside android application?

android - how to pass Array list <Object> to another activity -

i pass array list intent give error . please tell me wrong. code for sending addtocartlist=new arraylist<>(); intent intent=new intent(shopingcart.this,selectedproductfromshopingcartshow.class); intent.putextra("selectedlist", (serializable) addtocartlist); startactivity(intent); and receiver code public class selectedproductfromshopingcartshow extends appcompatactivity{ arraylist<showproducts> arraylist=new arraylist<>(); string condition="selecteditemsfromshoppingcart"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_selected_product_from_shoping_cart_show); arraylist= (arraylist<showproducts>) getintent().getserializableextra("selectedlist"); } } here's error 07-25 20:15:54.280 16503-16503/com.sizdom.sizdomstockmanager e/androidruntime: fatal exception: main java.lang.runtimeexce

javascript - use a callback inside a sort function -

i want use callback function when sort method has finished sorting numbers inside array. think must this: totals.sort(function(a, b){b - a; continuation()}); somehow though, code isn't doing supposed do. therefore wondering wheter or not because of line of code. in case is, can please tell me appropriate way this. the sort function doesn't accept argument that, can't. it isn't needed though: sort isn't asynchronous in first place. just sort array, whatever else want afterwards. totals.sort(function(a, b){b - a; }); continuation()

php - TCPDF digital signature not visible in adobe viewer -

Image
i trying add digital signature existing pdf file using fpdi , tcpdf , signature getting added pdf file in adobe viewer signature not visible, small rectangular block visible in pdf not text in (i.e. signed john doe, date: ............) below code, <?php require_once('./tcpdf/tcpdf.php'); require_once('./tcpdf/tcpdf_import.php'); require_once('./fpdi/fpdi.php'); $pdf = new fpdi('l', 'mm', 'letter'); //fpdi extends tcpdf $pdf->addpage(); $pages = $pdf->setsourcefile('pan.pdf'); $page = $pdf->importpage(1); $pdf->usetemplate($page, 0, 0); $certificate = 'file://g:/wamp/www/cert/certificate.crt'; $info = array( 'name' => 'nishant', 'location' => 'ahmedabad', 'reason' => 'testing signature', 'contactinfo' => 'http://www.google.com', ); $pdf->text(200, 170, 'test content'); $pdf-

url - Nginx rewritting reverse proxy -

This summary is not available. Please click here to view the post.

mysql - How to get last item for GROUP BY -

this question has answer here: select last row in mysql 7 answers mysql - select last inserted row easiest way 6 answers i have table this: id transaction_id auto_recurring paid_amount package_customerid 37 0 1 0 4 45 37 1 0 4 51 0 1 0 4 57 51 1 0 4 62 0 1 0 4 67 62 1 0 4 there 6 records of package_customer_id = 4. want last record of 4. in case id = 67 desired record. try select * transactions group package_customer_id . got first record of package_customer_id = 4

ios - Object Archive (.plist) between app and its extension -

i'm developing app keyboard extension , i'm trying share between them .plist file contains encoded custom objects (all of same type, class inheriting nsobject). i managed sharing setting app group common both this: // mark: - save helper functions func documentsdirectory() -> string { let paths = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true) return paths[0] } func datafilepath() -> string { let groupcontainerurl: url = filemanager.default.containerurl(forsecurityapplicationgroupidentifier: "group.myapp.something")! let groupcontainerpath = groupcontainerurl.path return (groupcontainerpath nsstring).appendingpathcomponent("myobjects.plist") } and loading file array of objects: private func loadcarmojis() -> [myobject] { var myobjects: [myobject] = [] let path = datafilepath() if filemanager.default.fileexists(atpath: path) { if let data = try? data(contentsof:

perl - Dynamically generate writer/reader from attribute names in Moose -

in moose can put restrictions on instance attributes or add getters/setters so: has 'color' => ( => 'rw', isa => 'str', writer => '_set_color', ); my question is, there way dynamically array of elements? it's possible this: has ['color', 'temperature', 'size'] => ( => 'rw', isa => 'str', ); but there way create each of these items own writer (or reader), e.g. _set_color , _set_temperature , _set_size ? tried see if following yielded insight, returned error bad accessor/reader/writer/predicate/clearer format, must hash ref has ['color', 'temperature', 'size'] => ( => 'rw', isa => 'str', writer => sub { print dumper(\@_); return; ); what hoping (which doesn't work): has ['color', 'temperature', 'size'] => ( => 'rw', isa => 'str',

javascript - Swapping text equal in different divs and classes -

i have several boxes of cards on 1 page, these boxes can come dynamically in different, not upper right corner has text click open accordion type content, each class have action below, think of regardless of number of classes. *new i not know how explain it, i'll try summary: change text of 1 div when clicking, because when click on item in box changes other texts of other boxes. $('.change-1').click(function () { var $mudartxt = $('.mudartexto'); if ($mudartxt.text() == 'expandir') $mudartxt.text('ocultar'); else { $mudartxt.text('expandir'); } }); you need find current clicked item. for can use event object $('.change-1').click(function (e) { // current target jquery object var $target = $(e.currenttarget); // find mudartexto in current target. var $mudartxt = $target.find('.mudartexto'); if ($mudartxt.text() == 'expandir') $

r - save custom ggplotly plot to pdf (in Shiny) -

Image
i export ggplotly plot in shiny in format of pdf. can plotly::export and shiny::downloadhandler function have need: save kind of ggplotly plot user can customize inside app (for example zooming on or filter of elements, etc.). here example: library(webshot) library(htmlwidgets) library(raster) library(ggplot2) library(shiny) library(plotly) server <- function(input, output, session) { #plot function target_plot <- reactive({ dsamp <- diamonds[sample(nrow(diamonds), 1000), ] p <- qplot(carat, price, data=dsamp, colour=clarity) ggplotly(p) }) output$plot_display <- renderplotly({ target_plot() }) #export function output$plot_export <- downloadhandler("test.pdf", function(thefile) { makepdf <- function(filename){ pdf(file = filename) export(target_plot(), file = "test.png") r <- brick(file.path(getwd(), "test.png")) plo

Python custom delimiter for read or readline -

i interacting subprocess , trying detect when ready input. problem having read or readline functions rely on '\n' delimiter @ end of line, or eof yield. since subprocess never exits, there no eof in file object. since keyword want trigger off of not contain delimiter read , readline functions never yield. example: 'doing something\n' 'doing else\n' 'input>' since process never exits, read or read line never see eof or \n requires yield. is there way read file object , set custom delimiter input> ? you can implement own readlines function , choose delimiter yourself: def custom_readlines(handle, line_separator="\n", chunk_size=64): buf = "" # storage buffer while not handle.closed: # while our handle open data = handle.read(chunk_size) # read `chunk_size` sized data passed handle if not data: # no more data... break # break away... buf += data # add co

node.js - Define npm Proxy Windows -

i have seen several posts on this, nothing seems work. tried set npm proxy. ping wpad - commands not working have tried different ways find out, proxy using. what i've tried far (everything https-proxy): http://proxyname:port http://proxyname.dns-suffix:port http://dns-suffix.proxyname:port http://username:password@dns-suffix.proxyname:port http://username:password@proxyname.dns-suffix:port http://"username:password"@proxyname:port http://"domain\username:password"@dns-suffix:port http://dns-suffix:port and other stuff. got proxyname , port manual configuration in windows. going chrome://net-internals/#proxy gives me same result config, can assume right adress&port combination. netsh winhttp show proxy says have direct access (for whatever reason), setting no proxy did not work. dns-suffix got ipconfig /all. feels kinda sad ask considering trying (setting proxy config), have no idea else should do. first check if proxy has been set np

Delphi - how to check for any windows user if it is an administrator? -

i need check kind of accounts available on local machine. i found how can current logged user: function iswindowsadmin: boolean; var haccesstoken: thandle; ptggroups: ptokengroups; dwinfobuffersize: dword; psidadministrators: psid; g: integer; bsuccess: bool; begin result:= false; bsuccess:= openthreadtoken(getcurrentthread, token_query, true, haccesstoken); if not bsuccess begin if getlasterror = error_no_token bsuccess:= openprocesstoken(getcurrentprocess, token_query, haccesstoken); end; if bsuccess begin getmem(ptggroups, 1024); bsuccess:= gettokeninformation(haccesstoken, tokengroups, ptggroups, 1024, dwinfobuffersize); closehandle(haccesstoken); if bsuccess begin allocateandinitializesid(security_nt_authority, 2, security_builtin_domain_rid, domain_alias_rid_admins, 0, 0, 0, 0, 0, 0, psidadministrators); g:= 0 ptggroups