Skip to content

Instantly share code, notes, and snippets.

View daryltucker's full-sized avatar

Daryl Tucker daryltucker

  • Neo-Retro Group
  • Salem, Or
View GitHub Profile
@daryltucker
daryltucker / objectid_to_epoch.py
Created February 7, 2014 01:03
Convert ObjectId into Epoch
import datetime
import calendar
import time
def objectid_to_epoch(_id)
epoch = datetime.datetime.fromtimestamp(int(str(_id)[0:8], 16))
return calendar.timegm(datetime.datetime(epoch.year, epoch.month, epoch.day, epoch.hour, epoch.minute).utctimetuple())
@daryltucker
daryltucker / pp.py
Created February 13, 2014 20:08
Python Pretty Print Helper Function
import pprint
def pp(data, ro=False):
"""Format for pretty print."""
if not ro:
pprint.pprint(data, indent=4, width=10)
return pprint.pformat(data, indent=4, width=10)
@daryltucker
daryltucker / 2014-Security_and_Trust_on_the_Web.mkd
Last active August 29, 2015 13:56
Security and Trust on the Web

Security and Trust on the Web

Daryl Tucker

Cryptography

Encryption


Decryption

@daryltucker
daryltucker / nginx_server
Last active August 29, 2015 13:57
Skeleton NGINX Configuraton (Forces SSL)
server{
server_name domain.tld;
rewrite ^ https://domain.tld$request_uri? permanent;
}
server{
ssi on;
listen 443;
server_name domain.tld;
@daryltucker
daryltucker / wget-download.sh
Created April 14, 2014 18:36
Download a specific subdirectory of a website while preserving referenced media.
#!/bin/bash
# @daryltucker
# This will download files within a specific directory but preserve media. For example:
# www.domain.tld/subdirectory/
# index.html
# page1.html (contains an image on www.domain.tld/images)
# page2.html (contains an image on www.domain.tld/)
wget -p -r -l1 --no-parent "$@"
setInterval(function(){
var x = document.getElementsByTagName('a');
console.log(x);
for ( var i=0; i<x.length; i++) {
x[i].click();
};
}, 500);
@daryltucker
daryltucker / linux_kernel_compile.mkd
Last active August 29, 2015 14:05
Compiling a new Kernel using old configuration.

Copy current kernel configuration to linux source

cp -vi /boot/config-`uname -r` .config

Decide about new kernel options

Use the following if you wish to only build modules for devices currently in use/connected. For example, if you don't have any usb_storage devices, you won't be able to plug in usb drives.

make localmodconfig

Compile the kernel

make -j6

Compile kernel modules

@daryltucker
daryltucker / relative_tar_path.py
Created August 24, 2014 18:54
python - tarfile - Relative Paths
import tarfile
import glob
import tempfile
FILENAME = 'Title_for_your_file'
t_dir = t_dir = tempfile.mkdtemp(prefix='app-')
# Compress t_dir
tarname = '/tmp/%s.tar.bz2' % (FILENAME)
fileobj = open(tarname, 'wb')
@daryltucker
daryltucker / git-pull-global.sh
Last active August 29, 2015 14:06
Pull all git repositories within a specific directory.
#!/bin/bash
pwd=`pwd`
git_directory='/home/daryl/Projects/*'
for d in $git_directory;
do
echo $d
cd $d
git fetch --all
git pull --all
done
@daryltucker
daryltucker / url_norm.py
Created October 23, 2014 19:25
Normalize URLs
import urlparse
def url_norm(url, scheme='http'):
response = 0
try:
x = urlparse.urlsplit(url, scheme=scheme)
response = '%s://%s%s' % (x.scheme, x.netloc, x.path)
except Exception:
pass