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/bash | |
## Based on a script from @chrishwiggins | |
## https://github.com/chrishwiggins/mise/blob/9bc3e8c6ae309db3fb3e9f0e21d38925f06af82e/bash/oai-no-key.sh | |
if [ $# -eq 0 ]; then | |
echo "Usage: ask-chatgpt \"your questions\"" >&2 | |
exit 1 | |
fi |
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
use_nvm() | |
{ | |
local version | |
version="${1}" | |
if [[ -e .node-version ]]; then version=$(<.node-version) | |
elif [[ -e .nvmrc ]]; then version=$(<.nvmrc) | |
fi | |
if [[ -e ~/.nvm/nvm.sh ]]; then | |
source ~/.nvm/nvm.sh |
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
# install dokku on ubuntu 14.04 server | |
wget -qO- https://raw.github.com/progrium/dokku/v0.3.9/bootstrap.sh | sudo DOKKU_TAG=v0.3.9 bash | |
# add application on server | |
dokku apps:create the-app | |
# add developer public key | |
cat developers_id_rsa.pub | ssh ubuntu@the-dokku-server "sudo sshcommand acl-add dokku $USER" | |
# developer attaches dokku to local git repo |
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
http://inside-bigdata.com/2014/07/20/putnam-mathematical-competitions-unsolved-problem/ | |
All final boards are full of stones (LAAEFTR). | |
A turn can only net 0 or 1 stones (LAAEFTR). | |
Only the removal of an edge stone nets 0 stone (LAAEFTR). | |
The removal of an edge stone is always optional (LAAEFTR). | |
A stone adjacent to a stone cannot be removed (LAAEFTR). | |
Since A plays first on an odd sized board, an even number of spots are left over, meaning A will win unless B plays a turn that nets 0 stones. | |
If A's first move is anywhere but at the edge with subsequent moves building a chain of stones outward, B will only be able to play a net 0 stone turn on a self-laid edge stone. |
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 Timer = React.createClass({ | |
getInitialState: function() { | |
return {secondsElapsed: 0}; | |
}, | |
tick: function() { | |
this.setState({secondsElapsed: this.state.secondsElapsed + 1}); | |
}, | |
componentDidMount: function() { | |
this.interval = setInterval(this.tick, 1000); | |
}, |
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
_params = function(params,encoded) { | |
var __hasProp = {}.hasOwnProperty; | |
maybeEncode = function(k){ return (encoded ? encodeURIComponent(k) : k); } | |
var pairs, proc; | |
pairs = []; | |
(proc = function(object, prefix) { | |
var el, i, key, value, _results; | |
if (object == null) object = params; | |
if (prefix == null) prefix = null; | |
_results = []; |
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
namespace :spec do | |
require './last_failed_logger.rb' | |
default_opts = ["--format progress", "--color", "--fail-fast", "-f LastFailedLogger"] | |
RSpec::Core::RakeTask.new(:auto) do |t| | |
if File.exists? "./log/last_failed_spec.log" | |
$ran_last_failed_test = true | |
t.rspec_opts = [*default_opts, "--tag ~wip"] | |
t.pattern = File.open("./log/last_failed_spec.log").read |
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
module Jekyll | |
require 'haml' | |
class HamlConverter < Converter | |
safe true | |
priority :low | |
def matches(ext) | |
ext =~ /haml/i | |
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
def is_ajax_request? | |
if respond_to? :content_type | |
if request.xhr? | |
true | |
else | |
false | |
end | |
else | |
false | |
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
class ApplicationController < ActionController::Base | |
before_filter :compound_date_values | |
protected | |
def compound_date_values(h=params,prefix=[]) | |
to_fix = {} | |
h.each do |k, v| | |
if v.is_a? Hash |
NewerOlder