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
a = {a: [:b, :c], b: [:c]} | |
def get_edges(sm) | |
res = [] | |
sm.each do |s, e| | |
e.each do |d| | |
res.push([s,d]) | |
end | |
end | |
res |
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
CREATE EXTENSION IF NOT EXISTS plpythonu; | |
CREATE FUNCTION py_create_ed25519_keypair () | |
RETURNS varchar[] | |
AS $$ | |
import axolotl_curve25519 as curve | |
import os | |
import base64 | |
randm32 = os.urandom(32) |
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
Verifying my Blockstack ID is secured with the address 15e4krfMSXCgWrRpo2FnVRy7DLQ7HuMBQm https://explorer.blockstack.org/address/15e4krfMSXCgWrRpo2FnVRy7DLQ7HuMBQm |
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 'sshkit' | |
require 'sshkit/dsl' | |
# Once "bundle install" has been run, this script can be run as "ruby deploy.rb staging" or "ruby deploy.rb prod" | |
if ARGV.first == "prod" | |
servers = ['deploy@prod1.example.com', 'deploy@prod2.example.com'] | |
elsif ARGV.first == "staging" | |
servers = ['deploy@staging.example.com'] | |
else |
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
#!/usr/bin/python | |
# You need stereovision package to run this. Try "sudo pip install stereovision" | |
import cv2 | |
from stereovision.blockmatchers import StereoBM, StereoSGBM | |
from stereovision.calibration import StereoCalibration | |
from stereovision.stereo_cameras import CalibratedPair | |
from stereovision.ui_utils import STEREO_BM_FLAG, BMTuner |
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
# Allows you to build a Hash in a fashion very similar to Builder. Example: | |
# Fork of https://gist.github.com/360506 by BrentD with some enhancements | |
# | |
# HashBuilder.build! do |h| | |
# h.name "Nilesh" | |
# h.skill "Ruby" | |
# h.skill "Rails" # multiple calls of the same method will collect the values in an array | |
# h.location "Udaipur, India" do # If a block is given, first argument will be set as value for :name | |
# h.location do | |
# h.longitude 24.57 |
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
# TODO | |
# if a var has a value, it also needs a name. This should not be necessary. Variable.initialize should accept hashargs | |
# Expression.to_s should output in infix-notation (like normal humans) | |
# add more syntactic sugar by manipulating Ruby Numeric classes. Add symbolic operators to Ruby's Numeric | |
# If symbolic expression contains variables without value then it should return nil (should it, really?) | |
# Implement additional operators like ** | |
# All symbolic expression should be automatically simplified when created: | |
# cons(0) * x # => 0 | |
# 2 + x + 1 # => x + 3 | |
# -(x-y) + 2*x # => x + 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
# My attempt to implement a simple virtual machine with a minimal instruction set | |
# 8-bit computer, fixed-size memory, single cpu, 0-registers, based on von-neumann architecture | |
# No support for interrupts or I/O although we cheat and provide a "print" instruction :) | |
# The goal is to find a minimal, but turing-complete, instruction set | |
# For simplicity, every instruction has two operands, which are located adjacent to it in the memory | |
# This code is just to experiment with various instruction sets and not to be taken seriously | |
# Next fun step would be to develop a language/compiler for this virtual machine | |
class Memory | |
def initialize(size, program) |
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 ActiveRecord | |
module ConnectionAdapters | |
class MysqlAdapter | |
alias __native_database_types_enum native_database_types | |
def native_database_types #:nodoc | |
types = __native_database_types_enum | |
types[:enum] = { :name => "enum" } | |
types | |
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
#!/usr/bin/env ruby | |
#Example usage: mmacmd.rb basicrock 120 4 Bm Bm A A G Em Bm Bm | |
#MMA Website is here: http://www.mellowood.ca/mma/index.html | |
groove = ARGV.slice!(0) | |
tempo = ARGV.slice!(0) | |
count = ARGV.slice!(0) | |
puts "Generating MMA file" | |
File.open("/tmp/mmaout.mma","w") { |f| |