Skip to content

Instantly share code, notes, and snippets.

View shelling's full-sized avatar

shelling shelling

View GitHub Profile
require 'formula'
class Github < Formula
homepage 'https://github.com/ingydotnet/git-hub'
url 'https://github.com/ingydotnet/git-hub/archive/perl5-advent-2013.tar.gz'
sha1 'd63e11687579c22e708d327245d0451c981b5904'
head 'https://github.com/ingydotnet/git-hub.git'
def install
system 'make'
%html {
%head {
}
%body {
}
}
#!/usr/bin/env perl6
use v6;
grammar Simple {
rule TOP {
^ <integer> $
};
token integer {
#!/usr/bin/env ruby
require "parslet"
require "pp"
class SimpleParser < Parslet::Parser
rule :top do
integer
end
@shelling
shelling / anagrams.pl
Last active August 29, 2015 14:04
common questions
#!/usr/bin/env perl
use Modern::Perl;
use Data::Dumper;
use Test::More;
sub hash {
my ($string) = shift;
my $hash = {};
for my $c (split(//, $string)) {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char*
itos(int value) {
char* result = malloc(sizeof(char)*100);
sprintf(result, "%d", value);
return result;
}
require "mkmf"
$libs += " -lstdc++ "
create_makefile("human")
(setq h (make-hash-table :test 'equal))
(message "%s" h)
(puthash 'hello "world" h)
(message "%s" h)
(message "%s" (gethash 'hello h))
#!/usr/bin/env ruby
class Node
attr_accessor :data, :left, :right
def initialize(data, left = nil, right = nil)
@data = data
@left = left
@right = right
end
#!/usr/bin/env ruby
def hash(string)
hash = {}
string.each_char do |c|
hash[c] = hash[c].to_i + 1
end
return hash
end