Skip to content

Instantly share code, notes, and snippets.

package Magento;
use v5.14;
use warnings;
use Carp;
use XML::RPC;
sub new {
my ($class,$uri,$user,$pass) = @_;
my $client = XML::RPC->new("$uri/api/xmlrpc/");
@tron1point0
tron1point0 / Makefile
Created June 7, 2012 00:07
Youtube thingie
VERSION := 4.1.0
ZIPFILE := ext-$(VERSION)-gpl.zip
download := http://cdn.sencha.io/$(ZIPFILE)
downloader := $(shell which curl)
downloader ?= $(shell which wget)
COFFEE := $(shell which coffee)
UNZIP := $(shell which unzip)
#include <stdlib.h>
#define lc(var) (var >= 'A' && var <= 'Z' ? var + 32 : var)
#define uc(var) (var >= 'a' && var <= 'z' ? var - 32 : var)
#define vowelp(var) ( \
uc(var) == 'A' || \
uc(var) == 'E' || \
uc(var) == 'I' || \
uc(var) == 'O' || \
uc(var) == 'U')
@tron1point0
tron1point0 / fizzbuzz.hs
Created June 19, 2012 01:14
Point-free style, monads, arrows, and a partridge in a pear tree
import Control.Monad
import Control.Arrow
import Data.Monoid
import Data.List(unlines)
import System.Environment(getArgs)
fizzbuzz = uncurry (flip maybe id) . (arr show &&& arr forb)
where tests = map ((.) (==0) . flip mod) [3,5]
fb = map Just ["Fizz","Buzz"]
@tron1point0
tron1point0 / keymap.pl
Created September 24, 2012 04:50
Generates a keyboard map given a list of keybinds
#!/usr/bin/env perl
use strict;
use warnings;
use Template::Toolkit::Simple;
use YAML qw(Load);
my %config = Load do {local $/;<DATA>};
@tron1point0
tron1point0 / NBT.pm
Created October 10, 2012 00:43
NBT parser
#!/usr/bin/env perl
package NBT;
use strict;
use warnings;
sub parse {
my ($fh) = @_;
(function() {
var color_stuff = function(selector,classes) {
var nth_of_type = function(len,i) {
return ':nth-of-type(' + len + 'n+' + i + ')'
};
var nested = function(c) {
return function() {
var cs = classes.filter(function(e) { return e !== c });
for (var i = 0; i < cs.length; i++)
$(this).children(selector + nth_of_type(cs.length,i))
@tron1point0
tron1point0 / Makefile
Created February 26, 2014 23:47
Merge multiple arrays.
merge: merge.c
$(CC) -std=c89 -Wall $^ -o $@
clean:
-rm merge
@tron1point0
tron1point0 / knapsack.hs
Created May 8, 2014 20:02
Bounded knapsack problem
import Data.List
type Weight = Int
type Value = Int
type Item = (String,Weight,Value)
type Pack = ([String],Weight,Value)
knapsack :: (Pack -> Bool) -> [Item] -> [Pack]
knapsack f = sortBy (value) . filter (f) . map (foldl (pack) ([],0,0)) . tail . subsequences
where value (_,_,v1) (_,_,v2) = compare v2 v1
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Formatter;
public class Machine {
private Tape<Integer>[] tapes;
private int[] memory;
private final int scratch; // index of the scratch tape