Skip to content

Instantly share code, notes, and snippets.

@myano
myano / logger.py
Created September 6, 2012 14:38
This file runs in a cronjob every minute to check if logger.py is currently an actively running process. One limitation to this is that if a netsplit occurs the process will still be running but the connection to the server might not exist anymore or the
#!/usr/bin/env python
"""
Checks to see if loggy.py is running
"""
import os
import time
from subprocess import *
i = 0
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:myano/test.git
git push -u origin master
title (b): ['\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\
x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '
\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f',
'\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3',
'\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', ' ', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '
\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', '\xf3', '\xa0', '\x81', '\x9f', ' ', '-', ' ', 'P', 'a', 's', 't', 'e', 'b', 'i'
.', 'c', 'o', 'm']
title (a): ['\xf3', '\xa0', '\xf3', '\xa0',
@myano
myano / gist:5016700
Last active December 14, 2015 02:49
This will convert a given password "foobar" into the SHA output that Apache uses for it's .htpasswd files. You can take the output of this command and simply append it with a "username_here:{SHA}" and then place it into a .htpasswd is pointing at. This is useful if you want someone to generate a password for you but they don't have Apache instal…

Without salt:

$ echo -n "foobar" | sha1sum | cut -d' ' -f1 | xxd -r -p | base64

With salt:

$ USR="yourname";PWD="foobar";SALT="$(openssl rand -base64 3)";SHA1=$(printf "$PWD$SALT" | openssl dgst -binary -sha1 | sed 's#$#'"$SALT"'#' | base64); echo "$USR:{SSHA}$SHA1"

@myano
myano / join.py
Last active December 14, 2015 03:29
If you have saved your buffers in WeeChat with "/layout save", this script will print out an easy to copy/paste "/join #channel1,#channel2" that you can paste into WeeChat to join channels. If you have a lot of channels (more than 100). I would recommend joining only about 75-100 channels at a time.
#!/usr/bin/env python
import copy
f = open('weechat.conf', 'r')
formats = ['/join ', '/query ']
networks = {
1361852798.62 {'updated': u'2013-02-25T13:24:00-06:00', 'updated_parsed': time.struct_time(tm_year=2013, tm_mon=2, tm_mday=25, tm_hour=19, tm_min=24, tm_sec=0, tm_wday=0, tm_yday=56, tm_isdst=0), 'published_parsed': time.struct_time(tm_year=2013, tm_mon=2, tm_mday=25, tm_hour=19, tm_min=24, tm_sec=0, tm_wday=0, tm_yday=56, tm_isdst=0), 'author': u'w-nws.webmaster@noaa.gov', 'authors': [{'name': u'w-nws.webmaster@noaa.gov'}], 'guidislink': True, 'title_detail': {'base': u'http://alerts.weather.gov/cap/us.php?x=1', 'type': u'text/plain', 'value': u'Air Quality Alert issued February 25 at 1:24PM CST by NWS', 'language': None}, 'link': u'http://alerts.weather.gov/cap/wwacapget.php?x=IA124EEEEBFDD0.AirQualityAlert.124EEEF9D720IA.DMXAQAIA.b87599e40e16d2fecbdbab91f0e74ff2', 'published': u'2013-02-25T13:24:00-06:00', 'title': u'Air Quality Alert issued February 25 at 1:24PM CST by NWS', 'author_detail': {'name': u'w-nws.webmaster@noaa.gov'}, 'id': u'http://alerts.weather.gov/cap/wwacapget.php?x=IA124EEEEBFDD0.AirQual
» cat gen.sh
rm -rf /var/www/yanovich.net/public/blog/
mkdir /var/www/yanovich.net/public/blog/
mkdir /var/www/yanovich.net/public/blog/theme
pelican -D -s /var/www/yanovich.net/public/blog_src/pelican.conf.py /var/www/yanovich.net/public/blog_src/ -o /var/www/yanovich.net/public/blog/
» ./gen.sh
Traceback (most recent call last):
File "/usr/local/bin/pelican", line 9, in <module>
load_entry_point('pelican==3.2', 'console_scripts', 'pelican')()
@myano
myano / example.php
Last active December 14, 2015 08:39
This is an example of a styling preference seen in PHP that I find annoying.
<?php
echo "I find this format for the brackets annoying.";
if (mynum < 10) {
echo "low";
}
else {
echo "yay!";
}
@myano
myano / reqs.py
Created March 4, 2013 18:16
This is the script that powers reqs.py on lmddgtf.net. This script actually runs in a cronjob every 20 minutes. The reqs.py on http://lmddgtfy.net/reqs.py prints the output of this to the screen.
#!/usr/bin/env python
# -*- coding: utf8 -*-
from subprocess import Popen, PIPE
import datetime
import re
def main():
f = open("/var/www/lmddgtfy.net/logs/reqs.txt", "w")
@myano
myano / html.py
Created March 13, 2013 18:20
HTML Entities / Encodings. These are what characters are turned into when properly parsed in a URL.
#!/usr/bin/env python
# vim: set fileencoding=UTF-8 :
HTML_ENCODINGS = {
" ": "%20",
"!": "%21",
'"': "%22",
"#": "%23",
"$": "%24",
"%": "%25",