Skip to content

Instantly share code, notes, and snippets.

View iconnor's full-sized avatar

Ian Connor iconnor

View GitHub Profile
@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')
@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")
$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 / 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}"
@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 / 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 / Dockerfile
Created July 11, 2019 05:55
Java SpringBoot
FROM openjdk:8-jdk-alpine
RUN apk update \
&& apk add --no-cache curl
HEALTHCHECK --interval=5s --timeout=5s --retries=12 \
CMD curl --silent --fail localhost:8080/actuator/health || exit 1
VOLUME /tmp
ADD target/yourapp-SNAPSHOT.jar app.jar
ENV SPRING_PROFILES_ACTIVE cloud-dev
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
@iconnor
iconnor / Dockerfile
Last active July 11, 2019 06:00
PHP laravel with composer
#start with our base image (the foundation) - version 7.1.5
FROM businesstools/nginx-php:1.8.0
#install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
#set our application folder as an environment variable
ENV APP_HOME /var/www/html
ENV COMPOSER_ALLOW_SUPERUSER=1
@iconnor
iconnor / default.cong
Created July 11, 2019 05:59
PHP nginx conf file for Docker
# vim: ft=nginx ts=2 sw=2
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
# Make site accessible from http://localhost/
@iconnor
iconnor / signin.spec.ts
Last active July 11, 2019 06:22
Cypress io signin test
context('Actions', () => {
beforeEach(() => {
cy.visit('/login');
});
it('Bad sign in should fail', () => {
cy.get('#username')
.type('user@projectlounge.com');
cy.get('#password')
.type('Bad pass');