Skip to content

Instantly share code, notes, and snippets.

View connorjan's full-sized avatar

Connor Goldberg connorjan

View GitHub Profile
@connorjan
connorjan / rsub.md
Last active March 6, 2024 21:06
Editing Files Remotely via SSH on SublimeText 3

Editing Files Remotely via SSH on SublimeText 3

Sometimes you need to edit a file on a remote server, but using vim/emacs is not very practical, due to lag and speed of screen refresh.

TextMate users have the classic rmate, but it was implemented in Ruby, which may not be available on the remote server.

A better option is to use this version of rmate, implemented in pure Bash. It's a single file, self-contained, and with no external dependencies.

Step by step:

@connorjan
connorjan / PiEthernetOverUSB.md
Last active March 18, 2017 19:53
Setting up Ethernet over USB on a Raspberry Pi Zero

How to enable Ethernet/SSH over USB on a Raspberry Pi Zero

  1. Flash the latest kernel onto an SD card using the instructions here: https://www.raspberrypi.org/documentation/installation/installing-images/README.md

  2. Mount the SD card and browse to the boot partition using a file browser

  3. Enable the USB controller by opening up the config.txt file and adding a new line which contains the following: dtoverlay=dwc2

  4. Enable the ethernet gadget driver by opening up the cmdline.txt file and add the following text to the end of the line: modules-load=dwc2,g_ether

@connorjan
connorjan / common.py
Last active June 23, 2017 23:05
Common python functions
def expand(lst):
""""
Expand a list/tuple of lists/tuples of lists/tuples of ... of values into a single list
"""
exp = []
for item in lst:
if type(item) is list or type(item) is tuple:
exp += expand(item)
else:
exp.append(item)
#!/usr/bin/env python
import random
faces = ["U","D","L","R","F","B"]
modifiers = ["", "'", "2"]
min_scramble_len = 16
max_scramble_length = 20

Keybase proof

I hereby claim:

  • I am connorjan on github.
  • I am connorjan (https://keybase.io/connorjan) on keybase.
  • I have a public key whose fingerprint is DB55 6494 216F CD37 478A D420 DFE6 88D9 E17E 605D

To claim this, I am signing this object:

@connorjan
connorjan / Monitoring Processes on Raspberry Pi.md
Last active July 4, 2019 08:48
How to setup daemontools to monitor processes on Raspberry Pi

Monitoring Processes on Raspberry Pi

  1. Install daemontools

$ sudo apt-get install daemontools daemontools-run

  1. Create the service directory if not created by daemontools

$ sudo mkdir -p /etc/service

@connorjan
connorjan / Raspberry Pi Multi-User Boot Script Setup.md
Last active April 12, 2017 15:23
Guide to setting up automatic boot scripts for multiple users on a Raspberry Pi

Raspberry Pi Multi-User Boot Script Setup

This will show how you can setup scripts that will run on bootup of a Raspberry Pi. Any user in the /home/ directory where the name of the user matches the name of their home directory will be able to take advantage of this setup, as well as the root user.

  1. Add the following code to the file: /etc/rc.local, but be sure to leave the last line of the file as exit 0
# Startup scripts
## Root
if [ -f /root/startup.sh ]; then
import socket
import struct
import argparse
import binascii
parser = argparse.ArgumentParser(version="0.1",description='Magic packet sender')
parser.add_argument('--mac', action="store", default=None, required=True, help="The mac address to wake up")
arg = parser.parse_args()
import MySQLdb
import CSServer
import time
"""
This script will update your cs server's maplist file for you based on tiers that are stored in a database.
To get it to work, make sure that you have the 'CSServer.py' file in the same directory as this script,
then change the variables in the 'global variables' section as needed.
This will overwrite the map list file as needed, and will append changes to the new maps text file if enabled.
import os
import re
import urllib2
class CSServer:
def __init__(self, minTier, maxTier, mapType, mapsFilePath, mapsDirectory, fastDlServer = ""):
self.MinTier = minTier
self.MaxTier = maxTier
self.MapType = mapType