This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MicroQuery | |
{ | |
public static function configure($configuration) | |
{ | |
// configure ruckusing db adapter | |
self::$adapter = null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log navigator.serviceWorker.controller | |
navigator.serviceWorker.register('/worker.js') #, scope: 'path' | |
.then (reg) -> | |
console.log '◕‿◕', reg | |
, (err) -> | |
console.log 'ಠ_ಠ', err | |
# credit: https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/post-message/index.html | |
@sendMessage = (message) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "defines" | |
global.active_turret_range_entities = {} | |
global.nearby_turret_map = {} | |
local function draw_turret_range(turret_type, sx, sy, r) | |
-- what is this voodoo? | |
local function round(x) | |
return x + 0.5 - (x + 0.5) % 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WhiteHat101 | |
module Mean | |
def mean | |
inject(0.0, :+) / length | |
end | |
alias avg mean | |
alias average mean | |
def mean_absolute_deviation | |
mean = self.mean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WhiteHat101 | |
class Circle | |
attr_accessor :origin, :radius | |
def initialize origin = [0,0], radius = 0 | |
@origin = origin | |
@radius = radius | |
end | |
def self.origin_point origin, point | |
radius = Math.sqrt origin.zip(point) | |
.map {|a,b| (a - b)**2 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vector2D | |
include Math | |
attr_accessor :x, :y | |
def self.magnitude_angle magnitude, angle | |
x = magnitude * cos(angle*PI/180) | |
y = magnitude * sin(angle*PI/180) | |
new x, y | |
end | |
def initialize x, y | |
@x = x; @y = y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RealStdOut = $stdout | |
# Replace the main thread's $stdout and $stderr with IO.pipes | |
# Create a thread to watch for data on the pipes | |
# call given block with IO name, timestamp, and data read from IO | |
def redirect_stdout_and_stderr_to &callback | |
rout, $stdout = IO.pipe | |
rerr, $stderr = IO.pipe | |
map = { rout => 'stdout', rerr => 'stderr' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include Process | |
# puts " ROOT: #{pid} of #{ppid}" | |
# at_exit { puts " EXIT: #{pid} of #{ppid}" } | |
$running = true | |
$workers = [] | |
def start_worker | |
$workers << fork do | |
Signal.trap "INT", "DEFAULT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'set' | |
class SingleChannel | |
def initialize id | |
@id = id | |
@sockets = Set.new | |
end | |
def push ws | |
@sockets << ws | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wordlist on most Ubuntu Installs | |
open '/usr/share/dict/american-english' do |list| | |
until list.eof? | |
word = list.gets.chomp | |
next unless word.match /^[A-Za-z]+$/ | |
value = word.upcase.split(//).inject(1) do |sum,v| | |
sum *= v.ord - 'A'.ord + 1 | |
end | |
# puts "#{word} = #{value}" |
OlderNewer