Posts

javascript - Why should I use immutablejs over object.freeze? -

i have researched on net benefits of immutablejs on object.freeze() didn't find satisfying! my question why should use library , work non native data structures when can freeze plain old javascript object? i don't think understood immutablejs offers. it's not library turns objects immutable, it's library around working immutable values. without repeating docs , mission statement , i'll state 2 things provides: types. implemented (immutable) infinite ranges, stacks, ordered sets, lists, ... all of types implemented persistent data structures . i lied, here's quote of mission statement: immutable data cannot changed once created, leading simpler application development, no defensive copying, , enabling advanced memoization , change detection techniques simple logic. persistent data presents mutative api not update data in-place, instead yields new updated data. i urge read articles , videos link , more persistent data structures (...

java - How does Collections.sort(...) work? -

to clear, trying find out how collections.sort(list, new mycomp()) method calls compare method in sequence. i have linkedlist employees , personal number (k): numbers are: {1,2,3,4,5,6} compare(object o1, object o2) method in mycomparator gives number (which not relevant concern). how sort() call method compare? call parameters 1,2 then, 2,3 3,4 4,5 5,6? debug there's strange sequence jumps , compares 1,3. what compare? pattern? the specific comparisons made depend on algorithm, internally, collections.sort method using sort elements. according javadoc collections.sort : the documentation polymorphic algorithms contained in class includes brief description of implementation. such descriptions should regarded implementation notes, rather parts of specification. implementors should feel free substitute other algorithms, long specification adhered to. (for example, algorithm used sort not have mergesort, have stable.) in other words, java implementations free...

java - Where is the Deadlock? -

this tutorial java docs deadlock. don't threads blocked. since synchronized thought 1 thread 'll enter bow. both entered bow. [one waits [but when?]] then issue? when add comments [print statements trace]. there's no deadlock. how? public class deadlock { static class friend { private final string name; public friend(string name) { this.name = name; } public string getname() { return this.name; } public synchronized void bow(friend bower) { system.out.format("%s: %s" + " has bowed me!%n", this.name, bower.getname()); bower.bowback(this); } public synchronized void bowback(friend bower) { system.out.format("%s: %s" + " has bowed me!%n", this.name, bower.getname()); } } public static void main(string[] args) { final friend alphonse ...

python - How to swap configuration files for Production and Development? -

some time ago created script using python, script execute actions in instance based on configuration file. this issue, created 2 configuration files. config.py instance= <production url> value1= value2= b ... testconfig.py instance= <development url> value1= c value2= d ... so when want script execute tasks in development instance tests, import testconfig.py instead of config.py. main.py # config import * testconfig import * the problem comes when update script using git. if want run script in development have modify file manually, means have uncommited changes in server. doing change takes 1 min of time feel i'm doing wrong. do know if there's standard or right way accomplish kind of tasks? export environment variables on machines, , chose settings based on environment variable.

laravel - Registering Spark API Token -

i have created spark api token , trying register spark token using command spark register token-value but getting error cannot open source file register.ada does have idea on might causing error on ubuntu o.s? you need buy spark api token. when have it, replace token-value api key.

asp.net core mvc - Multi-Language Website with RESX Files -

i've been looking around example on how use resx files localization on mvc6 , far not able find example. my website have dropdown list avalible languages. dont want application automatically detect localization. ideia user select language , view select appropriate language (maybe keep language cookie) resx folder. so far i've created folder resources.resx, resources.en-en.resx, resources.es-es.resx. does have working example this? thank much!

JUnit test with Spring and mongodb: could not autowire repository -

i have problem writing test spring , junit test mongodb respository. message "could not autowire. no beans of ... type found" repository is public interface projectrepository extends mongorepository<project, string> { public project findbyname(string name); } while configuration file is @configuration @enablemongorepositories(basepackageclasses = repositorypackage.class) public class springmongoconfiguration extends abstractmongoconfiguration{ @override protected string getdatabasename() { return "test"; } @bean public mongoclient mongo() throws exception { mongoclient client = new mongoclient("localhost"); return client; } @bean public mongotemplate mongotemplate() throws exception { return new mongotemplate(mongo(), getdatabasename()); } } where repositorypackage in same package of repository. test is @runwith(springjunit4classrunner.class) @contextconfiguration(classes = springmongoconfiguration.class) public...