Skip to content

Instantly share code, notes, and snippets.

View iconnor's full-sized avatar

Ian Connor iconnor

View GitHub Profile
@iconnor
iconnor / Dockerfile
Created July 11, 2019 05:54
angular/react/vue/spa
FROM nginx:stable-alpine
COPY dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
@iconnor
iconnor / passwords_controller.rb
Created March 7, 2016 04:33
Stop password reset tokens being used more than once (so to with any domain referrer leakage)
# new file app/controllers/users/passwords_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def edit
super
raw, enc = Devise.token_generator.generate(User, :reset_password_token)
original_enc = Devise.token_generator.digest(User, :reset_password_token, params[:reset_password_token])
EncoreBackend::User.where(reset_password_token: original_enc).update_all(reset_password_token: enc)
@user.reset_password_token = raw
end
end
@iconnor
iconnor / anti_truetwit.rb
Last active January 29, 2016 03:42
Also remove bot replies
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['twitter_bot_consumer_key']
config.consumer_secret = ENV['twitter_bot_consumer_secret']
config.access_token = ENV['twitter_bot_access_token']
config.access_token_secret = ENV['twitter_bot_access_token_secret']
end
client.direct_messages(count: 200).each do |message|
if message.full_text =~ /uses TrueTwit validation. To validate click here/
puts "Don't even... #{message.full_text}"
$ip=((gwmi Win32_NetworkAdapterConfiguration | ? { $_.IPAddress -ne $null }).ipaddress | select -First 1)
$ipAddressName = $ip.Replace(".","-")
If ($env:COMPUTERNAME -eq $ipAddress) { echo $ipAddressName; echo "No need to change" } else { netdom renamecomputer "$env:COMPUTERNAME" /Newname $ipAddressName /REBoot 10 }
@iconnor
iconnor / skymiles.rb
Created September 15, 2012 13:37
Script to get account balance from Delta Sky Miles
require 'mechanize'
#Usage: ruby -rubygems skymiles.rb 123456789 1234 smith
acct = ARGV[0]
pin = ARGV[1]
lastName = ARGV[2]
@agent = Mechanize.new
page = @agent.get("http://www.delta.com/skymiles/manage_account/index.jsp")
@iconnor
iconnor / gist:1340400
Created November 4, 2011 20:28
Notify github issues when you deploy from master
# To do this, we call this from the deployment rake task:
DEPLOY_TAG = 'last-deploy'
# Tag & comment new issues that have been deployed
previous_deploy, current_deploy, issues = deploy_issues
#which calls this method:
def deploy_issues
update_branch('master')