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
# multi-class selection | |
<div class="a b c"> | |
</div> | |
.a.b { } | |
# parent - child selection | |
<div class="a"> |
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 Object | |
# Return a list of methods defined locally for a particular object. Useful | |
# for seeing what it does whilst losing all the guff that's implemented | |
# by its parents (eg Object). | |
def local_methods(obj = self) | |
(obj.methods - obj.class.superclass.instance_methods).sort | |
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
$ valgrind --version | |
valgrind-3.8.1 | |
$ valgrind ./ex6 | |
==56827== Memcheck, a memory error detector | |
==56827== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. | |
==56827== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info | |
==56827== Command: ./ex6 | |
==56827== |
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
=begin | |
## Description | |
A tool for Octopress to generate IDs in header tags and index list aside. It helps you easily build a tutorial page with many chapters. | |
## Features | |
* Support all languages. | |
## Syntax |
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
# LETS GET READY TO RECURSE!!!!!! | |
# | |
# Tower of Hanoi | |
# | |
# You have 4 discs which vary in size from small to large | |
# There are 3 pegs, A, B, C, respectively | |
# | |
# The discs are all currently on peg A, with the largest disc on the bottom, | |
# and the smallest disc on the top. | |
# |
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
# Unfortunately, Google doesn't return the actual string it is suggesting | |
# replacements for, so this got a little complicated. Fork and improve! | |
require 'httparty' | |
require 'nokogiri' | |
# > Spellcheck.correct("Ths is a tst") | |
# => "This is a test" | |
# > Spellcheck.correct("My nme is Robrt Whtney") | |
# => "My name is Robert Whitney" |
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
# Generate the sequence of numbers below. | |
# 0 1 2 3 4 5 6 7 8 9 | |
# 1 2 3 4 5 6 7 8 9 0 | |
# 2 3 4 5 6 7 8 9 0 1 | |
# 3 4 5 6 7 8 9 0 1 2 | |
# 4 5 6 7 8 9 0 1 2 3 | |
# 5 6 7 8 9 0 1 2 3 4 | |
# 6 7 8 9 0 1 2 3 4 5 | |
# 7 8 9 0 1 2 3 4 5 6 |
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
desc "a task with arguments" | |
task :example, :some_arg do |t, args| | |
# .. do something with the arguments | |
end | |
# > rake -T | |
# > rake example[some_arg] # a task with arguments |
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
# http://stackoverflow.com/a/8936202 | |
# | |
# ActiveAdmin already includes the necessary jquery in active_admin/base, | |
# so just add this to javascripts/active_admin.js after //= require active_admin/base | |
# | |
# | |
# Serialize and Sort | |
# | |
# model_name - you guessed it, the name of the model we are calling sort on. | |
# This is the actual variable name, no need to change it. |
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
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
NewerOlder