Skip to content

Instantly share code, notes, and snippets.

View DrummerHead's full-sized avatar
💭
Eternally Elated

DrummerHead DrummerHead

💭
Eternally Elated
View GitHub Profile
@DrummerHead
DrummerHead / quo.rb
Created February 24, 2014 02:06
My first Quine
c=["p", "r", "i", "n", "t", "\"", "c", "=", "\"", ";", "p", " ", "c", ";", "c", ".", "e", "a", "c", "h", "{", "|", "c", "|", "p", "r", "i", "n", "t", " ", "c", "}"]
print"c=";p c;c.each{|c|print c}
@DrummerHead
DrummerHead / reddit_comments_order.rb
Last active December 18, 2015 05:49
Get a list of your last 1000 reddit comments, ordered by score. Useful for storage and to actually order your posts by score, since reddit can't currently do so. Put your username as argument (or just wait for it to be asked) and get a lovely html file!
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
# Ask for name and check if it exists
args = ARGF.argv
if args.empty?
puts "Type the name of the reddit user:"
@DrummerHead
DrummerHead / map_processing.rb
Created June 8, 2013 05:13
Ruby implementation of Processing's map function
# Ruby implementation of Processing's map function
# http://processing.org/reference/map_.html
def map(value, v_min, v_max, d_min, d_max) # v for value, d for desired
v_value = value.to_f # so it returns float
v_range = v_max - v_min
d_range = d_max - d_min
d_value = (v_value - v_min) * d_range / v_range + d_min
end
@DrummerHead
DrummerHead / scrape_yourscenesucks.rb
Created May 22, 2013 23:35
Get a list of all the 'scenes' and links to the music related to the scene
require 'nokogiri'
require 'open-uri'
# Scarpe the site and aquire a lovely array
doc = Nokogiri::HTML(open('http://www.dobi.nu/yourscenesucks/left2.htm'))
root = 'http://www.dobi.nu/yourscenesucks/'
scene_links = []
#!/usr/bin/ruby
# requires: jpegtran and pngcrush
# brew install libjpeg
# brew install pngcrush
#
# "crushimg" on a directory will look for jpg and png files, compress them using
# jpegtran and pngcrush and return a new file with an "-optimized" suffix.
# it will not traverse the child directories (not recursive)
#
@DrummerHead
DrummerHead / loggy
Last active December 15, 2015 08:49
Get a lovely string that resumes what you've been working on
#!/Users/dh/.rvm/rubies/ruby-1.9.3-p362/bin/ruby -w
magia = %x[git log --pretty=oneline --no-merges --author=DrummerHead --since='yesterday']
unless magia.empty?
magia.gsub!(/^\w* /, "").gsub!(/\n/, "; ")
puts magia
else
puts "Gotta worky work!"
end
@DrummerHead
DrummerHead / steamGamesReview.js
Last active December 11, 2015 01:18
Too many Steam Games bought that you may don't even know about? Use this script to get YouTube and Metacritic reviews and get to know what they are all about.
// Go to http://steamcommunity.com/id/{{USERNAME}}/games/?tab=all&sort=name
// for example: http://steamcommunity.com/id/DrummerHead/games/?tab=all&sort=name
// now copy and paste this into your console:
// ( what is a console? http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers )
var games = document.querySelectorAll('.gameListRowItemName');
var engines = {
youtube : function(query) {
@DrummerHead
DrummerHead / servo.rb
Last active October 10, 2015 05:18
Lean UX Crowd-Sourced User-Validated Synergized Ruby Server for Lean Localhost testing
require 'webrick'
include WEBrick
class NonCachingFileHandler < HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
res['Expires'] = Time.now - 100**4
@DrummerHead
DrummerHead / gist:2795222
Created May 26, 2012 20:33
MS ASQ Query to find songs related to a word
filename:query kind:music NOT kind:folder NOT kind:m3u
@DrummerHead
DrummerHead / hideliminator.js
Created May 20, 2012 21:05
Just to show a comrade to debug this stuff
/* - These is a javascript snippet to be used with
http://mcdlr.com/js-inject/ - */
/* - Hideliminator - Any website - *\
|* - Hide elements on command - *|
\* - v1.0 - */
var h1d3l1m1n4t04 = {