Skip to content

Instantly share code, notes, and snippets.

View daspecster's full-sized avatar
🏠
Working remote

Thomas Schultz daspecster

🏠
Working remote
View GitHub Profile
@daspecster
daspecster / multi-process-logging.py
Last active August 29, 2015 14:24
Multi process logging with os.fork() and logging module
import os
import logging
def generate_primes(number):
logger = logging.getLogger(str(os.getpid()) + ':logger')
for num in range(number + 1):
# prime numbers are greater than 1
if num > 1:
from math import log
def to_decimal(n, base):
if n < 10:
return n
p = int(log(n, 10))
msb = base ** p
n -= 10 ** p
@daspecster
daspecster / GulpFile.js
Created May 8, 2015 02:58
ReactTheme GulpFile
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
gulp.task('sass', function () {
gulp.src(['./css/theme.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(concat('theme.css'))
.pipe(gulp.dest('./css/compiled/'));
});
@daspecster
daspecster / next_page.php
Created March 11, 2015 00:16
PHP Ziptastic multi-step form example page 2
<?php
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"x-referrer: " . $_SERVER['HTTP_REFERER'] . " \r\n"
)
);
$postal_code = strip_tags(htmlspecialchars($_POST['postalcode'], ENT_QUOTES));
@daspecster
daspecster / page.html
Last active August 29, 2015 14:16
PHP Ziptastic multi-step form example page 1
<html>
<body>
<form action="/next_page.php" method="get">
Postal Code: <input type="text" name="postalcode">
<input type="submit">
</form>
</body>
</html>
@daspecster
daspecster / Availability-Indicator.markdown
Last active August 29, 2015 14:16
Availability Indicator

Availability Indicator

This is a simple way to indicate the best times for a client to contact you via a given medium. This could be used for chat, twitter, skype etc...

TODO: Add in timezone support.

A Pen by Thomas Schultz on CodePen.

License.

@daspecster
daspecster / gist:6111937171e0f83c1391
Created February 25, 2015 19:10
GetZiptastic.com Version 3 jQuery example
$.ajax({
type: "GET",
beforeSend: function(request) {
request.setRequestHeader("x-referrer", "<your domain here. example.com>");
request.setRequestHeader("x-key", "<your api key here>");
},
url: "https://zip.getziptastic.com/v3/US/48867",
success: function(data) {
console.log(data);
}
@daspecster
daspecster / postgres-backup.txt
Last active May 17, 2017 23:03
Postgres Backup
Backup and restore databases
# Backup
pg_dump -h <orig db> -U <user> -Fc > data.backup
psql in to db...
$ drop schema public cascade;
$ \connect postgres
$ drop database <dbname>;
@daspecster
daspecster / Code-Standards.md
Last active August 29, 2015 14:05
Code Standards and Resources
@daspecster
daspecster / update-python-ec2.sh
Last active March 22, 2016 06:27
Update EC2 Python virtualenv
# Thanks to Sebastian Kreutzberger
# Source: http://www.lecloud.net/post/61401763496/install-update-to-python-2-7-and-latest-pip-on-ec2
# install build tools
sudo yum install make automake gcc gcc-c++ kernel-devel git-core -y
# install python 2.7 and change default python symlink
sudo yum install python27-devel -y
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python