Skip to content

Instantly share code, notes, and snippets.

@usure
usure / stackr.rb
Last active August 29, 2015 14:27
stack lang
#!/usr/bin/env ruby
def push(element); $stack << element; end
def pop; $stack.pop end
$stack = []
$dictionary = {
'.' => -> { puts(pop) },
'..' => -> { puts($stack) },
'.,' => -> { pp($dictionary)},
@usure
usure / f.rb
Last active August 29, 2015 14:27 — forked from deadprogram/forth.rb
Forth interpreter in 64 lines of Ruby
#!/usr/bin/env ruby
require 'pp'
def pop; $stack.pop || raise(StackUnderflow); end
def push(expression); $stack << expression; end
def unary; -> { push(yield pop) }; end
def binary; -> { push(yield pop, pop) }; end
def unary_boolean; -> { push(if yield pop then 1 else 0 end) }; end
def binary_boolean; -> { push(if yield pop, pop then 1 else 0 end) }; end
def functions; -> { push(yield pop, pop)}; end
use std::io;
use std::io::prelude::*;
fn main() {
let stdin = io::stdin();
for line in stdin.lock().lines() {
println!("{}", line.unwrap());
break;
}
}

Keybase proof

I hereby claim:

  • I am theshadowfog on github.
  • I am tinsef (https://keybase.io/tinsef) on keybase.
  • I have a public key whose fingerprint is CD9C 0E14 5EB5 69AA 8DC4 05A7 4BD5 F707 EFCC 6E2C

To claim this, I am signing this object:

@usure
usure / stack.lisp
Created January 13, 2014 04:18
A stack in common lisp.
(defparameter *stack*
(list 0))
(defun push-to-stack (&rest args)
"This pushes any number of arguments to the stack."
(dolist (arg args)
(push arg *stack*)
(print "ok")))
(defun pop-stack (&rest args)
@usure
usure / blog.rb
Last active December 31, 2015 00:09
it works
#!/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby
require 'fileutils'
require 'optparse'
require 'redcarpet'
current_time = Time.now
@pdir = "posts"
@output = "/var/www/blog/posts"
@template = "<center>Title:
<br>Date: **#{current_time}**
</center>"
@usure
usure / fib.rb
Created October 22, 2013 13:12
Fibonacci sequence in ruby
a = [1,2]
for i in 0..10
a.push(a[-1] + a[-2])
end
puts a
@usure
usure / index.haml
Created April 5, 2013 23:57
A CodePen by Greg. REEDR
!!! 5
%title = "APP"
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
#header
APP
#menu
<br>
%a{:href => "/"} HOME
|
@usure
usure / 4dl
Last active October 12, 2015 10:27
4chan thread archiver (UPDATED)
#!/bin/bash
[[ $1 =~ .*org* ]] && \
#thread=`echo $1 | cut -c25-`
thread=`echo $1 | sed "s/4chan.org//g" | sed "s/[^0-9]//g;s/^$/-1/;"`
echo $thread
echo "BOARD?"
read board
cd $board
mkdir $thread
@usure
usure / test
Created July 18, 2012 23:57
test
test