Skip to content

Instantly share code, notes, and snippets.

View gist:6262076
view(:local_variable => "a", :cond => false) do
~ div do
~ local_variable
end
~ content_tag("span")
if cond
~ div("true")
else
View gist:6105848
def render(buffer, algorithm = "dot", format = "png")
png_buffer = ""
graph_buffer = buffer.dup.force_encoding("BINARY")
png_pipe_ruby = nil
png_pipe_render = nil
graph_pipe_render = nil
graph_pipe_ruby = nil
pid = nil
status = nil
View gist:6098560
<!DOCTYPE html>
<html>
<head>
<script>
!function(){this.Shape=function(){function Shape(){}Shape.prototype.rotated=null;Shape.$shapeTemplates=[{rotated:7,blocks:["TL","TC","MR"],color:"red"},{rotated:8,blocks:["TC","TR","ML"],color:"lime"},{rotated:9,blocks:["ML","MR","BC"],color:"#aa00ff"},{rotated:3,blocks:["TL","TC","ML"],color:"yellow"},{rotated:12,blocks:["ML","BL","MR"],color:"orange"},{rotated:15,blocks:["ML","BR","MR"],color:"blue"},{rotated:18,blocks:["ML","MR","MSR"],color:"cyan"},{rotated:0,blocks:["TC","ML","BL"],color:"red"},{rotated:1,blocks:["TC","MR","BR"],color:"lime"},{rotated:10,blocks:["TC","MR","BC"],color:"#aa00ff"},{rotated:11,blocks:["TC","ML","MR"],color:"#aa00ff"},{rotated:2,blocks:["TC","ML","BC"],color:"#aa00ff"},{rotated:13,blocks:["TC","BC","BR"],color:"orange"},{rotated:14,blocks:["TR","ML","MR"],color:"orange"},{rotated:4,blocks:["TL","TC","BC"],color:"orange"},{rotated:16,blocks:["TR","TC","BC"],color:"blue"},{rotated:17,blocks:["TL","ML","MR"],color:"blue"},{rotated:5,b
View gist:6095344
SlashAdmin.register model do
# Creates a controller for specified model.
# Returns new controller.
# Preferred form in autoloading environments is
# AdminFooController = SlashAdmin.register Foo
#
# Verbose form is also available:
# class AdminFooController < SlashAdmin::Controller
# admin Foo
View gist:4608801
#!/usr/bin/env ruby
require "chunky_png"
#require "oily_png"
def screenshot(display = ":0")
mine_pipe, xwd_pipe = IO.pipe
png = nil
begin
@grindars
grindars / watchdogd.conf
Created Jan 15, 2013
watchdogd initscript
View watchdogd.conf
# /etc/sysconfig/watchdogd
WATCHDOGD_OPTIONS="itusbwdt"
View xinitrc.sh
#!/bin/sh
xset s off
xset -dpms
if [ -f "$HOME/.monitors" ] && [ ! -f "$HOME/.calibration_data" ]; then
echo "Assuming incorrect monitor selection."
rm -f "$HOME/.monitors"
fi
View gist:4516599
X.Org X Server 1.10.6
Release Date: 2012-02-10
[ 288.456] X Protocol Version 11, Revision 0
[ 288.458] Build Operating System: x86-004 2.6.18-308.1.1.el5
[ 288.460] Current Operating System: Linux localhost.localdomain 2.6.32-279.el6.i686 #1 SMP Wed Jun 13 18:23:32 EDT 2012 i686
[ 288.462] Kernel command line: ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM 8250.nr_uarts=5 drm_kms_helper.poll=0 quiet quiet
[ 288.466] Build Date: 28 March 2012 03:02:31PM
[ 288.468] Build ID: xorg-x11-server 1.10.6-1.el6
[ 288.470] Current version of pixman: 0.18.4
[ 288.471] Before reporting problems, check https://www.redhat.com/apps/support/
@grindars
grindars / steam_bootstrap.sh
Created Dec 7, 2012
Steam installer for Debian
View steam_bootstrap.sh
#!/bin/bash
#
# Steam installer for Debian wheezy (32- and 64-bit)
#
# Place into empty directory and run.
#
download() {
local url="$1"
local filename="$(basename "$url")"
@grindars
grindars / extract.rb
Created Oct 9, 2012
FON file splitter
View extract.rb
#!/usr/bin/env ruby
require "fileutils"
module MachineIO
def read_word
read(2).unpack("v")[0]
end
def read_dword