Skip to content

Instantly share code, notes, and snippets.

View montj2's full-sized avatar

James montj2

View GitHub Profile
@montj2
montj2 / fogcreek_apply.rb
Created April 28, 2014 15:12
The Fog Creek Dev Application Challenge @ http://www.fogcreek.com/Jobs/Dev/
hash = 910897038977002
letters = "acdegilmnoprstuw"
answer = ""
9.times do |x| #9 letter string loop
remainder = hash % 37 #get the remainder for lookup
answer = answer + letters[remainder] #add letter to the answer
hash = (hash - remainder) / 37 #now we're evenly divisible
@montj2
montj2 / gist:cc4d3640f4fafce55a65
Created June 1, 2015 01:48
checkout.js SSL fail
var checkout_data = {
product : "",
variation:0,
flavour_set :true,
selected_flavour:"",
specific_flavours:[]
};
function navigate_step(step){
$(".one_button .step").removeClass("active");
$("#step"+step).addClass("active");
@montj2
montj2 / conn_test.py
Last active October 22, 2016 19:07
Python TCP port check
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket # socket module
import sys # exit method(s)
def check_server(address, port):
# Create TCP Socket
s = socket.socket()
@montj2
montj2 / spotlight_fix.sh
Created August 22, 2017 13:17
MacOS 10.9 - 10.13 Spotlight Reindexing Fix
#!/bin/bash
# Check for root/sudo
if [ "$(id -u)" != "0" ]; then
echo "This script should not be run using sudo or as the root user"
exit 1
fi
# Turn off indexing
@montj2
montj2 / tlp-stat_ac
Created January 12, 2020 17:53
TLP 1.3.0-beta.2 [AC]
--- TLP 1.3.0-beta.2 --------------------------------------------
+++ Configured Settings:
TLP_ENABLE="1"
TLP_PERSISTENT_DEFAULT="0"
DISK_IDLE_SECS_ON_AC="0"
DISK_IDLE_SECS_ON_BAT="2"
MAX_LOST_WORK_SECS_ON_AC="15"
MAX_LOST_WORK_SECS_ON_BAT="60"
CPU_ENERGY_PERF_POLICY_ON_AC="balance_performance"
@montj2
montj2 / tlp-stat_batt
Created January 12, 2020 17:59
TLP 1.3.0-beta.2 [BATT]
--- TLP 1.3.0-beta.2 --------------------------------------------
+++ Configured Settings:
TLP_ENABLE="1"
TLP_PERSISTENT_DEFAULT="0"
DISK_IDLE_SECS_ON_AC="0"
DISK_IDLE_SECS_ON_BAT="2"
MAX_LOST_WORK_SECS_ON_AC="15"
MAX_LOST_WORK_SECS_ON_BAT="60"
CPU_ENERGY_PERF_POLICY_ON_AC="balance_performance"
@montj2
montj2 / vimrc
Created November 13, 2021 17:11
Standard vimrc
syntax on
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" change the leader key from \ to ,
let mapleader = ","
@montj2
montj2 / Transpose.py
Created June 15, 2023 14:40
Pandas sample
import pandas as pd
# Read the Excel spreadsheet into a pandas DataFrame
df = pd.read_excel('your_spreadsheet.xlsx')
# Specify the columns to keep intact
keep_columns = ['A', 'B', 'C']
# Specify the columns to be transposed
transpose_columns = ['1', '2', '3', '4', '5']
@montj2
montj2 / SSL-dump.py
Last active June 23, 2023 14:34
SSL Dump
import requests
import ssl
import certifi
import logging
# Disable SSL verification warning
requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)
# Configure logging
logging.basicConfig(level=logging.INFO)