Skip to content

Instantly share code, notes, and snippets.

Preston Guillory pguillory

  • Pinterest
  • San Francisco
Block or report user

Report or block pguillory

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
@pguillory
pguillory / output.txt
Last active Jun 14, 2016
Built-in macros expanding to invalid code
View output.txt
case(:condition) do
x when x in [false, nil] ->
nil
_ ->
:ok
end
case(:condition) do
x when Enum.member?([false, nil], x) ->
nil
_ ->
View game.ex
defmodule Game do
# Client
def start do
spawn &Game.play/0
end
def move(pid, request) do
send(pid, {:request, self, request})
receive do
View beowulf.txt
I.
THE LIFE AND DEATH OF SCYLD.
{The famous race of Spear-Danes.}
Lo! the Spear-Danes' glory through splendid achievements
The folk-kings' former fame we have heard of,
How princes displayed then their prowess-in-battle.
@pguillory
pguillory / text.md
Last active Mar 19, 2017
Internet Explorer quirk: HTML entities in URLs
View text.md

Try going into your browser console and typing:

window.location = 'http://causes.com/?a=true&not_a=false'

Now look at your address bar. What you see depends on which browser you're using.

Chrome, Firefox: http://www.causes.com/?a=true&not_a=false

View gist:4627333
.nav-item {
&:nth-child(1) {
@media {min-width: 200px) {
display: none;
}
}
&:nth-child(2) {
@media {min-width: 250px) {
display: none;
View classify_version.js
Causes.SomeClass = Causes.classify({
init : function() {
this.value = 0;
$('#something').on('click', this.handlerFunc.bind(this));
},
handlerFunc : function(event) {
event.preventDefault();
this.value += 5;
},
View gist:1474598
package main
type SomeCollection struct {
members []int
}
func (this *SomeCollection) Append(i int) {
this.members = append(this.members, i)
}
View gist:967683
# Returns parsed CSS
def extract_css
css = @dom.css('style, link[rel=stylesheet]').collect do |node|
next unless /^$|screen|all/ === node['media'].to_s
node.remove
if node.name == 'style'
node.content
else
uri = %r{^https?://} === node['href'] ? node['href'] : File.join(@stylesheets_path, node['href'].sub(/\?.+$/,''))
View gist:839545
// Synchronous form - 6 lines
function f() {
a()
b()
c()
d()
}
// Asynchronous form - 12 lines
function f(callback) {
View browserize.js
// foo.js
console.log('foo');
require('bar').print();
//bar.js
exports.print = function() {
console.log('bar');
}
You can’t perform that action at this time.