Skip to content

Instantly share code, notes, and snippets.

View JackBracken's full-sized avatar
💭
wut

Jack Bracken JackBracken

💭
wut
View GitHub Profile
@JackBracken
JackBracken / gist:1ff19d96dd5b2c1d98c6fcb332c8208e
Created October 10, 2018 09:37
My anaconda don't want none
jack in /U/j/p/a/maintenance_scripts on master [!]
$ python sat6_report.py
Traceback (most recent call last):
File "sat6_report.py", line 6, in <module>
import requests
ImportError: No module named requests
jack in /U/j/p/a/maintenance_scripts on master [!]
$ pip list | grep requests
requests 2.10.0
@JackBracken
JackBracken / aoc_2016_1a.rb
Created December 2, 2016 10:58
Advent of code 2016, 1a.
#!/usr/bin/env ruby
# The naive approach
input = "R5, R4, R2, L3, R1, R1, L4, L5, R3, L1, L1, R4, L2, R1, R4, R4, L2, L2, R4, L4, R1, R3, L3, L1, L2, R1, R5, L5, L1, L1, R3, R5, L1, R4, L5, R5, R1, L185, R4, L1, R51, R3, L2, R78, R1, L4, R188, R1, L5, R5, R2, R3, L5, R3, R4, L1, R2, R2, L4, L4, L5, R5, R4, L4, R2, L5, R2, L1, L4, R4, L4, R2, L3, L4, R2, L3, R3, R2, L2, L3, R4, R3, R1, L4, L2, L5, R4, R4, L1, R1, L5, L1, R3, R1, L2, R1, R1, R3, L4, L1, L3, R2, R4, R2, L2, R1, L5, R3, L3, R3, L1, R4, L3, L3, R4, L2, L1, L3, R2, R3, L2, L1, R4, L3, L5, L2, L4, R1, L4, L4, R3, R5, L4, L1, L1, R4, L2, R5, R1, R1, R2, R1, R5, L1, L3, L5, R2".split(', ')
dist = hor = ver = 0
facing = :north
def turn(facing, dir)
#!/usr/bin/env bash
# Ask for the administrator password upfront.
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Install xcode command line tools
xcode-select --install
class CreateSomeModel < ActiveRecord::Migration
create_table :some_model do |t|
# SomeModel :active should always default to false
t.boolean :active, null: false, default: false
end
end
class SomeModel < ActiveRecord::Base
# But Model scope will override it
default_scope{ where(active: true) }
@JackBracken
JackBracken / authenticate_user_from_token.rb
Created November 18, 2015 16:26
Get auth token from header or params example
def authenticate_user_from_token!
user_token = request.headers['Auth-Token'].presence || params[:auth_token].presence || nil
user = user_token && User.find_by_authentication_token(user_token.to_s)
if user
@current_user = user
end
end
[~]$ cat Test.java
public class Test {
private int i;
public int getI() {
return i;
}
public static void main(String[] args) {
Test t = new Test();
[~]$ javac Test.java
Test.java:4: error: variable i might not have been initialized
System.out.print(i);
^
1 error
[~]$ cat Test.java
public class Test {
public static void main(String[] args) {
int i;
System.out.print(i);
<head>
<!-- Basic Meta Info -->
<meta charset="utf-8">
<title>
Congratulations!
</title>
<meta name="description" content="On your engagement!">
<meta name="author" content="Alan, Grace, Jack, Paul, Shaun and Erik">
<!-- Mobile Specific Metas -->
def game_over?
count = 0
token = last_token = ""
@board.each_index do |col|
# Look ahead then track back in each column
0.upto(2) do |y|
# If the space we are looking at is empty then skip it
next if @board[col][y].eql?(EMPTY_SPACE)
next unless @board[col][y].eql?(@board[col][y + 3])
int i = 0;
System.out.println("OUTPUT:");
if(true) {
i++;
System.out.println(i);
}
/*