Posts

Showing posts from May, 2014

html - How would I make background of slideshow more opaque -

this question has answer here: how give text or image transparent background using css? 26 answers i kinda want make black background little transparent unfortunately making image within slide transparent well. code: #slideshow { float:left; width: 810px; height: 360px; margin: 10px 0 0 10px; background-color: rgb(0,0,0); -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; } #slideshow img { margin: 5px 5px; -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; } you can use rgba() set background color opacity. example: #div { background-color: rgba(0,0,0,.4); } this make background black 40% opacity.

java - Can jackson deserialize from different JSON string to same object? -

i have json string, this: { ... "token": "abc123" ... } then reason, have update new structure, expected incoming json string becomes: { ... "token": {"property01":"true", "property02":"false", "value": "abc123"} ... } originally, token field in string type, now, becomes object, additional properties. i need handle both format backward compatibility, can jackson handle case? you creating own deserializer: class foojsondeserializer extends jsondeserializer<foo> { @override public foo deserialize(jsonparser jp, deserializationcontext ctxt) throws ioexception, jsonprocessingexception { foo foo = new foo(); //deserialize data here return foo; } } and don't forget add deserializer class @jsondeserialize(using = foojsondeserializer.class) class foo { ... }

python - performance generating combinations of objects with combinations of attr -

i looking advice on how can better approach couple of functions. i have set of 5 objects 6 attributes on each, number of objects can change amount of attributes. i need iterate on each possible combination of attribute, on each possible combination of object. no object in set can feature same value within set. , each objects attributes there n possible values ( n set size ). values applicable attributes cannot applicable attribute. ie. attributea's value, never value attributeb. at moment have objects represented list of lists. eg. [[obj1attr_a, obj1attrb], [obj2attr_a, obj2attr_b]] etc the problem itertools.combinations returns many redundent combinations not valid ( ie. values appear more once ). if use generator return valid combinations slow never yields correct combination. there way filter results in itertools.combinations efficiently? #keywords list of possible values each attribute solver.get_unique_combinations( itertools.combinations(itertools.produc

caching - Couchbase warmup strategies -

we have memcached cluster running in production. replacing memcached couchbase cluster persistent cache layer. question how implement cut-over , how warm couchbase bucket. can't switch on cold couchbase since starting old cache bring whole site down. one option thinking warm couchbase memcached node first. means couchbase using (non-persistent) memcached bucket, , getting cache set/get traffic other memcached node. thing there minimum code changes (what's needed configure moxi proxy take memcached traffic, , register node memcached node). later convert memcached buckets couchbase. not sure couchbase supports conversions between these 2 types of buckets. the 2nd option set persistent couchbase bucket (as opposed non-persistent memcached bucket) @ beginning. change production cache client replicate traffic both memcached , coucbase clusters. monitor couchbase bucket , once cache items reach size, complete cut-over. small drawback complexity change cache client. thoughts

Calculating exact change with JavaScript -

i'm attempting solve algorithm challenge on @ freecodecamp. here prompt problem: design cash register drawer function checkcashregister() accepts purchase price first argument (price), payment second argument (cash), , cash-in-drawer (cid) third argument. cid 2d array listing available currency. return string "insufficient funds" if cash-in-drawer less change due. return string "closed" if cash-in-drawer equal change due. otherwise, return change in coin , bills, sorted in highest lowest order. my solution works of parameters, except following: checkcashregister(19.50, 20.00, [["penny", 1.01], ["nickel", 2.05], ["dime", 3.10], ["quarter", 4.25], ["one", 90.00], ["five", 55.00], ["ten", 20.00], ["twenty", 60.00], ["one hundred", 100.00]]) should return: [["quarter", 0.50]] checkcashregister(3.26, 100.00, [["penny&quo

php - How to get back a Header in Wordpress once removed? -

at first wanted remove header on few pages. used code: /* hide header menu ()/ */ .page-id- #header-space, .page-id- #header-outer { display: none; } .page-id- #header-secondary-outer { display: none; } .page-id- #footer-outer { display: none; } i can't figure out how bring header these pages, deleted code 'appearance - editor) didn't seem work. can help? display: block should it. display: block opposit of display: none.

python - Making 1 milion requests with aiohttp/asyncio - literally -

i followed tutorial: https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html , works fine when doing 50 000 requests. need 1 milion api calls , have problem code: url = "http://some_url.com/?id={}" tasks = set() sem = asyncio.semaphore(max_sim_conns) in range(1, last_id + 1): task = asyncio.ensure_future(bound_fetch(sem, url.format(i))) tasks.add(task) responses = asyncio.gather(*tasks) return await responses because python needs create 1 milion tasks, lags , prints killed message in terminal. there way use generator insted of pre-made set (or list) of urls? thanks. asyncio memory bound (like other program). can not spawn more task memory can hold. guess hit memory limit. check dmesg more information. 1 millions rps doesn't mean there 1m tasks. task can several request in same second.

camera - libGDX: Get most left coordinate in a FillViewport -

how can left coordinate in fillviewport? tried things camera.viewportwidth/50, math.abs(gamescreen.viewport.getleftgutterwidth()) when resizing game, sprite should left outside of screen. resize method: @override public void resize(int width, int height) { viewport.update(width,height, true); }

WPF: Windows 7 vs Windows 10 Appearance -

Image
i have annoying appearance differences between windows 10 devices , windows 7 devices. i using windowstyle="none" , dockpanel directly inside window element. what don't why there still border? why borders on buttons, textboxes, comboboxes, etc. rounded? it seems related aero. there way can stop application using aero? i'm assuming there presentation framework related windows 10 not know called force it. would borderbrush easiest way resolve this? <window x:class="cbd.presentation.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:cbd.presentation" title="cbd" height="760" width="944" windowstartuplocation="centerscreen" windowstyle="none" sizechanged="window_sizechanged" minwidth="944" minheig

c - Size of allocated memory to a pointer changes when increment the pointer -

this question has answer here: program crashes when deleting pointer pointing heap? 2 answers char *ptr = (char*)malloc(10); if(null == ptr) { printf("\n malloc failed \n"); return -1; } else if(argc == 1) { printf("\n usage \n"); } else { memset(ptr, 0, 10); strncpy(ptr, argv[1], 9); while(*ptr != 'z') { ptr++; } if(*ptr == 'z') { printf("\n string contains 'z'\n"); /* more processing */ } free(ptr); } in previous code, lets arguments program is: mixx , program gives segmentation error. and question is: when in while loop: ptr++; does mean size of memory allocated pointer ptr changes , that's why when call free() function crashes

jquery - PHP-serialized String is cutted -

Image
i have form send via ajax. in form put values php-serialized-string in hidden input. <input type="hidden" name="userdata" id="userdata" value="<?php echo serialize($userinput); ?>"> now when send form.. let data = $('#step-4 :input').serialize(); $('#step-5').load('php/send.php?data='+data, function() { ... the serialized string somehow cutted.. [userdata] => a:13:{s:6: and can't figure out why(?) php jquery serialization share | improve question edited aug 8 '16 @ 13:21 asked aug 8 '16 @ 13:18 99problems 55 6

java - Find largest sequence within an arraylist -

some background last week did problem in textbook told me generate 20 random numbers , put brackets around successive numbers equal consider following program outputs 697342(33)(666)(44)69(66)1(88) what need do the next problem longest sequence of these words , put brackets around them. if have 1122345(6666) basically need put brackets around 4 6's , since occur often. i've finished other problems in chapter studying ( arrays , arraylists), can't seem figure 1 out. here solution have made putting brackets around successive numbers: class seq { private arraylist<integer> nums; private random randnum; public seq() { nums = new arraylist<integer>(); randnum = new random(); } public void fillarrlist() { (int = 0 ; < 20 ; i++) { int thisrandnum = randnum.nextint(9)+1; nums.add(thisrandnum); } } public string tostring() { stringbuilder

javascript - Tampermonkey get downloaded resource -

so, web page @ load download json file. want @ content of json, possible? i tried alter xmlhttprequest.prototype.open catch thing, seems script run after downloaded, nothing. by download, mean on network tab of developer tools, there's row saying "abc.json?blablah". note: file downloaded creating script element , attach body, destroy afterward (or something, because can't find after that). // ==userscript== // @name download subtitle wistia // @namespace http://tampermonkey.net/ // @version 0.1 // @description try take on world! // @author // @match http://*/* // @grant none // @run-at document-start // ==/userscript== (function() { 'use strict'; var open = xmlhttprequest.prototype.open; xmlhttprequest.prototype.open = function(method, url, async, user, pass) { console.log("generic request: " + url); if (url.indexof(".json") > -1) { console.l

android viewpager notifyDatachange return to first -

i'm working in android projet. use tab display data fragment. in third fragment, when update data, viewpager return first. try everything. this viewpageradapter public class viewpageradapter extends fragmentpageradapter { private final list<fragment> mfragmentlist = new arraylist<>(); private final list<string> mfragmenttitlelist = new arraylist<>(); private int baseid=0; public viewpageradapter(fragmentmanager manager) { super(manager); } @override public fragment getitem(int position) { return mfragmentlist.get(position); } @override public int getcount() { return mfragmentlist.size(); } public void addfragment(fragment fragment, string title) { mfragmentlist.add(fragment); mfragmenttitlelist.add(title); } @override public charsequence getpagetitle(int position) { return mfragmenttitlelist.get(position); } @override public i

command - How to delete files from android old sdk folder under Windows 10 -

i install android sdk android-sdk folder , android studio android-sdk path sdk installer. used path sdk android studio. try delete old android-sdk got error: ...\appdata\local\android\android-sdk\platform-tools\adbwinusbapi.dll access denied. i used try access: takeown /f android-sdk /r /d y icacls android-sdk /grant administrators:f /t also username account. how remove folder content? this fixed new android studio version 2.2.3 new instalation.

c++ - Performance decreases with a higher number of threads (no synchronization) -

i have data structure (a vector) elements have parsed function, elements can parsed different threads. following parsing method: void consumerpool::parse(size_t n_threads, size_t id) { (size_t idx = id; idx < nodes.size(); idx += n_threads) { // parse node //parse(nodes[idx]); parse(idx); } } where: n_threads total number of threads id (univocal) index of current thread and threads created follow: std::vector<std::thread> threads; (size_t = 0; < n_threads; i++) threads.emplace_back(&consumerpool::parse, this, n_threads, i); unfortunately, if method works, performance of application decreases if number of threads too high . understand why performance decreases if there's no synchronization between these threads. following elapsed times (between threads start , last join() return) according number of threads used: 2 threads: 500 ms 3 threads: 385 ms 4 threads: 360 ms 5 threads: 475 ms 6 threads:

ruby on rails - No route matches {:action=>"show", :controller=>"scoo.....missing required keys: [:id] -

i have partial form create , update...for new render partial when going edit 1 keep getting error actioncontroller::urlgenerationerror in scoopes#edit no route matches {:action=>"show", :controller=>"scoopes", :id=>nil, :user_name=>#<scoope id: 11, name: "asdsada", user_id: 3, created_at: "2016-08-07 20:37:52", updated_at: "2016-08-07 20:37:52">} missing required keys: [:id] i search answer old questions no 1 solved problem...the form creating scoopes.... the assosiaction between scoope , users : scoope belong_to user , user has_many scoopes here scoope controller: class scoopescontroller < applicationcontroller before_action :authenticate_user!, except: [:show] before_action :set_scoope, only: [:show, :edit, :update, :destroy, :index] before_action :owned_scoope, only: [:edit, :update, :destroy] def index @scoopes = @user.scoopes.all end def show @scoope = @user.scoopes.find(pa

How to enable a radio button based on combo box item in wpf -

i have combo box having 5 items , have 2 radio buttons. want enable first radio button if first item selected in combo box unless second radio button must enabled. how can in wpf? can me? you need subscribe combobox selectionchanged event , in can this: private void cmb_selectionchanged(object sender, selectionchangedeventargs e) { var combo = sender combobox; if (combo.selectedindex == 0) rad1.ischecked = true; else rad2.ischecked = true; } here rad1 , rad2 radio buttons defined in xaml.

android - How to get a HEAD of a Retrofit call from an api endpoint that requires field in the request body? -

i trying examine headers of response api call made via retrofit 2.0.2 before downloading content. my api interface looks following: @headers({"accept: application/json", "origin: http://www.example.com"}) @head("profiles") call<void> getprofileheaders(@field("puids") string puid); please note api call requires me specify in body field called puids=%{uuid} list of uuids in order return response. if download data without examining headers first, call interface this: @headers({"accept: application/json", "origin: http://www.example.com"}) @formurlencoded @post("profiles") call<string> getprofile(@field("puids") string puid); now issue when try use getprofileheader() endpoint, following runtimeexception: java.lang.illegalargumentexception: @field parameters can used form encoding. (parameter #1) in order use @field parameters (as suppose post method if required), have explicitl

angularjs - Adding multiple stylesheets to brunch -

i'm new angular , i'm working on angular2 project. want add these following css files brunch syntax? better add brunch-config.js or index.html? files: '/app/assets/css/bootstrap.css', '/app/assets/css/custom.css', '/app/assets/css/font-awesome.css', 'http://fonts.googleapis.com/css?family=open+sans' brunch-config.js: exports.config = { // see http://brunch.io/#documentation docs. files: { javascripts: { jointo: { 'vendor.js': /^node_modules/, 'main.js': /^app/ }, order: { after: [/\.html$/, /\.css$/] } }, stylesheets: { jointo: 'app.css' }, templates: { jointo: 'main.js' } }, plugins: { inlinecss: { html: true, passthrough: [/^node_modules/, 'app/global.css'] } } }; you can import fonts using @import css at-rule or <link> html element, usual. add other files, pu

javascript - Angular logic chaining in ng-class -

i'm trying chain logic in angular's ng-class directive. code within ng-class looks this: 'class-name': (x && y) || (z && !y) it working fine when had (x && y) other expression broke it. this: 'class-name': x && y, 'class-name': z && !y also doesn't work. know correct syntax chaining expressions here? lot help!

python - Django says that table doesn't exist while it does -

my ultimate goal deploy django application on new server , have raw image of disk of old server. have set on new server: uwsgi, python, mysql, django etc. let's problem: when run uwsgi --http :8001 --module propotolki.wsgi it runs without errors when try access through browser following stack trace in logs: internal server error: / traceback (most recent call last): file "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 90, in get_response response = middleware_method(request) file "./apps/middleware/middleware.py", line 11, in process_request if redirecthandler.objects.filter(is_active=true, redirect_from=request.path).exists(): file "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 512, in exists return self.query.has_results(using=self.db) file "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 409, in has_results return bool(compi