Skip to content

Instantly share code, notes, and snippets.

View digitalextremist's full-sized avatar
🏴
demonstrate freedom

//de digitalextremist

🏴
demonstrate freedom
  • .*
  • Northwest
View GitHub Profile
# Acts like an array and receives futures. Will yield them as
# they become ready.
class HackedMultiplexer
include Celluloid
include Enumerable
def initialize
@not_ready = []
end
@digitalextremist
digitalextremist / 0_reuse_code.js
Created May 26, 2016 16:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
module System
extend self
def cpu_count
return Java::Java.lang.Runtime.getRuntime.availableProcessors if defined? Java::Java
return File.read('/proc/cpuinfo').scan(/^processor\s*:/).size if File.exist? '/proc/cpuinfo'
require 'win32ole'
WIN32OLE.connect("winmgmts://").ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors
rescue LoadError
Integer `sysctl -n hw.ncpu 2>/dev/null` rescue 1
end
@digitalextremist
digitalextremist / concurrent_nested_hash.rb
Last active December 16, 2015 08:29 — forked from tarcieri/concurrent_nested_hash.rb
Oldie but a goodie, with more of the standard methods.
require 'celluloid'
class ConcurrentNestedHash
include Celluloid
def initialize( starting = {} ); @outer = starting end
def [](*keys); keys.inject(@outer) { |h,k| h[k] } end
def []=(*args)