This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// glfw + libao + libav*: video player outline. | |
// too simple for a real video player, too complex for a libav demo. (ffmpeg has it's own ways to output, see libavdevice/*) | |
// gcc av.c -o av -lav{util,format,codec,util} -lsw{scale,resample} -l{ao,epoxy,glfw,pthread} | |
#include <libavcodec/avcodec.h> | |
#include <libavformat/avformat.h> | |
#include <libavutil/imgutils.h> | |
#include <libswscale/swscale.h> | |
#include <libswresample/swresample.h> | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'madness' # https://gist.github.com/pumbur/2df08af2ad846ace75fa | |
need 'prime', 'bigdecimal/math', 'matrix' | |
{:prm=>Prime,:mth=>Math,:vec=>Vector,:mat=>Matrix}.each{|n,k| Kernel.class_alias(n,k) } | |
Num.act :sqrt, ->{ Math.sqrt(self) }, | |
:cbrt, ->{ Math.cbrt(self) }, | |
:sin, ->{ Math.sin(self) }, | |
:cos, ->{ Math.cos(self) }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def main?; (TOPLEVEL_BINDING.eval('self')==self) rescue (self.inspect=='main') end | |
def main_eval(&b); (main? ? Kernel : self).module_eval(&b); end | |
def aka(q); main_eval{ q.each{|k,v| alias_method(k,v) }}; end | |
def act(*q); main_eval{ q.each_slice(2){|a,b| define_method(a,&b) }}; end | |
def slf(*q); main_eval{ q.each_slice(2){|a,b| define_singleton_method(a,&b) }}; end | |
def to_sym; to_s.to_sym; end | |
def self; self; end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
require 'oj' | |
class Object | |
def ary?; self.is_a?(Array); end | |
def hsh?; self.is_a?(Hash); end | |
def sym?; self.is_a?(Symbol); end | |
def str?; self.is_a?(String); end | |
def prc?; self.is_a?(Proc); end | |
def num?; self.is_a?(Numeric); end |