Posts

Optimizing dictionaries in Python -

my question different 1 asked here . asking improvements made code containing dictionaries. however, link explains memory profilers, next step. i have following 2 sets of code achieve same thing. first one, a={1: 'a', 2: 'b', 3: 'c', 4: 'd'} b=[x x in if x in (1,2,3)] b=['a', 'b', 'c'] second one, a={1: 'a', 2: 'b', 3: 'c', 4: 'd'} c=[a[x] x in set(a.keys()) & set([1,2,3])] b=['a', 'b', 'c'] i know 1 works better in terms of memory optimized methods, , large sets of data. thanks in advance! if you're optimizing memory use generators tool. example: def get_keys(mapping, keys): key in keys: try: yield mapping[key] except keyerror: continue on example: list(get_keys(a, (1, 2, 3))) ['a', 'b', 'c']

Open file name that is inside the register in Ex mode in Vim -

if have full path inside register(e.g. @a="/dir/file.txt" ) , want open file in ex mode. i try :e @a that, doesn't work. and try :e echo @a doesn't work either. obviously can type :e ctrl-r a in ex mode, works. but i'm wondering there way content of register in ex mode without use ctrl-r. the :edit command takes file specification. there special characters (like % current file name; cp. :h cmdline-special ), @reg notation not work here. vim's evaluation rules different programming languages. need use :execute in order evaluate variable (or expression); otherwise, it's taken literally; i.e. vim uses variable name argument. so, solution problem is :execute 'edit' @a if don't want special characters apply register contents, more robust (but longer) way is :execute 'edit' fnameescape(@a)

javascript - jQuery/CSS: Changing the height and width attributes of an image when clicked -

i'm working on simple gallery built html, css, , jquery. when user clicks on image, larger version of image should pop in frame overlay behind it. have no problems horizontally-oriented images, vertically-oriented images, larger image comes out distorted. you can view working sample on codepen: http://codepen.io/anfperez/pen/axzgrv i try change the attributes of image saving height of image in variable , changing attribute using jquery, doesn't seem working. how can access height , width of larger image url , put frame? trying following code, did not work. var height_large = $(this).attr('height') var width_large = $(this).attr('width') $('#frame img').attr('height', height_large) $('#frame img').attr('width', width_large) for reference, here actual url of photo i'm trying pull down: https://farm8.staticflickr.com/7072/7274940170_c166072ddf_c.jpg changing height auto #frame img worked me. displays la...

Jenkins upload artifact to nexus plugin not working with Nexus 3 -

i have jenkins project gradle build , uploads build artifacts nexus maven hosted repository using jenkins upload artifact nexus plugin. working fine when using nexus 2.13 - after upgrading nexus 3, upload nexus no longer working. have made sure have configured nexus 3 repository nexus 2.13 repository. when build jenkins project response groupid: com.company artifactid: hello-world-util version: 1.0.0 file: hello-world-util-1.0.0.jar repository:companydevops uploading artifact hello-world-util-1.0.0.jar started.... reason phrase: method not allowed <!doctype html> <html> <head> <title>405 - nexus repository manager</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <!--[if lt ie 9]> <script>(new image).src="http://192.168.99.100:18081/favicon.ico?3.0.1-01"</script> <![endif]--> <link rel="icon" type="image/png" href="http:...

deep learning - How to use mxnet RNN symbol to generate lstm -

i've found rnn symbol added in mxnet v0.7 python lib. now, i'm trying use impl lstm in example/rnn python. have no idea because there's no document or information of input , output. can give me advice? thanks i think have given simple example on how use rnn symbol build lstm (they have mode option this, i.e., mode='lstm'). here example, check out: https://github.com/dmlc/mxnet/blob/master/example/rnn/rnn_cell_demo.py

apache - RewriteEngine is not working [.htaccess] -

rewrite engine not working, i'm using 000webhost web hosting service provider , i'm on free plan. problems: 1.) when go domain (without subdomains) prospekt.ml , i'm gonna redirected 000webhost 404 error. 2.) when tried test .htaccess if it's working. it's supposed rewrite url , add vanity url. ( user/astroxoom) instead of that, i'm getting redirected 000webhost 404 error. the .htaccess file placed on public_html folder. should redirect "member/user/username.php?username=$1" screenshot of public_html thank , have day! edit: .htaccess file # not remove line, otherwise mod_rewrite rules stop working rewritebase / # fancy indexing options indexes indexoptions fancyindexing namewidth=80 scanhtmltitles indexorderdefault ascending date indexignore *.jpg *.png # rewrite users rewriteengine on rewriterule ^member/user/([^/]+)$ member/user/username.php?username=$1 [l,qsa] on 000webhost server have use absolute rewrite path (st...

php - Symfony [2.8.9] EntityType within embedded form not selecting value -

i have organisation entity referencing embedded form containing country entity. form saves without issue, country entitytype field not correctly pick value upon editing, , such first option in dropdown selected rather correct option. the organisationtype form: <?php namespace appbundle\form\type\meta; use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface; use symfony\component\form\formevent; use symfony\component\form\formevents; use symfony\component\optionsresolver\optionsresolver; class organisationtype extends abstracttype { public function __construct() { } public function buildform(formbuilderinterface $builder, array $options) { $builder ->add('title', new titletype(), array('required' => true, 'label' => false)) ->add('country', new countrytype(), array('label' => false)) ->add('locatio...