Skip to content

Instantly share code, notes, and snippets.

View chris-x86-64's full-sized avatar

Christopher Smith chris-x86-64

View GitHub Profile
import sys
import random
ZUN = 'ズン'
DOKO = 'ドコ'
KIYOSHI = 'キヨシ!'
class ZunDoko(object):
def __init__(self):
self.words = list()
@chris-x86-64
chris-x86-64 / aliases
Last active April 14, 2016 04:33
Login alert system using sendmail and Slack
# Add the following line to /etc/aliases
slack: |"/usr/bin/python /path/to/post-to-slack.py"
@chris-x86-64
chris-x86-64 / login-alert.py
Created April 13, 2016 11:35
A Python script which posts login alerts to Slack webhook. (Requires 'who' command)
import socket
import commands
import urllib
import urllib2 as urlrequest
import json
from datetime import datetime
SLACK_POST_URL = "https://hooks.slack.com/services/[TOKEN]"
def build_attachment():
@chris-x86-64
chris-x86-64 / gist:2e3ac9846fa5cea374f4
Created December 22, 2014 05:58
Example Perl-CGI Apache2 config
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName aho.baka.com
DocumentRoot /home/aho/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/aho/app/>
@chris-x86-64
chris-x86-64 / minecraft.conf
Created August 3, 2014 05:46
Minecraft semi-auto startup using Upstart. Used in conjuction with the "Auto-Shutdown" mod.
description "Minecraft SemiAuto-Startup"
start on socket PROTO=inet PORT=25565
stop on runlevel [06]
console log
chdir /home/minecraft/whatever
setuid minecraft
setgid minecraft
respawn
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDdEfXyAQME2SXo7kUpUNq+pMpAm60fSNct0WKiRRXv1Z2HBT3VUKVH9aq2CYH+7wDQG8xrZmSu+gSSTy909nkEYJz8682ujdHLUwpnxKC3ADJZrmI5vWDqxlb8lv/Q7f3Kru6D4Z00qRQ5I/V8ycESyjfEd+X2SCsPwAvbINXfipSX2+8rwExDQ+Dy8C0ierOwqSZVDA34tBSFLD5Jnk337C2vLjPaSuVbxbhjjwRDwOwwqLh0eLGzquxOSI4aoZZksyvXH4CFU9+cinD+7MkFkkCumVTHjYDffIFNwb1I3uaWy2+w0Lew18niJhpjvxTDzKEgvqnOEWyDKen+etkT chris@lambo
@chris-x86-64
chris-x86-64 / ocr.py
Last active August 31, 2015 00:51
Recursive batch OCR script (Requires Tesseract-OCR or Cuneiform).
import os
import sys
import json
from optparse import OptionParser
from PIL import Image
from pyocr import pyocr
from pyocr.builders import TextBuilder
def get_opt():
parser = OptionParser()
@chris-x86-64
chris-x86-64 / gist:8969525
Created February 13, 2014 04:01
An example of copyright disclaimer.
Copyright Disclaimer Under Section 107 of the Copyright Act 1976, allowance is made for "fair use" for purposes such as criticism, comment, news reporting, teaching, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favor of fair use.
@chris-x86-64
chris-x86-64 / age_calc.py
Last active January 4, 2016 02:39
Age calculator available for use at http://age.x86-64.jp/ Usage: curl http://age.x86-64.jp/1991/12/29 ... Response: "Age: 22"
from flask import Flask
from datetime import date
app = Flask(__name__)
app.config.update(
DEBUG=False,
)
@app.route('/')
def usage():
#!/usr/bin/env python
wavelength = input("Input the wavelength within 0.2~0.55um in um: ")
x = 0.389*wavelength + 0.09426/wavelength -0.3228
sigma = 4.02 * 10**(-28) / wavelength**(4 + x)
lnAB = input("Input the value of lnAB : ")
N = lnAB/sigma
print "cross section sigma/cm^-2 is : ", sigma
print "density N/(number/cm^-2) is : ", N