Skip to content

Instantly share code, notes, and snippets.

View noahd1's full-sized avatar

Noah Davis noahd1

  • Code Climate
  • New York, NY
View GitHub Profile
@noahd1
noahd1 / csrf_controller.js
Last active April 24, 2024 20:17
csrf_refresh
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = {
wait: Number
}
connect() {
this.refresh = this.debounce(this.refreshNoBounce, this.waitValue || 500); // Default wait time of 500ms if not specified
}
@noahd1
noahd1 / Dockerfile
Last active December 16, 2022 09:12
Export GitHub Team Memberships
FROM ruby:2.1
RUN mkdir /app
RUN mkdir /app/bin
WORKDIR /app
ENV PATH=/app/bin:${PATH}
ADD Gemfile Gemfile.lock /app/
RUN bundle install -j 8
ADD export-team-memberships.rb /app/bin/
@noahd1
noahd1 / issues.rb
Last active March 3, 2020 09:35
Example Code Climate API usage in Ruby
#!/usr/bin/env ruby
## Usage: ./issues.rb REPO_ID [BRANCH]
#
# Outputs CSV formatted list of all issues from most recent snapshot
# of the repo specified. Pipe STDOUT to a file to save to a file.
#
# Branch defaults to "master" if not specified.
#
# e.g. ./issues.rb 5017075af3ea000dc6000740
@noahd1
noahd1 / etc ssh config
Created November 17, 2012 22:41
my ssh config
[1.9.3-p286][17:41][~]$ cat /etc/ssh_config
# $OpenBSD: ssh_config,v 1.26 2010/01/11 01:39:46 dtucker Exp $
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.
# Configuration data is parsed as follows:
# 1. command line options
@noahd1
noahd1 / my .sshconfig file
Created November 13, 2012 01:18
ssh attempt with verbose output
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/noah/.ssh/config
debug1: /Users/noah/.ssh/config line 4: Applying options for *
debug1: /Users/noah/.ssh/config line 7: Applying options for spintoapp.com
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to spintoapp.com [208.113.92.242] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
{{view Ember.TextField elementId="foo" class="span4" placeholder="bar" valueBinding="person.name"}}
@noahd1
noahd1 / feasability.rb
Created October 10, 2012 03:58
Homework 1, #6
#!/usr/bin/env ruby
class Array
def agreement(other)
raise ArgumentError, "Cannot compare arrays of different sizes" if size != other.size
other.each_with_index.map do |elem, i|
self[i] == elem ? 1 : 0
end
end
end
@noahd1
noahd1 / match_entry.rb
Created September 25, 2012 03:17
Example of using also_validates for racquet.io
class MatchEntry
include Informal::Model
attr_accessor :winner_registration, :loser_registration
validate :different_twitter_handles?
also_validates :winner_registration, :loser_registration
def initialize(options = {})
@winner_registration = options[:winner_registration]
@loser_registration = options[:loser_registration]
@noahd1
noahd1 / transfer_ownership.sh
Created July 22, 2012 02:30
local_ownership
#!/bin/sh
#/ Usage: transfer-master path-to-repo( path-to-repo( path-to-repo))...
#/ Changes master to reference new master
set -e
# show program usage
if [ $# -eq 0 -o "$1" = "--help" ]
then
grep '^#/' <"$0" |
cut -c4-
@noahd1
noahd1 / Scramble
Created July 14, 2012 12:42
Scramble history
1. Black bear
- went to Newark got a passenger van
- reservation got lost
- Lee, Bryan, Josh, John (w)
vs.
- Noah, Ross, Brenn (l)
- came down to hold 18
2. The links at Shirley
- Noah, Lee, John (w)