Skip to content

Instantly share code, notes, and snippets.

View mbilokonsky's full-sized avatar

Mykola Bilokonsky mbilokonsky

View GitHub Profile
@mbilokonsky
mbilokonsky / gist:4325454
Created December 18, 2012 06:03
sample composition OOP in JS
function Task(name) {
var self = this;
self.getName = function() { return name; }
self.getAsigner = function() { return 'Frank'; }
self.getAssignee = function() { return 'Joe'; }
self.foo = function() { return 'bar'; }
}
function TimedTask(name, startTime) {
var self = this;
$ exterminate
[6160:-1397648704:0327/123247:ERROR:master_preferences.cc(110)] Failed to read master_preferences file at /Library/Google/Google Chrome Master Preferences. Falling back to default preferences.
[6160:-1397648704:0327/123248:ERROR:extension_prefs.cc(1540)] Bad or missing pref 'version' for extension 'aohghmighlieiainnegkcijnfilokake'
[6160:-1397648704:0327/123248:ERROR:extension_prefs.cc(1540)] Bad or missing pref 'version' for extension 'apdfllckaahabafndbhieahigkjlhalf'
[6160:-1397648704:0327/123248:ERROR:extension_prefs.cc(1540)] Bad or missing pref 'version' for extension 'pjkljhegncpnkpknbcohdijeoejaedia'
[6160:-1397648704:0327/123248:ERROR:extension_prefs.cc(1540)] Bad or missing pref 'version' for extension 'coobgpohoikkiipiblmjeljniedjpjpf'
[6160:-1397648704:0327/123248:ERROR:extension_prefs.cc(1540)] Bad or missing pref 'version' for extension 'blpcfgokakmgnkcojhhkbfbldkacnbeo'
@mbilokonsky
mbilokonsky / gist:5880505
Created June 27, 2013 21:19
I'm not able to pull down my themes from siteleaf using the ruby app.
$ siteleaf pull theme
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open-uri.rb:129:in `open_uri': invalid access mode r:UTF-8 (URI::HTTPS resource is read only.) (ArgumentError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open-uri.rb:518:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open-uri.rb:30:in `open'
from /Library/Ruby/Gems/1.8/gems/siteleaf-0.9.6/bin/siteleaf:92:in `get_theme_assets'
from /Library/Ruby/Gems/1.8/gems/httparty-0.11.0/lib/httparty/response.rb:57:in `each'
from /Library/Ruby/Gems/1.8/gems/httparty-0.11.0/lib/httparty/response.rb:57:in `send'
from /Library/Ruby/Gems/1.8/gems/httparty-0.11.0/lib/httparty/response.rb:57:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/siteleaf-0.9.6/bin/siteleaf:88:in `get_theme_assets'
from /Library/Ruby/Gems/1.8/gems/siteleaf-0.9.6/bin/siteleaf:155
@Test
public void test_int_to_long_stuff() {
int x = 10;
int y = 20;
ByteBuffer buffer = ByteBuffer.allocate(8);
buffer.putInt(x).putInt(y);
Assert.assertFalse(buffer.hasRemaining()); // confirm I used all 8 bytes
buffer.position(0);

Keybase proof

I hereby claim:

  • I am mbilokonsky on github.
  • I am mykola (https://keybase.io/mykola) on keybase.
  • I have a public key whose fingerprint is 7C32 022F AA84 89E2 ABCE 0290 6418 45B1 7F4E 733A

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am mbilokonsky on github.
* I am mykola (https://keybase.io/mykola) on keybase.
* I have a public key whose fingerprint is DC16 7BFB 87BC E4F4 8D24 6A7F 201F 537E 81DD 64D7
To claim this, I am signing this object:
object Application extends Controller with securesocial.core.SecureSocial {
// this won't compile, what am I missing?
def index = SecuredAction { implicit request =>
Assets.at("/public", "index.html").apply(request)
}
// when I route to this, it works
def unprotectedIndex = Assets.at("/public", "index.html")
In Defense of April Fool's Day
Long ago, when people were afraid of demons and ghosts, they started celebrating All Hallow's Eve by dressing up as those things that they feared most. Before that, they'd make sacrifices to appease the gods or devils. We see this motif time and time again - Japanese oni masks worn by priests, the running of the bulls, hell even Greek Tragedy are all attempts by humans to conquer and bind the sublime terror of their times.
When your culture is uneasy about something, you face that fear by celebrating it and binding it in ritual.
To me, April Fool's Day is not merely some day when people lie on the internet; it's in fact a day when we celebrate the greatest fear we all have on the internet, broken information.
By setting aside a day to make shit up and try to convince people of it, we're participating in a human tradition that goes back as far as civilization itself. We're laughing at the devil, owning our weakness and building a bulwark against the void.
@mbilokonsky
mbilokonsky / gist:83bf6b7357323d97737f
Created May 8, 2015 17:09
Is there any reason that this would be hard? Seems really straightforward, right?
Y'all I've been thinking about something. Javascript is great, right? But writing testable javascript is kinda hard. On the one hand, you want to close over your functions so that they don't leak all over your global namespace. On the other hand, once you've done that you can't test any of the functions you've closed over. This is a huge problem!
```
var computedValue = (function foo(injectedArgument) {
var myLocalVar = 123;
function someSiblingFunction() {
console.log("hey this was called, cool.");
}
@mbilokonsky
mbilokonsky / gist:d4e578b5a1c6628ba66b
Created May 8, 2015 17:10
This should work, right?

Y'all I've been thinking about something. Javascript is great, right? But writing testable javascript is kinda hard. On the one hand, you want to close over your functions so that they don't leak all over your global namespace. On the other hand, once you've done that you can't test any of the functions you've closed over. This is a huge problem!

var computedValue = (function foo(injectedArgument) {
  var myLocalVar = 123;
  
  function someSiblingFunction() {
    console.log("hey this was called, cool.");
  }