Skip to content

Instantly share code, notes, and snippets.

View TikiTDO's full-sized avatar

TikiTDO TikiTDO

  • Toronto, Canada
View GitHub Profile
@TikiTDO
TikiTDO / blank.rb
Last active August 29, 2015 14:03
Blank ruby class
class Blank
core_methods = %w(__id__ __send__ object_id instance_eval methods class nil? is_a?
respond_to?)
instance_methods.each {|m| undef_method(m) unless core_methods.include?(m.to_s)}
def respond_to_missing?
true
end
def method_missing(name, *args, &block)

Login:

Google Cloud Storage

You'll want to login using an official Google account (i.e. if this is for your company, use the comapany Gmail account vs. a personal one.)

When logging in, you might be prompted to verify the account; if so, enter your cell number to get a verification e-mail or phone call.

Once verified, you'll have to agree to the terms of service; do that, and click continue.

@TikiTDO
TikiTDO / aceify.js
Last active August 29, 2015 14:07
Aceify Script
/**
* Allows you to aceify any element, though it's intended for textareas.
* Useful for sites that insist on providing plain HTML textareas for entering structured data.
* Based on https://gist.github.com/duncansmart/5267653
*
* Usage:
* $.getScript('https://cdn.rawgit.com/TikiTDO/6033a7e7d61ad59b8c2c/raw/0765886a28499e923648a940be963dabdc0161f0/aceify.js')
* $('textarea').aceify('markdown') // Defaults to javascript if not specified
**/
@TikiTDO
TikiTDO / log_op.rb
Last active August 29, 2015 14:07
Logs the code in a block, and the result it produced
require 'sourcify'
class Binding
def log_op(&block)
result = nil
source = block.to_source strip_enclosure: true
result = self.eval source
puts "Command: #{source} Returned: #{result}"
result
end
@TikiTDO
TikiTDO / tree.slim
Created October 18, 2014 11:24
Auto-conneting trees and stuff
scss:
.node_top {
display: block;
border: 1px dotted black;
margin: auto;
}
.node {
display: table-cell;
vertical-align: top;
@TikiTDO
TikiTDO / poly_int_type.rb
Last active August 29, 2015 14:08
Fixes to make poly int type work with where requests
module PolymorphicIntegerWhere
class Railtie < Rails::Railtie
initializer "PolymorphicInteger.active_record" do
::PolymorphicIntegerType::Extensions::ClassMethods.class_eval do
prepend ForcePolymorphicInteger
end
::ActiveRecord::Associations::BelongsToPolymorphicAssociation.class_eval do
prepend InjectBelongsToPolymorphicAssociation
end
require 'rubygems'
require 'pry'
require 'awesome_print'
data = [
[%q{Janez Drnovšek}, %q{12th President of Yugoslavia, 2nd President of Slovenia}],
[%q{Gene Baur}, %q{Activist}],
[%q{H. Jay Dinshah}, %q{Activist}],
[%q{Casey Affleck}, %q{Actor}],
[%q{Alec Baldwin}, %q{Actor}],
@TikiTDO
TikiTDO / jsPlumb.getOffsetFix.js
Last active August 29, 2015 14:18
Fixes the jsPlumb getOffset function to ignore parent element scroll offsets.
// Fixes the jsPlumb getOffset function to ignore parent element scroll offsets.
// Note - This is a hack. It may have unintended side-effects including
// breaking your page, your computer, and/or your universe.
jsPlumbInstance.prototype.getOffset = function(el, relativeToRoot) {
var current_element, container, out, parent_element;
// Initialization
current_element = jsPlumb.getDOMElement(el);
container = this.getContainer();
out = {
@TikiTDO
TikiTDO / five_problems.rb
Last active August 29, 2015 14:21
My solutions to the "Five programming problems every Software Engineer should be able to solve in less than 1 hour"
# https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
def sum_a(list)
sum = 0
for item in list
sum += item
end
return sum
end
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;