Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View stevenschobert's full-sized avatar

Steven Schobert stevenschobert

View GitHub Profile
@stevenschobert
stevenschobert / log.js
Last active August 19, 2016 05:31
My personal Log utility. Has option to set log level.
var Log = {
_levelInt: function levelInt() {
return this._levels.indexOf(this.level);
},
_intForLevel: function intForLevel(level) {
return this._levels.indexOf(level);
},
_logForLevel: function logForLevel() {
if (!console) { return; }
@stevenschobert
stevenschobert / preload_test.html
Created July 13, 2016 21:36
Demonstrating how programmatically loading images in HTML pages affects network calls
<html>
<body>
<title>Image Preloading Test</title>
<meta charset="utf-8" />
</body>
<div id="target">Loading...</div>
<button id="load">start</button>
<script>
@stevenschobert
stevenschobert / ntlm_authentication_example.swift
Created June 17, 2016 14:00
Example of NTLM authentication in iOS using NSURLSession
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var execButton: UIButton!
var username: String? = nil
var password: String? = nil
lazy var conn: NSURLSession = {
@stevenschobert
stevenschobert / fix_haproxy_ssl_tls1.sh
Created June 3, 2016 04:44
Fix disabled TSL1.0 support in running HAProxy container
cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bkup
cat /etc/haproxy/haproxy.cfg | sed 's/ssl-default-bind-options no-sslv3 no-tlsv10/ssl-default-bind-options no-sslv3/' > /etc/haproxy/haproxy.cfg
/etc/init.d/haproxy restart
@stevenschobert
stevenschobert / safari_find_or_open_url.scpt
Created June 1, 2016 22:43
AppleScript to find existing tab with URL, or open a new one.
tell application "Safari"
set topWindows to every window whose name is not ""
set numWindows to the number of topWindows
set didFind to false
set targetUrl to "http://localhost:3000/"
repeat with x from 1 to numWindows
set numTabs to the number of tabs in window x
repeat with y from 1 to numTabs
set tabUrl to the URL of tab y of window x
@stevenschobert
stevenschobert / hide_github_diffs.js
Last active May 31, 2016 15:30
Hide certain files in a GitHub diff based on file path.
function hideNodes(matcher) {
var fileNodes = document.querySelectorAll("#files .file");
var indeciesToHide = [];
var tester = (typeof matcher === "string") ? new RegExp(matcher) : matcher;
var fileHeader;
var filePath;
for (var i=0; i < fileNodes.length; i++) {
fileHeader = null;
filePath = null;
@stevenschobert
stevenschobert / dropbox_backup.sh
Last active August 26, 2016 15:15
My go-to hacky backup solutions: gzip directories up to Dropbox! Uses https://github.com/andreafabrizi/Dropbox-Uploader
#!/usr/bin/env bash
MAX_NUM_BACKUPS=10
DB_LOCATION=/root/dropbox_uploader.sh
DB_CONFIG=/root/.dropbox_uploader
BACKUP_FILENAME=ss_ranch_bkup
BKP_DIRS="/home/docker/rancher /home/docker/nginx"
EXCLUDE_DIRS="/home/docker/nginx/ssl"
TMP_DIR="/tmp/"
@stevenschobert
stevenschobert / centos_7_setup.md
Last active December 29, 2021 01:38
My setup guide for CentOS 7

Start

Add non-root user

adduser deploy
passwd deploy

Update system packages

@stevenschobert
stevenschobert / load_remote_content_mail_dot_app.scpt
Last active January 12, 2022 11:19
Apple Script to click the "Load Remote Content" button. I like to disable all remote content in Mail.app, and then bind this script to a keyboard shortcut using Keyboard Maestro. https://www.keyboardmaestro.com
tell application "System Events" to tell process "Mail"
set mainWindow to a reference to the first window
set rootSplitter to a reference to the first splitter group of the mainWindow
set firstSplitter to a reference to the last splitter group of the rootSplitter
set scrollArea to a reference to the last scroll area of the firstSplitter
set scrollGroup to a reference to the first group of the scrollArea
if number of groups of the scrollGroup is greater than 1 then
set maybeRemoteContentGroup to a reference to the first group of the scrollGroup
@stevenschobert
stevenschobert / image-preload.js
Created April 18, 2016 17:09
Image preloader
/**
* Loads images for a section of dom tiles. Loads the image in the
* background and then removes loading indicators once loaded.
*
* Takes an array of dom nodes, a single dom node, or a css selector.
*/
function loadTileImages(imageEls) {
if (typeof imageEls !== 'string' && !Array.isArray(imageEls)) {
imageEls = [imageEls];
}