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
#!/usr/bin/env ruby | |
# Remove all gems EXCEPT defaults :) | |
`gem list -d`.split(/\n\n^(?=\w)/).each do |data| | |
match = data.match(/(?<name>([^\s]+)) \((?<versions>.*)\)/) | |
name = match[:name] | |
versions = match[:versions].split(', ') | |
if match = data.match(/^.*\(([\d\.]*),? ?default\): .*$/) | |
next if match[1].empty? # it's the only version if this match is empty |
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
# Automatically print tasks description wrapping the execution of | |
# the task. | |
module Capistrano::Configuration::Namespaces | |
alias_method :_task, :task | |
def task(name, options = {}, &block) | |
desc = next_description | |
full_task_name = [fully_qualified_name, name].compact.join(':') | |
$column = 0 | |
$last_was_after = true |
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
data = File.read('classes.txt') | |
classes = data.split(/^$\n/) | |
classes.each do |klass| | |
name, *methods = klass.split(/:?\n/) | |
Object.const_set(name, Class.new do | |
methods.each do |method| | |
parse = method.match(/(?<name>\w+) \(?(?<arguments>[\w\, ]*)\)? ?-> {(?<body>.*)}/) | |
if parse[:arguments].empty? | |
define_method(parse[:name]) { eval parse[:body] } | |
else |
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
body{-webkit-animation: spin 30s linear infinite;} | |
p:before {content: "Code in Ruby! ";} | |
body, p, body p, body div p {font-family: 'Comic Sans MS', cursive !important;} | |
html {-webkit-animation: rainbow 8s infinite;} | |
@-webkit-keyframes blur { | |
0% { -webkit-filter: blur(0px); } | |
49% { -webkit-filter: blur(0px); } | |
50% { -webkit-filter: blur(1px); } | |
51% { -webkit-filter: blur(0px); } | |
100% { -webkit-filter: blur(0px); } |
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
module AliasMethodizer | |
private | |
def alias_method(alias_name, name, &function) | |
define_method alias_name, -> (*args, &block) do | |
value = method(name)[*args, &block] | |
instance_exec &function if block_given? | |
value | |
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
# From the tty_ioctl man page in Linux. | |
# | |
# TIOCGWINSZ struct winsize *argp | |
# Get window size. | |
# | |
# TIOCSWINSZ const struct winsize *argp | |
# Set window size. | |
# | |
# The struct used by these ioctls is defined as | |
# |
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
#include <SPI.h> | |
#define CHIP_SELECT_PIN 10 | |
void setup() { | |
// Setup SPI communication for the MAX7221. | |
pinMode(CHIP_SELECT_PIN, OUTPUT); | |
SPI.begin(); | |
// Test for 1 second. |
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
void mempack(void **restrict dst, const void *restrict src, size_t n) { | |
memcpy(*dst, src, n); | |
*dst = (char *) *dst + n; | |
} |
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
#include <fcntl.h> | |
#include <sys/types.h> | |
#include <sys/uio.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int roll_dice(int, int); | |
int main(int argc, char const *argv[]) { |
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
#if defined(__APPLE__) | |
#include <OpenGL/gl.h> | |
#include <OpenGL/glu.h> | |
#else | |
#include <GL/gl.h> | |
#include <GL/glu.h> | |
#endif | |
#include <GLUT/glut.h> | |
#include <stdio.h> |