Skip to content

Instantly share code, notes, and snippets.

View craigpalermo's full-sized avatar

Craig Palermo craigpalermo

View GitHub Profile
@craigpalermo
craigpalermo / ssl_upgrade.sh
Last active August 29, 2015 13:58
Upgrade OpenSSL to 1.0.1g
cd /usr/src
wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
tar -zxf openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
./config
make
make test
make install
cd /usr/src
rm -rf openssl-1.0.1g.tar.gz
@craigpalermo
craigpalermo / create_home_folders.sh
Created April 24, 2014 18:51
Create home folders for existing Linux users
#grab regular users with user id above 500 from /etc/passwd
awk -F: '$3 > 499' /etc/passwd > uid500+.txt
#extract username, create home directory, and apply home directory to user
for users in `awk -F: '{print $1}' uid500+.txt`
do
mkdir /home/$users
usermod -d /home/$users $users
chown $users:$users /home/$users
done
@craigpalermo
craigpalermo / create_users.sh
Last active August 29, 2015 14:01
Create an account for each user listed in the external file
#!/bin/sh
# Example:
# sh create_users.sh file_with_usernames.txt
if [ -z "$1"] # check if filename is given
then
echo "No input filename given, exiting."
else
while read NAME; do
@craigpalermo
craigpalermo / wsgi.py
Last active August 29, 2015 14:03
wsgi.py for django project
import os, sys
path = '/path/to/project'
settings_module = 'myapp.settings'
if path not in sys.path:
sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
@craigpalermo
craigpalermo / fake_keypress.py
Last active August 29, 2015 14:03
As long as it's running, it simulates pressing the F16 key every 5 seconds to trick messaging clients into thinking that you're still active.
import win32api, win32com.client
import time, sys
# open a shell to type into
shell = win32com.client.Dispatch("WScript.Shell")
while True:
# just some dots to show that it's still running
sys.stdout.write('.')
sys.stdout.flush()
@craigpalermo
craigpalermo / move_videos.py
Last active August 29, 2015 14:03
This script moves the largest file in each folder in the directory that it's run from into that directory.
'''
This script moves the largest file from each subdirectory into the
same directory that the script is run from.
Before:
/root
/episode1
e1.avi
...
/episode2
@craigpalermo
craigpalermo / Stylus Style Guide.md
Last active August 29, 2015 14:05
A set of general guidelines to create awesome looking stylesheets with Stylus

Stylus Style Guide

Data Exchange is going to use Stylus as its CSS preprocessor. Learn good style, and it will be your friend.

This guide includes content adapted from the Obvious Corporation's LESS style guide for Stylus.

Naming Conventions

@craigpalermo
craigpalermo / rotate_array.py
Created September 4, 2014 15:15
Interview question, rotate elements in 2D array 90 degrees clockwise
n = 5
arr = []
# populate array
for i in range(0, n):
arr.append([])
for j in range(0, n):
arr[i].append(j)
# print before
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
from tweepy import Stream
from tweepy import API
from cleverbot import Cleverbot
import json
import sys
consumer_key = ""
for object in objects
object['place'] = object['@place']