Skip to content

Instantly share code, notes, and snippets.

@joshjordan
joshjordan / _zsh-config.sh
Last active February 8, 2024 03:23
Initialize a new machine with my preferred applications and configurations
#!/bin/zsh
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
git clone https://gist.github.com/033fd9f674a670da0460.git ~/zprezto_custom
ln -s ~/zprezto_custom/prompt_joshjordan_setup ~/.zprezto/modules/prompt/functions/prompt_joshjordan_setup
golang: go run go-producer.go
redis: redis-server
ruby: sidekiq -r './ruby-consumer.rb'
@joshjordan
joshjordan / lenskit.rb
Last active October 2, 2017 13:42
Example showing usage of lenskit from Ruby, via JRuby.
require 'jbundler'
require 'example_runner'
#In a real application, include this module in your Ruby class
include ExampleRunner
user_ids.each do |user_id|
puts "Recommendations for user with id=#{user_id}:"
puts " #{item_recommender.recommend(user_id, 5)}"
end
$Rewards = "Donuts","Cookies","Steak","Bacon","Cupcakes","Truffles","Chocolates","Snacks","Breakfast","Lunch","Back rubs","Burgers","Pancakes","High fives","Coconuts","Cheesecake","Stamps"
$sendDateTime = (Get-Date)
$sendDateTime.AddSeconds(-1)
while($true)
{
Write-Output ($sendDateTime -lt (Get-Date))
if($sendDateTime -lt (Get-Date))
{
$ChosenReward = $Rewards | Get-Random
@joshjordan
joshjordan / socks-proxy.sh
Created August 18, 2016 04:35
Simple script to connect to a dynamic proxy via SSH and connect your local OS X wifi to it via SOCKS. Disconnects on CTRL+C
#!/bin/bash
# Set PROXY_HOST to the SSH proxy hostname (optionally, include a username)
# Override PROXY_PORT if necessary
sudo -s <<EOF
trap clear_proxy INT
function clear_proxy() {
echo "Disconnecting proxy..."
@joshjordan
joshjordan / to_csv.rb
Last active August 4, 2016 02:50
Snippet that saves an array of hashes to a CSV file easily
require 'csv'
class Array
def to_csv(csv_filename, homogeneous_headers = false)
return unless self.any?
headers = if homogeneous_headers
self.first.keys
else
self.inject([]) { |memo, row| memo |= row.keys; memo }
end

Keybase proof

I hereby claim:

  • I am joshjordan on github.
  • I am joshjordan (https://keybase.io/joshjordan) on keybase.
  • I have a public key whose fingerprint is 017B 4FEC 0D82 7646 A7BA F2B3 AD81 8BB5 E132 FB8A

To claim this, I am signing this object:

@joshjordan
joshjordan / polyfills.js
Created March 8, 2016 00:19
d3 deconstructor polyfills
SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(elem) {
return elem.getScreenCTM().inverse().multiply(this.getScreenCTM());
};
// SVGPathSeg API polyfill
// https://github.com/progers/pathseg
//
// This is a drop-in replacement for the SVGPathSeg and SVGPathSegList APIs that were removed from
// SVG2 (https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html), including the latest spec
@joshjordan
joshjordan / prompt_joshjordan_setup
Last active January 16, 2016 22:47
Simple prezto prompt with working directory and git info on the left prompt, and current time on right prompt.
#
# My prezto prompt. Simplified version of (read: almost completely lifted from) steeef theme
#
function prompt_joshjordan_precmd {
# Check for untracked files or updated submodules since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
branch_format="(${_prompt_joshjordan_colors[1]}%b%f%u%c${_prompt_joshjordan_colors[4]}●%f)"
else
branch_format="(${_prompt_joshjordan_colors[1]}%b%f%u%c)"
require 'benchmark'
module A
end
class DefinedMethodStyle
def dont_bust_cache(*)
Object.new
nil
end