Skip to content

Instantly share code, notes, and snippets.

# Stolen from Xenobrain and remixed (https://gist.github.com/xenobrain/5fa64f8a3e8f8f6f1b31eee4f870dd75)
TIME_STEP = 1 / 60 # delta time isn't required in DragonRuby but it really handy for tuning and debugging physics
COLLISION_BIAS = 0.05 # adds some energy into the collision to get objects to separate. tune this in steps of 0.01
COLLISION_SLOP = 0.1 # amount shapes are allowed to overlap without triggering correction. helps avoid position jitter
COLLISION_ITERATIONS = 10 # how many times to run the solver. a good range is between 5 and 15
CIRCLE_RADIUS = 10
CIRCLE_RADIUS_2 = CIRCLE_RADIUS * 2
CIRCLE_RADIUS_SQ = CIRCLE_RADIUS_2**2
@marcheiligers
marcheiligers / main.rb
Created July 2, 2022 01:39
DRGTK Layer Hack
LAYERS = %w[
solids
sprites
primitives
labels
lines
borders
].freeze
class Player
@marcheiligers
marcheiligers / install_chromium.sh
Created August 16, 2016 01:02 — forked from ctrlaltdylan/install_chromium.sh
Install chromium on jessie
#!/bin/bash
wget http://ftp.us.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11_1.5.0-5+deb7u3_armhf.deb
wget http://launchpadlibrarian.net/218525709/chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
wget http://launchpadlibrarian.net/218525711/chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
sudo dpkg -i libgcrypt11_1.5.0-5+deb7u3_armhf.deb
sudo dpkg -i chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
sudo dpkg -i chromium-browser_45.0.2454.85-0ubuntu0.14.04.1.1097_armhf.deb
@marcheiligers
marcheiligers / vm_log.rb
Created November 30, 2014 11:53
SH2ac log
require 'httparty'
require 'nokogiri'
def log(name, url)
time = Time.now
html = HTTParty.get(url)
doc = Nokogiri::HTML(html)
body = (doc/"table tbody")
data = body.children.map { |r| r.children.map { |c| c.text.strip }.join(" ") }.reject { |t| t.nil? || t.to_s.squeeze.strip == "" }
@marcheiligers
marcheiligers / views.rake
Created April 6, 2013 14:57
Using http://www.youtube.com/watch?v=B1l5F3KEEBw as inspiration after being sick of modifying all the Devise templates by hand.
namespace :views do
desc "Converts all .html.erb files in app/views to .html.haml files"
task :hamlize do
Dir.glob('app/views/**/*.erb').each do |file|
begin
puts "Hamlizing #{file}"
`bundle exec html2haml #{file} | cat > #{file.sub(/(\.html)?\.erb$/, '.html.haml')} && rm #{file}`
rescue => e
puts "Error in #{file}: #{e.message}"
end
@marcheiligers
marcheiligers / gist:4545351
Last active December 11, 2015 04:28 — forked from sruli/gist:4545272
addLoadEvent(function() {
var dropdowns = form.getElementsByTagName("select");
for(var i = 0; i < dropdowns.length; ++i) {
dropdowns[i].onchange = (function() {
var dropdown = dropdowns[i];
return function() {
if(dropdown.value != "") {
if(document.getElementsByClassName(dropdown.id).length == 0) {
var input = document.createElement("input");
input.type = "hidden";
public static void CallAPI(ParamType param)
{
var resetServicePoint = false;
var origSecurityProtocol = System.Net.ServicePointManager.SecurityProtocol;
try
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
resetServicePoint = true;
// Make your API call here
}
@marcheiligers
marcheiligers / sample.js
Created February 21, 2012 10:10
JS Memoization
// Simple memoization which only handles a single argument
// There's lots of things wrong with this code,
// like that it doesn't handle falsy values, for example.
// See below for a good discussion on memoization:
// http://addyosmani.com/blog/faster-javascript-memoization
Function.prototype.memoize = function() {
var fn = this,
cache = {};
return function(arg) {
if(!cache[arg]) {
require 'rubygems'
require 'httparty'
class MadMimi
include HTTParty
base_uri 'http://api.madmimi.com/'
def self.import(username, api_key, csv_data)
attempts = 0
success = false
@marcheiligers
marcheiligers / add_to_list.vb
Created June 14, 2010 12:00
Classic ASP VBScript Mad Mimi Sample
<html>
<body>
<%
' Mad Mimi api details
Const MAD_MIMI_USERNAME = ""
Const MAD_MIMI_API_KEY = ""
Const MAD_MIMI_API_URL = "http://api.madmimi.com"
' A mini Mimi API lib
' ------------------------------------------------------------------------------------------------