Skip to content

Instantly share code, notes, and snippets.

@KarimP
KarimP / ftp.rb
Last active June 24, 2022 06:29
Using Ruby's Net FTP to upload a stream of partial chunks
# Simple extension of Net::FTP to allow uploading a stream instead of a file
# This allows for transferring of files between servers without downloading entire file first
# The code below is a modification of the storbinary method in Net::FTP
# https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L686
# It goes without saying that the code may break at anytime and may or may not work with other
# features of Net::FTP such as using Resume.
require 'net/ftp'
@KarimP
KarimP / pre-commit_jshint.sh
Last active August 29, 2015 14:11
JSHint pre-commit git hook with a prompt to continue when there are errors
#!/bin/bash
#
# Run JSHint validation before commit
# Path to custom jshint config file if you have one (relative to root directory of repository)
jshint_config_file=""
# Get all changed js files (minus any minfied files)
files=$(git diff --cached --name-only --diff-filter=ACMR -- *.js **/*.js | grep -v 'min')
pass=true;