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
def generate_secure_s3_url(s3_key) | |
# | |
# s3_key would be a path (including filename) to the file like: "folder/subfolder/filename.jpg" | |
# but it should NOT contain the bucket name or a leading forward-slash | |
# | |
# this was built using these instructions: | |
# http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?S3_QSAuth.html | |
# http://aws.amazon.com/code/199?_encoding=UTF8&jiveRedirect=1 | |
s3_base_url = MyApp::Application::S3_BASE_URL # i.e. https://mybucket.s3.amazonaws.com |
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
# Runs a specified shell command in a separate thread. | |
# If it exceeds the given timeout in seconds, kills it. | |
# Returns any output produced by the command (stdout or stderr) as a String. | |
# Uses Kernel.select to wait up to the tick length (in seconds) between | |
# checks on the command's status | |
# | |
# If you've got a cleaner way of doing this, I'd be interested to see it. | |
# If you think you can do it with Ruby's Timeout module, think again. | |
def run_with_timeout(command, timeout, tick) | |
output = '' |
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
var API_KEY = "XXX"; | |
var SECRET_KEY = "XXX"; | |
var crypto = require('crypto'); | |
var url2png = function() { | |
this.generateLink = function(url) { | |
var options = "?url="+url + "&viewport=1480x1037&thumbnail_max_width=500"; | |
var token = crypto.createHash('md5').update(options + SECRET_KEY).digest('hex'); | |
return "http://api.url2png.com/v6/"+API_KEY+"/"+token+"/png/"+options; |
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
#!/bin/sh | |
# curl https://gist.githubusercontent.com/danvine/5bf13971980126853964/raw > ~/.laptop.local | |
# sh mac 2>&1 | tee ~/laptop.log | |
brew_tap 'caskroom/cask' | |
brew tap 'caskroom/versions' | |
brew_install_or_upgrade 'brew-cask' | |
brew cask install 1password |
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
| awk '{a[$0]++}END{for (i in a) print i"\t"a[i]}' | |
| perl -lne '++$a{$_} }{ print "$_\t$a{$_}" for keys %a' |
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 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
# | |
yum install net-snmp.x86_64 | |
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig | |
scp root@$IP:/etc/snmp/snmpd.conf /etc/snmp/snmpd.conf | |
chkconfig snmpd on | |
service snmpd start |
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
<?php | |
/** | |
* Input an object, returns a json-ized string of said object, pretty-printed | |
* | |
* @author Unknown | |
* @param mixed $obj The array or object to encode | |
* @return string JSON formatted output | |
*/ | |
function json_encode_pretty($obj, $indentation = 0) { | |
switch (gettype($obj)) { |
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
// Step 1: | |
// Retrieve test image: | |
// wget http://s3.amazonaws.com/tastrix/440/large_orig/shiso_trans.png | |
// | |
// Step 2: | |
// Then, run this through node.js | |
// | |
// Step 3: | |
// Inspect shade_test.png; the overlayed squares have drop shadow with Gaussian blur, the circle of leaves does not | |
var Canvas = require('canvas') |
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
### Setup | |
mkdir 2_models_1_view | |
rails new 2_models_1_view | |
rails g scaffold Parent name:string age:integer | |
rails g scaffold Children toy:string hair:string eyes:string parent_id:integer | |
rake db:migrate |
OlderNewer