Skip to content

Instantly share code, notes, and snippets.

View notsobad's full-sized avatar

notsobad notsobad

View GitHub Profile
@paulosuzart
paulosuzart / tornado_basic_auth.py
Created November 2, 2010 19:52
Sample (working) for basic http auth on tornado
def authenticated(auth):
def decore(f):
def _request_auth(handler):
handler.set_header('WWW-Authenticate', 'Basic realm=tmr')
handler.set_status(401)
handler.finish()
return False
@codebrainz
codebrainz / gist:1009404
Created June 5, 2011 20:44
On the fly tarball creation CGI script.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# archive.py
#
# Copyright 2011 Matthew Brush <mbrush@codebrainz.ca>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@wesleyhales
wesleyhales / confess-mod.js
Created July 26, 2012 20:52
phantom script
var fs = require('fs');
var confess = {
run: function () {
var cliConfig = {};
confess.performancecache = this.clone(confess.performance);
if (!this.processArgs(cliConfig, [
{
name: 'url',
def: 'http://google.com',
@NV
NV / most_used_css_property_names.js
Created September 19, 2012 18:47
PhantomJS script to collect most used CSS property names (supported by WebKit)
// phantomjs --web-security=no most_used_css_property_names.js
var urls = [
'http://google.com',
'http://facebook.com',
'http://youtube.com',
'http://yahoo.com',
'https://github.com/',
'http://twitter.com/',
'http://en.wikipedia.org/wiki/Main_Page',
@yonjah
yonjah / gist:5082855
Last active February 10, 2023 19:25
Blocking DDOS bots with JavaScript for fun and profit! Or how easy it is to break the current protection methods and how to make it better.
TL;DR - jump to the challenge at the end
====ON BLOCKING EVIL BOTS=====
On a resent job interview I had for "Incapsula" a few days ago I was put to the challenge to break
their bot protection mechanism. Apparently node.js is not that common among bot writes and most bots
are not able to run javascript.
The challenge had two parts -
1. find what the code does.
2. implement a bot that will break the code without using js.
3. think how to make this code unbreakable
@ssstonebraker
ssstonebraker / sed cheatsheet
Created August 2, 2013 14:06 — forked from un33k/sed cheatsheet
Sed Cheatsheet
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
@grenade
grenade / sane-gnome-settings.sh
Last active February 4, 2024 08:11
my personal gnome and fedora setup preferences
# Sane settings for Gnome
gsettings set org.gnome.desktop.background show-desktop-icons true
gsettings set org.gnome.desktop.interface clock-show-date true
gsettings set org.gnome.settings-daemon.plugins.xsettings antialiasing 'grayscale'
gsettings set org.gnome.settings-daemon.plugins.xsettings hinting 'slight'
gsettings set org.gnome.desktop.interface text-scaling-factor '1.0'
gsettings set org.gnome.desktop.interface monospace-font-name "Monospace 10"
gsettings set org.gnome.desktop.interface document-font-name 'Sans 10'
gsettings set org.gnome.desktop.interface font-name 'Cantarell 10'
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita'
@sergiotapia
sergiotapia / md5-example.go
Last active December 5, 2023 03:53
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@morhekil
morhekil / nginx.conf
Created August 14, 2014 12:18
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '