Skip to content

Instantly share code, notes, and snippets.

@marcheiligers
marcheiligers / main.rb
Created Jul 2, 2022
DRGTK Layer Hack
View main.rb
LAYERS = %w[
solids
sprites
primitives
labels
lines
borders
].freeze
class Player
View install_chromium.sh
#!/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
View vm_log.rb
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 Apr 6, 2013
Using http://www.youtube.com/watch?v=B1l5F3KEEBw as inspiration after being sick of modifying all the Devise templates by hand.
View views.rake
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
View gist:4545351
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";
View gist:4539778
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
}
View sample.js
// 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]) {
View more_complex_chunking.rb
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 Jun 14, 2010
Classic ASP VBScript Mad Mimi Sample
View add_to_list.vb
<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
' ------------------------------------------------------------------------------------------------
View gist:428817
<?php
/*
Plugin Name: Mad Mimi Archives Plugin
Plugin URI: http://mimi.fascinationstreet.co.za/mimi_archives.php
Version: 0.01
Author: <a href="http://fascinationstreet.co.za/">Marc Heiligers</a>
Description: A plugin which displays archived newsletters from Mad Mimi in your blog
Distributed under the MIT license. Please don't sue me :-)