This file contains hidden or 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
package main | |
import ( | |
"os" | |
"fmt" | |
"errors" | |
"net" | |
"encoding/json" | |
"github.com/gmallard/stompngo" | |
) |
This file contains hidden or 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 | |
require 'optparse' | |
require 'csv' | |
@options = { | |
:files => [], | |
:pattern => /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i, | |
:columns => [], | |
:output => nil | |
} |
This file contains hidden or 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 ProjectsController < ApplicationController | |
stream | |
def index | |
# rest of controller code | |
end | |
end |
This file contains hidden or 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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
before_filter do | |
@categories = Rails.cache.fetch("global/categories", expires_in: 10.minutes) do | |
Category.where("posts_count > 0").all | |
end | |
end | |
end |
This file contains hidden or 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
def collect_between(first, last) | |
first == last ? [first] : [first, *collect_between(first.next, last)] | |
end | |
date_h3 = page.at_xpath("//h3[contains(text(), 'Date:')]") | |
time_h3 = page.at_xpath("//h3[contains(text(), 'Time:')]") | |
date_strings = collect_between(date_h3, time_h3) | |
date_strings[1..(date_strings.size - 2)].collect(&:text).delete_if(&:blank?) |
This file contains hidden or 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
# I have an array of dates (both past and present) and a single date ('needle' below), | |
# for which I want to find the closest date in either direction. Here's my solution; | |
# can you think of a better one? | |
dates.sort_by { |date| (date.to_time - needle.to_time).abs }.first |
This file contains hidden or 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
Day job: Web Developer at Core Web Design (in the land of persistent rain; Wales). | |
Your Rails contributions (if any): Moral support and a few decent bug reports. | |
What's your Ruby/Rail experience?: Nearly two years using Ruby/Rails. Currently using it to build projects at work and at home which I wouldn't dream of attempting by myself in anything else. | |
How do you use GitHub?: I use GitHub for my own projects, my work projects, and even more as my go-to place for library discovery. |
This file contains hidden or 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
10:53 -!- penos [[email protected]] has joined #ruby | |
10:53 <penos> i like to be raped by 15 gays | |
10:53 <merlish> you want #python, not #ruby |
This file contains hidden or 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 an example table of 'addresses' with a latitude and longitude column | |
# Replace #LONGITUDE#, #LATITUDE#, and #DISTANCE_IN_MILES# with your search values | |
SELECT addresses.*, (ACOS( SIN(RADIANS(#LATITUDE#)) * SIN(RADIANS(addresses.latitude)) + COS(RADIANS(#LATITUDE#)) * COS(RADIANS(addresses.latitude)) * COS(RADIANS(addresses.longitude) - RADIANS(#LONGITUDE#)) ) * 3963.1676) AS distance | |
FROM addresses | |
WHERE (((ACOS( SIN(RADIANS(#LATITUDE#)) * SIN(RADIANS(addresses.latitude)) + COS(RADIANS(#LATITUDE#)) * COS(RADIANS(addresses.latitude)) * COS(RADIANS(addresses.longitude) - RADIANS(#LONGITUDE#)) ) * 3963.1676) <= #DISTANCE#) OR (addresses.latitude = #LATITUDE# AND addresses.longitude = #LONGITUDE#)) |
This file contains hidden or 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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
PS1="\w\$(parse_git_branch) $ " |