Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
int main(void) {
int8_t ms[] = {
0x50,
0x50,
0x50,
0x50,
import Control.Monad
import Data.List
distinct :: Eq a => [a] -> Bool
distinct [] = True
distinct (x:xs) = case x `elem` xs of
True -> False
False -> distinct xs
multipleDwelling :: [[(String, Integer)]]
import Data.Functor
import Control.Applicative
newtype O f g a = O { unO :: f (g a) }
instance (Functor f, Functor g) => Functor (O f g) where
-- fmap :: (a -> b) -> O f g a -> O f g b
fmap f' o = O $ fmap (\g' -> fmap f' g') $ unO o
instance (Applicative f, Applicative g) => Applicative (O f g) where
require 'devise'
class TestToken
def self.token
@token ||= Devise.friendly_token
end
end
class TestToken2 < TestToken
end
@mmagm
mmagm / Tree.java
Last active August 29, 2015 13:56
import java.util.Stack;
import java.util.Queue;
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayDeque;
import java.util.LinkedList;
public class Tree {
private Node root = null;
@mmagm
mmagm / tree.rb
Last active August 29, 2015 13:56
class Node
attr_accessor :numbers
attr_accessor :children
def initialize
@numbers = []
@children = []
end
end
require 'find'
class Expression
def |(other)
Or.new(self,other)
end
def &(other)
And.new(self,other)
end
class Node
attr_accessor :next
attr_accessor :value
def initialize(value)
@next = nil
@value = value
end
end
class InfiniteCycleEnumerator
def self.enum(num)
Enumerator.new do |y|
idx = 0
loop do
y << idx % num
idx = idx + 1
end
end
end
@mmagm
mmagm / replace-rockets.el
Created December 4, 2012 07:26
replace rockets in ruby
(defun replace-rockets ()
(interactive)
(goto-char (point-min))
(while (re-search-forward ":\\([_A-Za-z0-9]+\\)[\t\n ]+=>" nil t)
(replace-match "\\1:")))