Skip to content

Instantly share code, notes, and snippets.

@havenwood
havenwood / cheating.rb
Created August 30, 2014 23:28
Klass Module
module Klass
def self.new *args, &block
object = Class.allocate
object.send :initialize, *args, &block
object
end
end
Cat = Klass.new do
attr_reader :name, :age
@Zehkul
Zehkul / Convert Script – README.md
Last active March 17, 2025 10:39
Script to quickly convert and crop videos from within mpv

#README:

This script for mpv intends to offer the fastest and simplest way to convert parts of a video—while you’re watching it and not really more work intensive than making a screenshot. A short demonstration: https://d.maxfile.ro/omdwzyhkoa.webm

##Installation:

You need:

  • yad (at least 0.26) (AUR)
@whylom
whylom / README.md
Last active August 29, 2015 13:57
Superhash!

Superhash!

A wrapper for Hash that lets you access keys via dynamic methods (like Ruby's OpenStruct) but also:

  • works recursively
  • also lets you use Hash methods like [] and keys

Example

@rthbound
rthbound / animated_moon.rb
Last active August 29, 2015 13:57
Make a gif of the Moon as seen from Earth for one lunar year, starting now - http://gfycat.com/SilverPositiveBluet
require "usno/imagery"
require "open-uri"
require "RMagick"
include Magick
def animate(n,f)
i=0
time = Time.now
@aurelienpierre
aurelienpierre / Winetricks
Last active May 30, 2017 23:02
Creates a complete fake Windows 7 installation within a Wine Prefix in one command
#!/bin/bash
winetricks ie8 wmp10 allcodecs d3dx11_43 dotnet40 vc2005 vc2008 dsound ogg allfonts hosts ddr=opengl fontsmooth=rgb videomemorysize=2048 win7 glsl=enabled ao=enabled rtlm=auto psm=enabled mwo=force fontsmooth=rgb vsm=hardware
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 10, 2025 09:21
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@dconnolly
dconnolly / README.md
Last active December 11, 2024 09:10
All 100 Chromecast background images that are rotated through, linked to their original locations on Google hosting. Links to 2560 width versions, where available.
@whylom
whylom / to_hash.rb
Last active December 25, 2015 20:19
Array#to_hash converts an array of instances into a hash using the provided pair of methods to determine the key & value of each row
# example class
class State < Struct.new(:name, :code)
def self.all
[
State.new('Alabama', 'AL'),
State.new('Alaska', 'AK'),
State.new('Arizona', 'AZ')
]
end
end
@marianposaceanu
marianposaceanu / rvm_alternatives.md
Last active December 19, 2015 04:09
RVM Alternatives

RVM Alternatives

We have two tiers of RVM alternatives :

tier 1

Here we have the inception of the minimalistic, one thing and do it well tool with no magic, following the UNIX philosophy.

Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production. Put rbenv to work with Bundler for painless Ruby upgrades and bulletproof deployments. [0]

@whylom
whylom / README.md
Last active December 17, 2015 19:49
Ruby script that enhances the standard `git branch` listing by organizing and color coding remotes (origin, root, etc).

This is a Ruby script that enhances the standard git branch listing by organizing and color coding remotes (origin, root, etc).

screenshot

  • Branches whose remote is origin (the default) are listed at the top.
  • Branches whose remote is not origin are listed next, with the remote displayed in magenta. This makes it easier to see branches that are shared with other developers.
  • A hardcoded list of staging branches are displayed at the bottom in gold.