Posts

random number generator between 0 - 1000 in c# -

i need in writing program generate 100 random numbers between 0 , 1000. out put needs displayed in windows message box. i'm stuck code have use numbers in box , have 100 random numbers. have tried random integer between 0 , 1000(1000 not included): random random = new random(); int randomnumber = random.next(0, 1000); loop many times want

php - Static variable inside function can't hold reference to singleton -

i've noticed weird behavior singletons in php there's no better way explain example. let's have following singleton class: class singleton { protected function __construct() { // deny direct instantion! } protected function __clone() { // deny cloning! } public static function &instance() { static $instance; echo 'class echo'.php_eol; var_dump($instance); if (!isset($instance)) { $instance = new self; } return $instance; } } and following function: function test($init = false) { static $instance; if ($init === true && !isset($instance)) { $instance =& singleton::instance(); } echo 'function echo'.php_eol; var_dump($instance); return $instance; } and when use following: test(true); test(); singleton::instance(); the output is: class echo null function echo object(singleton)#1 ...

Disable Close Button In Title Bar of a WPF Window (C#) -

Image
i'd know how disable (not remove/hide) close button in wpf window. know how hide makes window's title bar this: but want disable meaning should this: i'm scripting in c# , using wpf (windows presentation foundation). try this: public partial class mainwindow : window { [dllimport("user32.dll")] static extern intptr getsystemmenu(intptr hwnd, bool brevert); [dllimport("user32.dll")] static extern bool enablemenuitem(intptr hmenu, uint uidenableitem, uint uenable); const uint mf_bycommand = 0x00000000; const uint mf_grayed = 0x00000001; const uint mf_enabled = 0x00000000; const uint sc_close = 0xf060; const int wm_showwindow = 0x00000018; const int wm_close = 0x10; public mainwindow() { initializecomponent(); } private void window_loaded(object sender, routedeventargs e) { } protected override void onsourceinitialized(eventargs e) { base...

python - django search function , models are not working -

@login_required def searchproduct(request): """ search particular product name """ search_terms ='' if request.get['search_term']: search_terms = request.get.get('search_term') if search_terms: products = models.product.objects.filter(product_name__icontains=search_terms) product in products: kitchenstyle = kicthenstylemapping.objects.filter(product= product) print kitchenstyle return render_to_response('admin/product/searchlistproduct.html',{'search_terms': search_terms,'products' : products }, context_instance=requestcontext(request)) return httpresponseredirect('/') class kicthenstylemapping(models.model): style_mapping_id = models.autofield(primary_key=true) style = models.foreignkey(kitchenstyle) product = models.foreignkey(product) class meta: ...

onkeydown - android policy phonewindow getSystemService permission denied -

i trying use context.getsystemservice(context.activity_service) to topactivity in onkeydown method of class phonewindow.java .but told "java.lang.securityexception: permission denial: gettasks()" ,how can change permission or code right ? below piece of code protected boolean onkeydown(int featureid, int keycode, keyevent event) { context mcontext; mcontext = getcontext(); activitymanager mactivitymanager = (activitymanager)mcontext.getsystemservice(context.activity_service); componentname mcname = mactivitymanager.getrunningtasks(1).get(0).topactivity; string activityname = mcname.getclassname().tostring(); log.d(tag, "packagename " + activityname); ... } <uses-permission android:name="android.permission.get_tasks" > </uses-permission>

batch file - How to show a data list for created profiles -

i"m new batch file , i'm attempting make rpg i'm looking goes past knowledge of batch file wondering how make system able see profiles/users/data's created decide load,delete,etc. data selecting :datalist cls echo. echo datas echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍ echo test echo test02 echo test03 set /p datas=enter= if %datas% == %currentdata% goto ? ^test ^test ^testdata so see... datas --------------- test test02 test03 after select testdata :testdata echo. echo test data echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍ echo 1) load current data echo 2) delete current data echo 3) set /p dataoptions=enter= if %dataoptions% equ 1 goto %test%data if %dataoptions% equ 2 del %test%data if %dataoptions% equ 3 goto datalist this see test data -------------- 1) load current data 2) delete current data 3) so need have operate every time make new dat...

javascript - How to generate a custom image in php? -

i looking create product customization tool in php. tool allow user create own customization predefined mobile cover. have mobile cover image , looking allow user write 3 characters written in circle called monogram background color. i not sure how proceed ahead it. looking dynamically create image placed on mobile cover in such way looks part. here link sample image generated http://d13eowy7ljcd3.cloudfront.net/images/ark.png i looking way on how approach , php image handling libraries should make use of. help appreciated. have @ gd , image functions . imagearc there lot of examples out there. you may have @ imagemagick , graphicsmagick.