Posts

Python lists, increment & return modified list -

this question has answer here: python assign values list elements in loop 4 answers the below code doesn't work intended: l = [1,1] def modifylist(list): element in list: element += 1 return list the list expect when run: modifylist(l) is [2,2] instead of [1,1] can explain why python acts way? you need access list element using index , increment: def modifylist(lst): ind, _ in enumerate(lst): lst[ind] += 1 # access list element index , increment return lst or use list comprehension , add 1 each element: def modifylist(lst): lst[:] = [ele +1 ele in lst] # lst[:] changes original list return lst if modifying original list in place, don't need return value, if want create new list return list comprehension: return [ele +1 ele in lst] def mod_in_place(lst): lst[:] = [ele +1 ele in lst] # lst[:] chan...

winapi - WS_OVERLAPPEDWINDOW and WM_SYSKEYDOWN -

setwindowlong(hwnd, gwl_style, ws_overlappedwindow); if add line above, program receive every second press of alt key. catch alt key wm_syskeydown event. must mention though, wm_syskey up still detects every release of alt key. so when repeatedly press alt key log looks this: down up down up any idea why that, , how fix problem still retain normal application window look? (that why overlapped window flag used). update: found ws_sysmenu causes same problem, must related sys menu hotkeys.

codeigniter - mb_convert_encoding() function is not working in php -

i using library (glocery_crud) in codigniter convert database table csv , working fine on localhost on live server showing me blank page , not creating csv file . here code -: // convert utf-16le , prepend bom $string_to_export = "\xff\xfe" .mb_convert_encoding($string_to_export, 'utf-16le', 'utf-8'); $filename = "export-".date("y-m-d_h:i:s").".csv"; header('content-type: application/csv;charset=utf-16le'); header('content-disposition: attachment; filename='.$filename); header("cache-control: no-cache"); echo $string_to_export; die(); if commenting first line geting csv file not formatted in csv () -: testing9988312003sdgsgsdgsgvipul@gmail.comsdgfrayear it works fine $string_to_export = "\xff\xfe".iconv("utf-8","ucs-2le",$string_to_export);

python 2.7 - PyPlot.pltm is not defined -

i on ubuntu 14.04 platform. have installed julia, anaconda etc. when try plot on ijulia using pyplot, following error. julia> pkg.add("pyplot") info: nothing done julia> using pyplot julia> x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x)); julia> pyplot.plot(x, y, color="red", linewidth=2.0, linestyle="--") error: pltm not defined in plot @ /home/cgmei/.julia/v0.3/pyplot/src/pyplot.jl:368 is pltm part of other package. when want call external python packages in julia need call them in different way did. in example should is: pkg.add("pycall") using pycall @pyimport pylab x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x)); pylab.plot(x,y, color="red", linewidth=2.0, linestyle="--") pylab.show() if want use python library example clarify, assuming have added package pycall: using pycall @pyimport numpy x = numpy.linspace(0,2*pi,1000) and result ...

python - pelican blog post not getting generated -

i trying post pelican blog python app, not doing pelican ./output -s settings.py commandline. i have modified pelican accept mocked argparse object pass needs, have moved content of main function in __init__.py to function named runpelican(args) accepts args, , app has mocked argparse this, class mockargparse(object): """mock argparse's pass pelican """ def __init__(self, verbosity=true, theme=none, output=none, path=none, delete_outputdir=none, settings=none, ignore_cache=none, cache_path=none, selected_paths=none, autoreload=none): """ args: path (str): content path settings(str): settings python file path """ super(mockargparse, self).__init__() self.theme = theme self.cache_path = cache_path self.ignore_cache = ignore_cache self.delete_outputdir = delete_outputdir self.s...

javascript - Disable submit button on file input validation error using krajee file-input plugin -

i using plugins.krajee.com/file-input , can't find way of disabling upload or submit button of form when validation error occurs minimagewidth exceeded. $('.file').fileinput({ language: 'en', showupload: false, allowedfileextensions : ['jpg', 'png','gif'], maxfilesize:1024, minimagewidth:286, minimageheight:322 }); how use $('.file').fileinput('disable'); when image width minimum setting returns validation error?

javascript - Node.JS WriteFile - File of specific size -

is there way specify size/length of file , have system reserve space needed? i'm looking like: fs.write('file', buffer, 1024*1024*54); // create 54mb file. just create buffer of size? fs.writefile('file', new buffer(1024*1024*54));