Skip to content

Instantly share code, notes, and snippets.

View zailleh's full-sized avatar

Tim Caldwell zailleh

View GitHub Profile
@zailleh
zailleh / pre-commit
Last active October 11, 2019 02:55
Git pre-commit for Rubocop
#!/bin/sh
BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
REF=$(git merge-base master $BRANCH)
DIFFS=$(git diff --diff-filter AM --name-only --relative $REF)
if [ "$DIFFS" != "" ]
then
echo "Checking for rubocop offenses..."
OFFENSES=$(rubocop $(echo "$DIFFS"))
if [ "$(echo $OFFENSES | grep 'no offenses')" == "" ]
then
@zailleh
zailleh / ruby_luhn_monkey_patch.rb
Created July 13, 2018 00:34
Monkey Patch for the Integer class in Ruby to add Luhn algorithm features.
class Integer
def luhn_sum
num = self.to_s.chars
sum = 0
num.reverse.each_with_index do |n,i|
n = n.to_i
n *= 2 if i % 2 == 1
@zailleh
zailleh / atom_snippits.md
Last active July 6, 2018 02:14
A brief cheat-sheet on adding custom snippets to Atom

Creating Snippets in Atom

Main Points

  1. Where to Add Snippets
  2. How to find out the language selector (scope)
  3. How to format a snippit

Where to Add Snippets

In Atom, you can add snippets by going to the Atom menu and going to Snippets...

def addition_function # declare this outside of the case and loop so we can call it repeatedly
puts "Which numbers would you like to add?"
n1 = gets.chomp.to_i
n2 = gets.chomp.to_i
answer = n1 + n2
puts "The sum is: #{answer}"
end
def show_menu
puts "Calculator"
@zailleh
zailleh / short-tic-tac-toe-any-size-board.js
Created June 29, 2018 08:48
Made a tic-tac-toe game in js and jquery that will work at any size board in as few lines as possible
// <input type="range" id="size" min="3" max="10" value="3">
// <div class="board">
// </div>
let p = 0;
const s = [];
let size = +$('#size').val() //set size to default
const makeBoard = function() {
size = +$('#size').val() //get size from input
@zailleh
zailleh / atm.js
Last active June 24, 2018 09:04 — forked from ellijayne/atm bank js
atm bank html
$(document).ready(function() {
const balance = {
savings: 0,
checking: 0
};
//CHANGING COLOR ON $0...
const zeroBalance = function() {
if (balance['savings'] === 0) {
@zailleh
zailleh / GLaDOS_Shell.sh
Last active June 18, 2018 11:41
Script for printing a random welcome message from GLaDOS
################################################################################
# GLaDOS SHELL Welcome Messages!
################################################################################
# Colours Variables
RESET="\033[0m"
BOLD="\033[1m\e[38;5;214m"
ORANGE="\e[38;5;208m"
# FUN GLaDOS QUOTES!!!
echo "${BOLD}Initialising GLaDOS...${RESET}"
// sum shopping cart items js
// shopping cart object
const cartForParty = {
banana: "1.25",
handkerchief: ".99",
Tshirt: "25.01",
apple: "0.60",
nalgene: "10.34",
proteinShake: "22.36"
@zailleh
zailleh / example.js
Created June 16, 2018 08:38
array.push example.js
//create empty array of bank accounts
let bankAccounts = []
// function to create a new account
const addAccount = function( name, amount ) {
// create new account object
let newAccount = {
accountName: name,
balance: amount
@zailleh
zailleh / Export-ADUserImages.ps1
Last active May 4, 2018 01:48
Powwershell script that will extract Active Directory user Thumbnail Images to files. Output directory is the only parameter. Will use your local/default domain controller & domain.
################################################################################
# AD PROFILE PICTURE EXTRACTOR #
################################################################################
# THIS SCRIPT WILL GET THE thumbnailPhoto ATTRIBUTE FROM ACTIVE DIRECTORY USER #
# AND SAVE TO JPEG #
# #
# AUTHOR: TIM CALDWELL #
# DATE: 21/02/2014 #
################################################################################
param(