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
version 5 | |
FIREHOL_LOG_PREFIX="firehol: " | |
interface any world | |
policy drop | |
server "ssh icmp http https" accept | |
client all accept |
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
[ext2/1/ext 1 (0,20)] [straight_topics_core`, `infix_topics_core] apple @sphinx_internal_class_name (Topic) |
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
class PagesController < ApplicationController | |
exposes :weather | |
def index | |
@weather = Rails.cache.fetch "weather", expires_in: 5.minutes do | |
Weather.lookup 68164 | |
end | |
render | |
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
require "open-uri" | |
require "cgi" | |
require "json" | |
SEARCH_API = URI "http://api.thriftdb.com/api.hnsearch.com/items/_search" | |
START_DATE = "2012-01-01" | |
END_DATE = "2012-12-31" | |
TOP_LIMIT = 10 | |
def get(type, sortby) |
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
# e.g. - "AC 10 01 3D" => "172.16.1.61" | |
def hex2ip(hex) | |
hex.split(" ").map { |i| i.to_i(16) }.join(".") | |
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
require "minitest/autorun" | |
module Enumerable | |
def collect(&block) | |
each_with_object([]) { |i, obj| obj << block.call(i) } | |
end | |
def detect(&block) | |
# each_with_object(nil) { |i, obj| obj ||= block.call(i) ? i : nil } | |
inject(nil) { |obj, i| obj ||= block.call(i) ? i : nil; obj } |
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 | |
unless filename = ARGV.first | |
abort "usage: #{__FILE__} file [http://host] [theme]" | |
end | |
host = ARGV[1] || "http://wp33.dev" | |
theme = ARGV[2] || "twentyten" | |
text = File.read(filename) | |
text.gsub! /'siteurl','.*',/, "'siteurl','#{host}'," |
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
# using ruby: | |
$ echo $PATH | ruby -e 'STDIN.read.split(":").each { |l| puts l }' | |
$ echo $PATH | ruby -e 'print STDIN.read.gsub(":", "\n")' | |
# Using sed: I would expect this to work, but it does not | |
$ echo $PATH | sed 's/:/\n/g' |
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 UniqueId | |
def self.included(base) | |
raise StandardError, "model must have 'uuid'" unless base.columns.any? { |c| c.name == 'uuid' } | |
base.before_create do | |
self.uuid = UUID.generate unless uuid.present? | |
end | |
end | |
end |