Posts

ASP.NET session vs session state and cookies vs cookie less -

please me whether understanding right. asp.net sessions stored on web server , no cookies whatsoever used this. asp.net if configured use session webconfig->session state: can configure either stateconnection or sqlconnection. asp.net if configured use session state (either stateconnection or sqlconnection) when user uses sessions in code cookies on client machine used unless specify in webconfig cookieless=true if use <sessionstate cookieless="true" /> default stateconnection set localhost when talking session in many dynamic web sites want store user data between http requests (because http stateless , can't otherwise associate request other request), don't want data readable / editable @ client side because don't want client play around data without passing through (server side) code. the solution store data server side, give "id", , let client know (and pass @ every http request) id. there go, sessions implemented. or...

Swift - UITableView scroll event -

i wondering how detect if uitableview scrolled (up or down). want hide keyboard when uitableview scrolled self.view.endediting(true) . thanks in advance you can add uiscrollviewdelegate . after can implement scrollviewdidscroll method.

python - Indent Error with my battleship.py script -

i'm trying create simple 2 player game classic battleship. hence i'm beginning learn python , i'm keeping simple. have created 5x5 grid , want players (2) able place 1 ship 1x1 anywhere on board. take turns guessing other person placed ship. when compiled code got indent error on line 61 "else: " . i'm aware "h" , "m" hit , miss overlap since i'm outputting same playing board. i guess need while loops in code. import sys #////////////////////////////setting board//////////////////////////////////// board = [] x in range(5): board.append(["o"] * 5) def print_board(board): row in board: print " ".join(row) #///////////////////////////getting input////////////////////////////////////////// def user_row(): get_row = raw_input("enter ship row between 1 , 5") #not shure if best way of checking input int if int(get_row) == false: print "you must enter integer...

c++ - Calculate the function F(n) with recursion -

read topic not know saying: function f (n) determined on non-negative integers follows: f (0) = 1; f (1) = 1; f (2n) = f (n); f (2n + 1) = f (n) + f (n + 1) calculated f (n) recursion. , code: #include<iostream.h> double tinh_f(int n) { if(n == 0) { return 0; } if(n == 1) { return 1; } return (f(n+1) - f(2*n+1)); } this incorrect. recursive function calls itself , includes stopping condition: #include<iostream.h> double tinh_f(int n) { if(n == 0) { return 0; } if(n == 1) { return 1; } // note function name change return (tinh_f(n+1) - tinh_f(2*n+1)); } what should function if integer passed in negative? recursion still work? or should throw exception indicate callers contract broken?

javascript - Angular looping multi dimensional json object not working -

i'm practicing angular , thought cool make shopping cart, have downloaded pre-made site template displays items in categories way layed out pretty like <div class="row"> <ul> <li>item1</li> <li>item2</li> <li>item3</li> </ul> </div> so every row in category grid div containing un ordered list of 3 items here angular code: <div ng-app="categoryloader" ng-controller="catloader"> <div ng-repeat="row in items"> <ul> <li class="new" ng-repeat="item in row"> <div class="catthum"><img src="http://cart.asccio.net/images/oxo---homepage_39.jpg" alt="" /><div class="new"></div></div> <div class="catdetail"> <h4><a href="#">{{item.name}}</a></h4> <p...

javascript - C3js - Uncaught TypeError: Cannot read property 'data' of null -

Image
the error message re-created in demo: http://plnkr.co/edit/6tok16u287skhqpsramx?p=preview var chart = c3.generate({ data: { "columns": [["b1", 1], ["b2", 2]], "type": "donut", onclick: onclick, }, donut: { "title": "iris petal width" } }); function onclick(){ chart.load({ columns: [['a_b1', 1], ['b_b1', 2]], unload: ['b1', 'b2'] }); } the documentation function here: http://c3js.org/reference.html#api-load do think i'm using wrong or it's bug in library? --reponse comment-- error occurs in fiddle when section of donut clicked. if watch transition animation closely can see hesitate when rendering different sections of donut. these errors occur after rendering.

backbone.js - Passing variables into Handlebars template when rendering Marionette/Backbone View -

i'm using handlebars backbone , marionette. i'm compiling handlebars templates , storing them in object can referenced view definitions. i'm using layoutview , regions display various items need in ui. what want pass (boolean) variables view such handlebars make decisions (via block helper {{#if varname}} ) render. clarity don't want persist data i'd rather not make them part of model i'm passing in rendered. so i'm doing defining backbone.model , marionette.itemview normal, , trying pass in additional variables via initialize: var newuser = new app.userview({ model: new app.usermodel(), initialize: function(){ this.isnewdoc = true } }); // display view in region using app.regions.maun.show(newuser); // ...etc. what want able pass in , able refer variables such isnewdoc in handlebars template, ideally via {{#if isnewdoc}}...{{/if}} . i've tried various permutations line this.isnewdoc = true such isnewdoc: true i'm not ge...

javascript - The best performant way to push items into array? -

in website have many arrays data. example: vertices array, colors array, sizes array... i'm working big amounts of items. tens of millions. before adding data arrays need process it. until now, did in main thread , made website freeze x seconds. froze because of processing , because of adding processed data arrays. today 'moved' (did lot of work) processing web workers, processed data being added in main thread. managed save freezing time of processing not of adding. the adding done array.push() or array.splice() . i've read articles how array works, , found out when add item array, array being copied new place in memory array.length + 1 size , there adding value. makes data pushing slow. i read typed array faster. need know size of array, don't know, , creating big typed array counter , managing adding items in middle(and not end of array) lot of code change, don't want @ time. so, question, have typedarray return web worker, , need put regu...

oop - How to create an instance in java based on specific input? Implementation of Singleton pattern -

suppose have crypto class. public class crypto{ // method returns instance of crypto class key. // if instance key hasn't been created new instance created. // if created key same instance returned. public static crypto getinstance(string key){ } } how implement pattern? mean singleton design pattern different instances different keys , save instance? i think can use map : class crypto{ map<string,crypto> map = new hashmap<string,crypto>(); private crypto(){ } public static crypto getinstance(string key){ if(map.contains(key)){ return map.get(key); } else{ // switch on key , create cryptos map.put(key,new crypto(); } return map.get(key); } }

c - Problems linking my driver -

i've got quite programming experience, i'm new windows driver development. trying create simple display driver, following this turorial . goal simulate second (and in future: third, etc.) display, purely virtual , renders framebuffer. grab contents of virtual screen via vnc , render remote machine. the problem is: if try build project (using visualstudio 2013 , wdk 8.1), lnk2019 error: error lnk2019: unresolved external symbol "driverentry" in function "gsdriverentry". e:\vs_projects\mviz\mvizvmongdidrv\bufferoverflowfastfailk.lib(gs_driverentry.obj) mvizvmongdidrv there no driverentry function in code, bool drvenabledriver , acting equivalent driverentry in display driver. any ideas on how resolve error? okay, found solution myself: entry point wrong. changing drvenabledriver fixed it.

excel - unique values in combobox based on another combo box -

i adding unique values in combobox2 based on selection in combobox3 . when implementing same code add unique values in combobox3 based on selection on combobox2 , not working. replaced combobox2.value combobox3.value , column b column c . private sub combobox1_change() dim ws worksheet, _ dic object, _ rcell range, _ key string set ws = worksheets("sheet1") set dic = createobject("scripting.dictionary") me.combobox2.clear 'clear added elements me.combobox2.value = vbnullstring 'set active value empty string '------here need tests------- each rcell in ws.range("b2", ws.cells(rows.count, "b").end(xlup)) if rcell.offset(0, -1) <> me.combobox1.value else if not dic.exists(lcase(rcell.value)) dic.add lcase(rcell.value), nothing end if end if next rcell each key in dic userform1.combobox2.additem key next end sub

http - ios multipart image upload, uploaded file is corrupted -

Image
i making multipart post request server , works fine, jpeg i'm uploading doesn't have file extension , can't opened (the file size same orginal). i've tried on tho different servers , same error occured, i'm assuming it's issue of app code. let boundary = generateboundarystring() let request = nsmutableurlrequest(url: urls.sendfileurl) request.httpmethod = "post" request.setvalue("multipart/form-data; boundary=\(boundary)", forhttpheaderfield: "content-type") let body = nsmutabledata() (key, value) in params { body.appendstring("--\(boundary)\r\n") body.appendstring("content-disposition: form-data; name=\"\(key)\"\r\n\r\n") body.appendstring("\(value)\r\n") } let imagedata: nsdata = uiimagejpegrepresentation(photo, 0.8) body.appendstring("--\(boundary)\r\n") body.appendstring("content-disposition: form-data; n...

ubuntu - Seafile-server search option in web -

Image
i have installed seafile server in centos , seafile client in windows machine. please me clarify doubts. have included screenshot. how enable search bar in pages seacloud.cc after logged admin account how view user files. in future how upgrade hard disk incase if hard disk full. only available in pro edition you cannot view other users files except have shared them you stop server -> copy old disk new disk -> update settings ngnix (path data) -> start server

jquery - Moving fullscreen background image -

have been looking 2 days after googling still no idea how achieve want. hope can me. i want background image move this: http://www.theophile-patachou.com/nl/ any suggestions? dug through stackoverflow searching gold no result... guess way go css transform? i tried use these examples build outcome not desired http://www.sitepoint.com/css3-transform-background-image/ you can achieve zooming affect using jquery animate function ( http://api.jquery.com/animate/ ). $('img').animate({width:'+=300',height:'+=300'},16000); $('img').animate({width:'-=300',height:'-=300'},16000); if need use setinterval , call repeatedly. setinterval(function(){ $('img').animate({width:'+=300',height:'+=300'},16000); $('img').animate({width:'-=300',height:'-=300'},16000); },32100);

C dynamic memory allocation array -

my program has 3 int arrays (pointers) declared in main function. user enters length of array a , filled random numbers. then, function called takes 3 arrays arguments. takes numbers array a , puts them array b , , odd numbers c . sizes of b , c need same number of elements. elements of b printed. #include <stdio.h> #include <stdlib.h> #include <time.h> int vela, velb, velc; //the sizes of arrays void napravi(int a[], int *b, int *c); void main() { int *a, *b, *c; int i; srand(time(null)); printf("enter array lenght:"); scanf("%d", &vela); getchar(); = (int*)calloc(vela, sizeof(int)); b = (int*)malloc(4); //i have initialize variable in order pass argument ? c = (int*)malloc(4); for(i = 0; < vela; i++) { a[i] = rand() %101; } napravi(a, b, c); for(i = 0; < velb; i++) { printf("%d ", b[i]); } free(a); // free(b); //windows has trig...

javascript - IDs in quotes when using MongoDB $setEquals -

i've got problem quoted ids in referenced array. when try this: task.find({ game: req.user.game }).exec(function(err, task) { if(err) { console.log(err); } else { console.log(task[0].incategories); } }); it writes array of ids in quotes node.js console ( ["5550a9604b24bcdc1b88cc76", "5551213c35d0516807b2cd99"] ). i'm trying return task logged in user (look @ comments next console.log commands): profession.find({ _id: req.user.profession }).exec(function(err, profession) { if(err) { return res.status(400).send({ message: errorhandler.geterrormessage(err) }); } else { console.log(profession[0].assignedtaskcategories); // output: array quoted ids var pipeline = [ { '$match': { 'game': req.user.game, } }, { '$project': { 'title': 1, ...

python - "yield from iterable" vs "return iter(iterable)" -

when wrapping (internal) iterator 1 has reroute __iter__ method underlying iterable. consider following example: class fancynewclass(collections.iterable): def __init__(self): self._internal_iterable = [1,2,3,4,5] # ... # variant def __iter__(self): return iter(self._internal_iterable) # variant b def __iter__(self): yield self._internal_iterable is there significant difference between variant , b? variant returns iterator object has been queried via iter() internal iterable. variant b returns generator object returns values internal iterable. 1 or other preferable reason? in collections.abc yield from version used. return iter() variant pattern have used until now. the significant difference happens when exception raised within iterable. using return iter() fancynewclass not appear on exception traceback, whereas yield from will. thing have information on traceback possible, although there situations want hid...

android - Mail link open my app on specific URL -

i'm using crosswalk . have hard restrictions speaking project i'll try clear possible. when open app manually, webview load home index.html of website. website used webrtc so, send invitation via e-mail specific url. is possible open my own application url clicked ? i checked <intent-filter> have no clue how deal url opening. hope have solutions or clues. edit: <intent-filter> <data android:scheme="https" android:host="xxx.xxx.com"/> <action android:name="android.intent.action.view"/> <category android:name="android.intent.category.browsable"/> <category android:name="android.intent.category.default"/> </intent-filter> with can open application when click on link, still need link url , set url loaded in xwalkview. example: https://xxx.xxx.com/join?xertfgf=1 when click on that, app open good, know want xwalkview load this. ...

Android ListView Pull to refresh and Swipe List item to reveal buttons -

i working on android listview. implemented pull refresh through xlistview , want implement swipe left right show buttons list item on listview. how can it? or how add 2 libs same on listview. my listview in xml is. <com.orderlyexpo.www.listview.refresh.xlistview android:id="@+id/lvorders" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="@color/gray_text" android:dividerheight="@dimen/dp1x" /> don't use lib swipe, make own view , can use pull refresh same lib. just way. add class name. swipedetector.java public class swipedetector implements view.ontouchlistener { public static enum action { lr, // left right rl, // right left tb, // top bottom bt, // bottom top none // when no action detected } private static final string logtag = "swipedetector"; private static final int min_distance = 100...

How to set the screen orientation to Landscape mode in a activity when the auto rotation feature is turned off in the device settings in Android -

well, have requirement, orientation of screen should changed, when phone turned when auto-rotation feature off on android-device settings. i know can achieved using the setrequestedorientation(activityinfo.screen_orientation_sensor); in oncreate of activity. or by @override public void onconfigurationchanged(configuration newconfig) { super.onconfigurationchanged(newconfig); setrequestedorientation(activityinfo.screen_orientation_sensor); } any tips or best practices or code snippets can achieve this? way of implemenatation right? helpful if has managed achieve within custom views or fragments share logic on how implemented. help! i know can done in androidmanifest file adding tag, limit layout in landscape , not i'm looking for.