Skip to content

Instantly share code, notes, and snippets.

@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 == "" }
def perform(url, rules, file_name)
response = Net::HTTP.get_response(URI.parse(url))
doc = Hpricot(response.body)
file = File.open(file_name, "a")
rules.each do |rule|
(doc/rule).each do |element|
file.puts element.inner_html
end
end
file.close
using System;
using System.Net;
using System.Text;
using System.IO;
namespace MadMimi
{
class Program
{
const string MAD_MIMI_USER_NAME = "YOUR MAD MIMI LOGIN";
using System;
using System.IO;
using System.Text;
using System.Net;
namespace MadMimi
{
class Program
{
static string apiKey = "YOUR MAD MIMI API KEY";
package Revamp::Mail::MadMimiMail;
use Switch;
use HTTP::Request::Common;
use LWP::UserAgent;
use YAML;
use Data::Dumper;
sub new {
my ($class, @args) = @_;
<?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 :-)
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 / 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]) {
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 / 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";