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
# this should be x-browser check | |
_raf = window.requestAnimationFrame | |
isScrolling = (fn) -> | |
pageY = window.pageYOffset | |
_checker = -> | |
unless (fn(pageY != window.pageYOffset) is false) | |
pageY = window.pageYOffset | |
_raf(_checker) | |
_raf(_checker) |
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 ContentItem | |
constructor: (@type) -> | |
# implementation of ruby's | |
# `define_method`; simplifies | |
# metaprogramming/adding methods at runtime | |
@define_method: (name, fn) -> | |
# syntax shorthand for | |
# this.prototype[name] = function(/* arguments */){...} | |
# note that `fn` will be in instance context (bound) |
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
#!/usr/bin/env bash | |
echo "================================================================================" | |
echo " PRE-COMMIT: CHECKING FILE SIZES" | |
echo "================================================================================" | |
# constant that you want to check sizes against | |
SIZE_LIMIT=$(( 1048576 * 64 )) | |
# $1 - filetype | |
function invalid_filetype() { |
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 'crowdmoderation' | |
API_KEY = "your_api_key" | |
DOMAIN_BASE = "https://api.crowdmoderation.net" | |
job_id = "your_job_id" | |
CrowdModeration::Job.connect! API_KEY, DOMAIN_BASE | |
job = CrowdModeration::Job.new(job_id) | |
unit = CrowdModeration::Unit.new(job) |
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 'mirador' | |
mc = Mirador::Client.new('your_key_here') | |
mc.classify_files('bathing-suit.jpg', 'nsfw-user-upload.png').each do |result| | |
puts "#{ result.name }: #{ (result.safe and 'is' or 'is not' } safe" | |
end | |
mc.classify_urls('http://possibly-nsfw.com/cool.png').each do |result| | |
puts "#{ result.name }: #{ (result.safe and 'is' or 'is not' } safe" | |
end |
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
[Unit] | |
Description=Demonstrate Bash | |
[Service] | |
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))" | |
ExecStart=/usr/bin/echo "2 + 2 = ${MYVAR}" |
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
#!/usr/bin/env bash | |
# upgrade starcluster | |
#### | |
mute_run () | |
{ | |
$* >/dev/null 2>&1 | |
} | |
cecho () | |
{ |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Tie::LevelDB; | |
sub foreach_key { | |
my ($db_name, $block) = @_; | |
my $db = new Tie::LevelDB::DB($db_name); | |
my $it = $db->NewIterator; |
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
#!/usr/bin/env ruby | |
# get coinbase price | |
### | |
require 'coinbase' | |
require 'optparse' | |
# your API key - https://coinbase.com/docs/api/authentication | |
COINBASE_API = '' | |
UP_ARROW = "\u25B2".encode('utf-8') | |
DOWN_ARROW = "\u25BC".encode('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 label_stream() | |
{ | |
perl -sne '$|=1; print "[$cmd]\t$_"' -- -cmd="$1" | |
} | |
# example use | |
ls -lafh . | label_stream "ls" | |
# output | |
[ls] drwxr-xr-x 6 nickjacob staff 204B Nov 11 2012 Processing/ |