Skip to content

Instantly share code, notes, and snippets.

@coldhawaiian
coldhawaiian / command.sh
Created February 7, 2014 20:13
Bash command for opening multiple files in your favorite editor
# Example $FILE_PATTERN: '*.js'
find $DIRECTORY -type f -name $FILE_PATTERN -exec $EDITOR "{}" \;
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@coldhawaiian
coldhawaiian / jQuerify.html
Last active August 29, 2015 13:56
A bookmarklet for injecting jQuery into any web page (jQuerifying, or jQuerification). Might need to call jQuery.noConflict() if there are problems with $ variable.
<a href="javascript:(function () { var script = document.createElement('script'); script.src = 'https://code.jquery.com/jquery-1.11.0.min.js'; var head = document.getElementsByTagName('head')[0]; head.appendChild(script); })();">
jQuerify
</a>
@coldhawaiian
coldhawaiian / Query.js
Created February 26, 2014 03:48
FQL Query Builder: a standalone JavaScript class to dynamically generate Facebook Query Language queries.
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Keoki Zee
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
require 'open-uri'
require 'json'
language = 'en'
print 'What do you need to know? : '
article = URI::encode gets.chomp
request_url = "http://#{language}.wikipedia.org/w/api.php?action=parse&page=#{article}&format=json&prop=text&section=0"
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
root_DN = /CN=Esotericsystems Root Authority/C=AT/
issuing_DN = /CN=Esotericsystems Issuing Authority/C=AT/
passphrase:
echo -n changeme > $@
#
# Create param files, keys and Self-Signed Certificate for the Root CA
#
root-ca-dsa.param: passphrase

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@coldhawaiian
coldhawaiian / practice.rb
Last active May 25, 2016 16:15
Just playing around with some Ruby.
# Eager (non-lazy) sequence generation:
(0..8).each_cons(2).map { |a,b| a + b }
# Another form (of above)
(1..10).each_with_object([1]) { |i,a| a[i] = a[i-1] + 2 }
# Eager Fibonacci (generates n+1 Fibonacci numbers)
(2..10).each_with_object([0,1]) { |i,a| a[i] = a[i-2] + a[i-1] }
# Corrected for n = 1 or 2, and removed extra number
@coldhawaiian
coldhawaiian / styles.less
Last active August 29, 2015 13:57
Personal style sheet for Atom editor
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/