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' | |
class Nokogiri::HTML::Document | |
# Use open-uri to get document and set url accordingly. | |
def self.get(url) | |
raw = open(url) | |
parse(raw, raw.base_uri.try(:to_s)) # handles redirected url | |
end | |
end | |
module Nokogiri::HTML | |
def self.get(url) |
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
# | |
# At CoverHound, we use conditional validations all over the form. However, there is no proper way to do | |
# this in Rails. Instead, we can provide an array of attributes (validated_fields attribute) | |
# and ensure they are the only ones to get validated. | |
# | |
module ConditionalValidations | |
attr_accessor :validated_fields | |
def field_is_required?(field) |
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
if (document.cookie.indexOf("full_site=1") === -1 && navigator.userAgent.match(/iPhone|iPod|iPad|Android/i)) { | |
window.location = document.URL.replace(/:\/\//, '://m.'); | |
} |
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
<xsl:stylesheet version="1.0" | |
xmlns="http://www.w3.org/1999/xhtml" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xhtml="http://www.w3.org/1999/xhtml" | |
> | |
<!-- lulalala 2008/10/16 created --> | |
<xsl:output method="text" encoding="UTF-8"/> |
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
function rspecgrep() | |
{ | |
SPK_FILES=`find spec -type f -name "*_spec.rb" | grep $1` | |
echo $SPK_FILES | |
time rspec $SPK_FILES --format documentation | |
} |
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 TaiwaneseAddress | |
def initialize(address) | |
@original_address = address.clone() | |
@levels = prepare_level() | |
@levels.each do |level| | |
level.keys.each do |region| | |
if match = address[/^(.{1,4}#{region})/,1] | |
level[region] = match |
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
SELECT `topics`.* FROM `topics` WHERE `topics`.`id` IN ( | |
SELECT DISTINCT `topic_comments`.`topic_id` FROM `topic_comments` WHERE (created_at > '2011-11-08 04:56:58') ORDER BY `topic_comments`.`created_at` DESC) | |
LIMIT 10 OFFSET 0; | |
SELECT DISTINCT `topic_comments`.`topic_id` FROM `topic_comments` WHERE (created_at > '2011-11-08 04:56:58') ORDER BY `topic_comments`.`created_at` DESC; | |
select topics.* from topics where topics.id in (45756,45334,44759,44799,44769,44697,43755,43445,43591,43754,42620,42643,42683,41333,42277,41678,41868,41610,41530,525,41336,41066,41067,41068,40596,40800,40575,40264,40292,40038,39744,39348,40082,39859,39702,40039,39532,38440,38658,8346,38218,37760,33297,37123,37353,37002,37089,36948,36870,36617,36727,16621,25468,25465,16972,8741,9604,17498,14175,14898,26513,26143,26058,10957,8799,35054,36728,36430,36393,36395,35816,7642,36278,36279,36097,24377,33299,35087,35053,32413,34660,34489,34510,33823,34077,33873,33557,32656,32600,33123,30970,32880,32924,116,29133,32274,32409,32104,32148,30 |
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
pacman -S gnupg | |
pacman -Sy | |
pacman -S systemd-tools --force | |
pacman -S pacman --force | |
sudo pacman-key --init; sudo pacman-key --populate archlinux |
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
set = Set.new() | |
i = 0 | |
Delayed::Job.order('id DESC').where('queue = "ender"').find_each do |d| | |
if not (set.add?( d.handler[/\d+/].to_i )) | |
d.destroy | |
i += 1 | |
end | |
end |