Skip to content

Instantly share code, notes, and snippets.

@maxplomer
maxplomer / url_methods.rb
Created July 28, 2016 15:43
Bastille Agency Test
class String
def get_domain
URI(self).host.match(/[^\.]+\.\w+$/).to_s
end
end
class Node
attr_accessor :a, :b, :c
def initialize(data)
@data = data
@maxplomer
maxplomer / uninstall_all_gems.rb
Created July 13, 2015 00:53
uninstall all gems
output = `gem list --no-versions`
output = output.split("\n")
output.each do |gem|
system("gem uninstall #{gem}")
end
@maxplomer
maxplomer / fix_bitchart.rb
Created June 13, 2015 03:09
script for bitchart.co to move trades forward and delete old quotes, until improve algorithm
Trade.all.each do |trade|
trade.created_at += 175.days
trade.save
end
@maxplomer
maxplomer / pi_camera.py
Created November 19, 2014 07:40
This is the code that my button.py code calls to takes pictures for 20 seconds
#!/usr/bin/python
import os
import time
import subprocess
from time import strftime
# EV level
photo_ev = 0
@maxplomer
maxplomer / button.py
Created November 19, 2014 07:39
this is the code that I attach to my raspberry pi's crontab so that it runs at startup
#!/usr/bin/env python
import time
import RPi.GPIO as GPIO
import os
import subprocess
def main():
# tell the GPIO module that we want to use the
@maxplomer
maxplomer / jquery_todo_app.html
Created November 19, 2014 05:45
a fun little todo app that uses a hidden field to store data on the webpage, click on the row for the hidden message
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.js"></script>
</head>
<body>
<h1>Todo List</h1>
<table class="todo-list">
<th style="padding-right: 30px;">Todo</th>
@maxplomer
maxplomer / business.rb
Created September 16, 2014 21:59
employee manager classes problem
class Employee
attr_accessor :name, :title, :salary, :boss
def initialize
@name
@title
@salary
@boss
end
@maxplomer
maxplomer / argv_test.rb
Created September 15, 2014 20:41
need to use shift to get args from argv otherwise will mess up gets
def argv_test
filename = ARGV.shift
game_save = File.readlines(filename)
p game_save
x = gets.chomp
p x
end
argv_test
@maxplomer
maxplomer / sum_of_pairs.rb
Created September 14, 2014 23:00
sum of pairs
def sum_of_pairs(arr)
max_length = 0 #max length of subset
#go through all subsets
for i in 0..(arr.size - 2)
for j in (i + 1)..(arr.size - 1)
sub_arr = arr[i..j]
sub_arr_length = sub_arr.length
if is_good?(sub_arr)
max_length = sub_arr_length if sub_arr_length > max_length
@maxplomer
maxplomer / rails_tutorial_git
Last active August 29, 2015 14:06
git notes from rails tutorial
####### install Git ##########
Use install Git section of Pro Git
can install from graphical Git installer or Macports
http://sourceforge.net/projects/git-osx-installer/
Note: I'm fine with my Git version