Skip to content

Instantly share code, notes, and snippets.

Michael Nutt mnutt

Block or report user

Report or block mnutt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:4219
def search(*args)
params = {:id => content_ids}
if Hash === args.last
if args.last[:conditions]
args.last[:conditions].merge!(params)
else
args.last[:conditions] = params
end
else
args << {:conditions => params}
View test.rb
def hello
puts "this is a test"
end
View code_kata_4.rb
#!/usr/bin/env ruby
# Kata #4: Football Data
def smallest_spread(file)
weather_data = File.open(file).readlines
temp_spread = weather_data.map {|line|
next unless line.match(/\s([A-Za-z_]+).*?(\d+)\s\s-\s\s(\d+)/)
day, max, min = $1, $2.to_i, $3.to_i
View bridge features.txt
== Bridge Features ==
System
* shutdown() - shutdown limewire
-- org.limewire.core.api.Application::stopCore()
* restart() - restart limewire
-- org.limewire.core.api.Application::startCore() ?
* setOption() - change a configuration option
-- #TODO
* getOption() - retrieve a configuration option
View bridge api.txt
== Bridge API ==
=== Requests ===
A bridge command is written in YAML, in the following format:
Request:
---
handler: library
action: show
View gist:96502
diff --git a/apps/tracker/modules/torrent/actions/actions.class.php b/apps/tracker/modules/torrent/actions/actions.class.php
index 2997f23..fbd83ae 100644
--- a/apps/tracker/modules/torrent/actions/actions.class.php
+++ b/apps/tracker/modules/torrent/actions/actions.class.php
@@ -48,8 +48,6 @@ class torrentActions extends sfActions
if(function_exists("apache_setenv")) // could be running under fastcgi or in non-apache env
apache_setenv('no-gzip', 1);
ini_set('zlib.output_compression', 0);
- ini_set('implicit_flush', 1);
- header('Content-type: multipart/x-mixed-replace;boundary="rn9012"');
View gist:97210
# .git/hooks/pre-commit:
#!/usr/bin/env sh
rake static:generate
git add static
# Rake task:
require 'rake'
ROOT = File.join(File.dirname(__FILE__))
View gist:110555
#!/usr/bin/env ruby
port_list = `port installed`
port_list.each_line do |port_line|
port_line =~ / ([^\s]+) @([^\+\s]+)(\+?[^\s]*)/
name, version, variants = $1, $2, $3
next if name.nil?
variants = variants.split('+') rescue []
puts "sudo port install #{name} #{variants.map{|v| " +"+v unless v == '' }.join}"
end
View gist:113686
$.fn.updateList = function(playlist) {
var items = itemsFromPlaylist(playlist);
var headers = commonHeaders(items);
for(var i in playlist.files) {
var innerHtml = "";
for(var j in headers) {
innerHtml += "<td class='"+headers[j]+"'>" + (state.library[playlist.files[i]][headers[j]] || '') + "</td>";
}
var newRow = $('<tr id="'+playlist.name+'_'+playlist.files[i]+'"><td><input type="checkbox" value="' + playlist.files[i] + '" /></td>' + innerHtml + "&nbsp;</tr>").data('idx', playlist.files[i]);
You can’t perform that action at this time.