Skip to content

Instantly share code, notes, and snippets.

View stollcri's full-sized avatar

Christopher Stoll stollcri

View GitHub Profile
@stollcri
stollcri / insert_text.sh
Created November 25, 2015 21:02
Insert text into a file at a specified line number
# insert ADDTHISTEXT at line 4 of MYFILE.TXT
sed -i '4i\ADDTHISTEXT\' MYFILE.TXT
@stollcri
stollcri / mysql_skip_forward.txt
Last active December 18, 2015 15:14
Forward a MySQL slave past problematic SQL commands
# It may become necessary to tell a MySQL replication slave to skip commands it
# is supposed to replicate. For eaxmple, if a table is deleted from the slave
# server and then it is deleted from the master server, the replication process
# will direct the slave to delete the table; since the table does not exist,
# the command cannot procees, and the replication gets stuck. The replication
# status on the slave cna be checked using 'SHOW SLAVE STATUS'. The slave drives
# replication, so the only way to check the stat us on the master is by using
# 'SHOW PROCESSLIST'
# see also:
# https://dev.mysql.com/doc/refman/5.7/en/replication-administration-status.html
@stollcri
stollcri / detach_process.txt
Created November 13, 2015 15:14
Detach a running process so that it can run after logout
$ myapp
$ Ctrl-z
[1]+ Stopped myapp
$ disown -h %1
$ bg 1
[1]+ myapp &
$ exit
@stollcri
stollcri / cat_awk_col40.sh
Created October 20, 2015 13:47
Print lines where the date in column 40 is September of 2015
#!/bin/bash
cat WIDE_TAB_DELIMITED.TXT | awk -F\t '$40 ~ /09\/.+?\/2015/' >> MATCH_COL_40_DATE_SEPT.TXT
@stollcri
stollcri / nmon_initd_debian_ubuntu
Last active October 16, 2015 13:39
Ubuntu (Debian) init.d script for nmon
#!/bin/sh
### BEGIN INIT INFO
# Provides: nmon
# Required-Start: $network $named $syslog
# Required-Stop: $network $named $syslog
# Should-Start: nmon
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
#
@stollcri
stollcri / ReplayKitExample.m
Last active May 9, 2018 18:11
Created a "Single View Application" project and added ReplayKit code to the ViewController files
//
// ViewController.h
// ReplayKitExample
//
// Created by Christopher Stoll on 6/11/15.
// Copyright © 2015 Christopher Stoll. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <ReplayKit/ReplayKit.h>

Keybase proof

I hereby claim:

  • I am stollcri on github.
  • I am stollcri (https://keybase.io/stollcri) on keybase.
  • I have a public key whose fingerprint is FD0D 1A69 8AD9 F05A 3052 707A 0D01 AA8F 51B2 E3EA

To claim this, I am signing this object:

@stollcri
stollcri / comparableGenerics.swift
Created June 7, 2014 14:38
Protocol type constraints for generics in Apple Swift
/*
* Here the Comparable protocol is used as the type constraint
* For equality testing the Equitable protocol would be needed
* To print a variable it must conform to the Printable protocol
*
* see also:
* https://developer.apple.com/library/prerelease/ios/documentation/General/Reference/SwiftStandardLibraryReference/Equatable.html#//apple_ref/doc/uid/TP40014608-CH17-SW1
*/
func min3a_generics<T: Comparable>(a: T, b: T, c: T) -> T {
if a < b {
@stollcri
stollcri / min.swift
Created June 6, 2014 15:13
Minimum Functions for 3 Integers (or Variadic) in Swift
import CoreFoundation
let TEST_ITTERATIONS = 100.0
let TEST_LOOPS = 100_000
func min3a(a: Int, b: Int, c: Int) -> Int {
if a < b {
if a < c {
return a
} else {
@stollcri
stollcri / min.c
Created June 6, 2014 15:11
Minimum Functions for 3 Integers in C
#include <stdio.h>
#include <limits.h>
#include <sys/time.h>
#define TEST_ITTERATIONS 100
#define TEST_LOOPS 100000
static inline int min3a(int a, int b, int c)
{
if (a < b) {