Skip to content

Instantly share code, notes, and snippets.

View TikiTDO's full-sized avatar

TikiTDO TikiTDO

  • Toronto, Canada
View GitHub Profile
@TikiTDO
TikiTDO / shelve.slim
Last active May 1, 2016 03:12
SVG diagram for shelf parts
scss:
rect {
stroke-width: 0px;
&.dado {
fill: green;
&.side {
fill: blue;
}
&.two {
@TikiTDO
TikiTDO / sprockets_manifest_directives.js
Created April 20, 2016 11:03
A list of directives that can be used in ruby sprockets manifest files
// Includes one file
//= require name/path[.ext]
// Includes files in one directory, but not nested
//= require_directory path
// Includes all nested files
//= require_tree path
// Adds the requested asset to the list of assets to be compiled
class Thread
class << self
alias_method :old_new, :new
def new(*args, &block)
new_thread = old_new(*args, &block)
new_thread.thread_variable_set(:parent, Thread.current)
return new_thread
end
end
end
@TikiTDO
TikiTDO / webrtc-datachannel-basic.js
Last active March 8, 2018 17:59
Rewrite of the WebRTC DataChannel Basic example, with all the operations grouped together for clarity. Now with links to relevant places in the spec.
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree.
*/
// Original used from: https://github.com/webrtc/samples/blob/750b0ec7675b3326831bb95261b33d0842bc2b39/src/content/datachannel/basic/js/main.js
@TikiTDO
TikiTDO / coin.rb
Created March 16, 2016 04:33
Coin Change Solver
require 'rubygems'
require 'pry'
VALID_COINS = [1, 5, 10, 25, 50]
def change(amount)
change_iter(amount, VALID_COINS).each do |item|
puts item.inspect
end
end
@TikiTDO
TikiTDO / auto_closure.sql
Last active January 14, 2016 03:07
Auto Closure Trigger
CREATE TRIGGER populate_management_relation_closures
AFTER INSERT ON management_relations
FOR EACH ROW
BEGIN
INSERT INTO management_relation_closures(manager_id, reportee_id, depth)
-- Insert the actual manager relation
SELECT NEW.manager_id, NEW.reportee_id, 1
-- Make sure all of the manager's managers know of the new reportee
UNION
SELECT manager_id, NEW.reportee_id, depth + 1 FROM management_relation_closures
#!/bin/bash
# Note: This is a joke. If you actually run this script, then I will laugh, and you will deserve whatever happens.
user=`whoami`
# Must be run as root
if [ $user != 'root' ]; then
echo "This script must be run as root. Aborting."
exit 1;
fi
// VirtualWire.cpp
//
// Virtual Wire implementation for Arduino
// See the README file in this directory fdor documentation
//
// Changes:
// 2008-05-25: fixed a bug that could prevent messages with certain
// bytes sequences being received (false message start detected)
//
// Author: Mike McCauley ([email protected])
tracker = {}
Keywords.all.each do |keyword|
tracker[keyword.user_id] ||= {}
name = keyword.name.strip
if tracker[keyword.user_id][name]
# Is Extra
else
import java.security.Key;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.KeyPair;
import java.security.Security;
import java.security.Signature;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;