This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
def get_current_cpu(pid): | |
d = open("/proc/%s/stat" % pid, "r").readline().split() | |
return int(d[13]), int(d[14]) | |
def get_total_cpu(): | |
d = open("/proc/stat", "r").readline() | |
return sum(map(int, d.split()[1:])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
index index.php; | |
server_name .kyle-gibson.com; | |
location /blog { | |
if (!-e $request_filename) { | |
rewrite ^/blog/(.+)$ /blog/index.php/$1 last; | |
} | |
} | |
location ~* \.php(/.*)?$ { | |
include /etc/nginx/fastcgi_params; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import socket | |
import os | |
HOST = '' # Symbolic name meaning all available interfaces | |
PORT = 50007 # Arbitrary non-privileged port | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((HOST, PORT)) | |
s.listen(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# ./generate_email_with_attachment.py files.tar.bz2 [email protected] > email_output | |
from email.encoders import encode_base64 | |
from email.mime import Base, Multipart | |
from mimetypes import guess_type | |
def main(args): | |
file_path = args[1] | |
to = args[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <signal.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/time.h> | |
#define USECREQ 250 | |
#define LOOPS 1000 | |
void event_handler (int signum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from __future__ import with_statement | |
import sys | |
import asyncore | |
import socket | |
import time | |
def loop(addrs, klass, args): | |
servers = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Latest version is always available at: https://gist.github.com/815751 | |
# | |
# The MIT License | |
# | |
# Copyright (c) 2011 Kyle Gibson | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# https://gist.github.com/gists/1007083 | |
# Donate: 1BdWJEUCkm6on231iX2ThXZHXZDfQny69R | |
from __future__ import division | |
import json | |
import urllib2 | |
from smtplib import SMTP | |
from email.mime.text import MIMEText | |
from cStringIO import StringIO | |
from pprint import pprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST=foo.example.com | |
USER= | |
PASS= | |
IPADDR=$(wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//') | |
RESULT=$(wget -q -O- "https://$USER:[email protected]/nic/update?hostname=$HOST&myip=$IPADDR&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function get_gist_url($id) { | |
$data = file_get_contents("https://gist.github.com/$id"); | |
$pos1 = strpos($data, "/raw/$id"); | |
$pos2 = strpos($data, "\"", $pos1); | |
$url = substr($data, $pos1, $pos2-$pos1); | |
return "https://gist.github.com$url"; | |
} | |
$url = get_gist_url($_GET["id"]); | |
ob_start('ob_gzhandler'); |
OlderNewer