Skip to content

Instantly share code, notes, and snippets.

View jcamenisch's full-sized avatar

Jonathan Camenisch jcamenisch

  • Raleigh, NC
  • 10:47 (UTC -04:00)
View GitHub Profile
@jcamenisch
jcamenisch / kwik.py
Created October 18, 2019 00:03
Kwik Refactoring Drill
######################################################################
# INPUT MODULE
import line_storage
######################################################################
## CIRCULAR SHIFTER
#
# Make circ_index store something represetning all circular shifts
#

Keybase proof

I hereby claim:

  • I am jcamenisch on github.
  • I am jcamenisch (https://keybase.io/jcamenisch) on keybase.
  • I have a public key ASCEpa9m45ZXvTh8ihYqM3wsfzxJXPC3sPtBFfYl5Dfdcgo

To claim this, I am signing this object:

@jcamenisch
jcamenisch / contact.html
Last active September 8, 2016 14:35 — forked from cypriss/contact.html
Create a UserVoice ticket with JSONP and our API.
<!DOCTYPE html>
<head>
<title>Demo Contact Form - Submit a ticket to UV via JSONP</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" />
<style type="text/css"> #contact_form { margin: 20px auto; width: 500px; } </style>
</head>
<body>
<div id="contact_form">
defmodule Chop do
def guess(actual, low..high) do
next_guess = fn
(n) when n == actual -> actual
(n) when n > actual -> guess(actual, low..n)
(n) when n < actual -> guess(actual, n..high)
end
n = div(low + high, 2)
IO.puts "Is it #{n}?"
defmodule Chop do
def guess(actual, low..high) do
n = div(low + high, 2)
IO.puts "Is it #{n}?"
_next_guess(actual, low..high, n)
end
defp _next_guess(actual, _.._, actual) do
actual
end
# !/bin/bash
# mapped to lw (as in log work) this script simply appends any parameters as a new line in worklog.txt in ~/
# no parameters will print the last 10 messages
# -o opens the worklog in VIM and immediately jumps to the last line.
# -l gets the tux to tell you the last message.
# -u deletes the last message (u as in undo).
# -uv also posts the message to idone this.
# Git pre-commit hook to block forbidden code
#
# Installation
#
# ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit
#
# Based on
#
# http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
# http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes
@jcamenisch
jcamenisch / list_method_arguments.rb
Last active August 29, 2015 14:02
List arguments to a Ruby method
def get_inputs(a, b, c)
Hash[local_variables.map { |name| [name, binding.local_variable_get(name)] }]
end
get_inputs('one', 'two', 'three')
#=> {:a=>"one", :b=>"two", :c=>"three"}
# Or package that in a reuseable method like so:
def get_local_variables(a_binding)
@jcamenisch
jcamenisch / .read_sensitive_data_into_environment
Last active August 29, 2015 13:56
With latest (master) version of dotenv, you can load in sensitive information straight from the Mac OS X keychain.
AWS_ACCESS_KEY_ID=$(keychain_account s3.amazonaws.com)
AWS_SECRET_ACCESS_KEY=$(keychain_password s3.amazonaws.com $AWS_ACCESS_KEY_ID)
@jcamenisch
jcamenisch / volunteerNotifications.js
Last active December 21, 2015 10:09
Given a list of people on a rotation to cover some responsibility, send notifications to the next people who's shift is approaching. To test this, 1. Make a duplicate of https://docs.google.com/spreadsheet/ccc?key=0AsonuW5GGQ5sdGtaTEFBZ1pzYTZ2ZzFZTWZvbW1nbmc for your sandbox. 2. In the menu of your spreadsheet, navigate to Tools > Script Editor.…
/*
* Runs in the context of
* https://docs.google.com/spreadsheet/ccc?key=0AsonuW5GGQ5sdGtaTEFBZ1pzYTZ2ZzFZTWZvbW1nbmc
*/
var sheetDefaults = {
firstDataRow: 2,
firstDataCol: 1,
spreadsheetId: '0AsonuW5GGQ5sdGtaTEFBZ1pzYTZ2ZzFZTWZvbW1nbmc',
};