Skip to content

Instantly share code, notes, and snippets.

View cgoldberg's full-sized avatar
☠️
¯\_(ツ)_/¯

Corey Goldberg cgoldberg

☠️
¯\_(ツ)_/¯
View GitHub Profile
@cgoldberg
cgoldberg / num_cpu_cores.py
Created November 1, 2015 00:06
Find the number of CPU cores (Linux)
def num_cpu_cores():
with open('/proc/cpuinfo') as f:
return f.read().count('processor')
@cgoldberg
cgoldberg / selenium-rum.py
Last active April 8, 2018 02:21
selenium-rum
"""
Instructions
************
1. install ubuntu deps:
-----------------------
sudo apt-get python-pip
sudo apt-get install firefox
sudo apt-get install chromium-browser
@cgoldberg
cgoldberg / bounce_services.sh
Created October 5, 2015 16:54
bounce supervisor controlled services
#!/bin/bash
# Bounce services and print start/stop messages to console and /var/log/syslog.
logger -s Restarting all processes controlled by supervisor now...
logger -s $(/usr/bin/supervisorctl restart all)
# Scheduled by system cron to run every hour:
# 0 */1 * * * /deploy/bounce_services.sh
@cgoldberg
cgoldberg / got_root.py
Created November 1, 2015 00:04
check if the process is running as root (Unix/Linux)
import os
def got_root():
"""check if we are running as root."""
if os.geteuid() == 0:
return True
return False
@cgoldberg
cgoldberg / keybase.md
Created December 8, 2017 20:11
Keybase proof

Keybase proof

I hereby claim:

  • I am cgoldberg on github.
  • I am cgoldberg (https://keybase.io/cgoldberg) on keybase.
  • I have a public key ASDk5SpG1Ab5cbPjZP2kcdVjLxyEN2_QbT-RMz1E_r5tuAo

To claim this, I am signing this object:

@cgoldberg
cgoldberg / sniff.txt
Created October 24, 2017 20:09 — forked from manifestinteractive/sniff.txt
A friendly formatter for curl requests to help with debugging.
\n
============= HOST: ==========\n
\n
local_ip: %{local_ip}\n
local_port: %{local_port}\n
remote_ip: %{remote_ip}\n
remote_port: %{remote_port}\n
\n
======= CONNECTION: ==========\n
\n
@cgoldberg
cgoldberg / pldiffs.md
Last active April 8, 2018 02:21
compare .plist changes between 2 git branches

Comparing p-lists (iOS Property List Files)

In OS X and iOS programming frameworks, property list files are used to store information about bundles and applications. Analyzing .plist files can tell you a lot about an application. It is often useful to compare content and view modifications to .plist files to understand what has changed between versions of an application.


  • list paths of .plist files modified between 2 branches
@cgoldberg
cgoldberg / file-rename-strip-digits.sh
Created October 8, 2018 21:54
shell one-liner - rename files in current directory with digits stripped from filenames
# rename files in current directory with digits stripped from filenames
# first do a dry-run (only print the commands that will be applied)
for f in *; do echo mv "$f" $(printf '%s' "$f" | tr -d '0123456789'); done
# run it for real (modifications done in-place)
for f in *; do mv "$f" $(printf '%s' "$f" | tr -d '0123456789'); done
@cgoldberg
cgoldberg / update_webdrivers.sh
Created July 16, 2018 18:52
Install geckodriver/chromedriver for Linux (64 bit)
#!/usr/bin/env bash
#
# Install WebDrivers for Linux
# ----------------------------
# * Binary webdrivers are required to drive Firefox and Chrome browsers from Selenium.
# * This script will fetch the 64-bit binaries (geckodriver/chromedriver) for Linux.
set -e
@cgoldberg
cgoldberg / check_root.bash
Last active November 25, 2018 07:56
got root?
# add this to the beginning of a bash script to ensure it can only be run with root access.
if [[ $EUID -ne 0 ]]; then
echo "permission denied."
echo "$(basename $0) must be run as root."
exit 1
fi