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/env python26 | |
# original from https://gist.github.com/1329319 | |
import redis | |
import random | |
import sys | |
r = redis.Redis(host = 'localhost', port = 6380) | |
REDIS_SETGET = False |
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 | |
for host in `cat /etc/huddler/site-config.txt | grep -v ^# | awk '{ print $2 }' | sed "s/www\.//"`; do | |
echo -n "$host: "; | |
dig $host a +short | tail -1; | |
done |
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
-- replacement | |
-- explain analyze @ 0.32ms | |
WITH a_user_albums AS ( | |
SELECT * | |
FROM gallery_albums | |
WHERE | |
user_id = 1 AND | |
type != 'private' AND | |
category_id IN (SELECT id FROM user_gallery_album_category_visibility(0)) AND | |
(status & 1)::bool |
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
; [SPOILER=Iterative][CODE]#include <stdio.h> | |
(define (print-* n) | |
(if (= n 0) | |
(display "\n") | |
(and | |
(display "* ") | |
(print-* (- n 1))))) | |
(define (print-full-* n) | |
(and |
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/perl | |
use strict; | |
my %object_map = {}; | |
while (my $line = <>) { | |
if ($line =~ /.*?"GET (.*) HTTP\/\d\.\d" \d+ (\d+).*HIT/) { | |
my $url = $1; | |
my $size = $2; | |
$object_map{$url}{'size'} = $size; |
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
cat access.log | awk '{ a[$2]++ } END { for (d in a) { printf("%d %s\n", a[d], d) } }' | sort -nr | less |
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 | |
TMP=$(mktemp) | |
awk '{ a[$2]++ } END { for (d in a) { printf("%d %s\n", a[d], d) } }' | sort -nr > $TMP | |
head -20 $TMP | |
echo "see $TMP for the whole list" |
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 | |
TMP=$(mktemp) | |
awk '{ a[$2]++ } END { for (d in a) { printf("%d %s\n", a[d], d) } }' | sort -nr > $TMP | |
count=0 | |
while read line; do | |
count=$(echo $line | awk '{ print $1 }') | |
ip=$(echo $line | awk '{ print $2 }') | |
company=$(jwhois $ip | grep -i OrgName | awk -F':' '{ print $2 }') | |
echo "$count $ip $company" |
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/perl | |
# vim: set ts=4 | |
use strict; | |
my $hitsize = 0; | |
my $misssize = 0; | |
my $hitcount = 0; | |
my $misscount = 0; | |
my $botcount = 0; |
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
(def C (string :utf-8 :delimiters " ")) | |
(def K (string :utf-8 :delimiters " ")) | |
(def V (string :utf-8 :delimiters " ")) | |
(def CR (string :utf-8 :delimiters ["\r\n"])) | |
defcodec SET ["SET" CR]) | |
(defcodec STORED ["STORED" CR]) | |
;STORED\r\n | |
(defcodec GET ["GET" CR]) |