Skip to content

Instantly share code, notes, and snippets.

@ip2k
ip2k / gist:e7aaf66b4204110ef513ec006832c9ee
Created January 25, 2024 22:46
post-server-status.py
# -*- coding: utf-8 -*-
import valve.rcon
import requests
import json
import re
import http.client as http_client
# TODO update /home/tf2server/.local/lib/python3.6/site-packages/valve/rcon.py to set encoding=utf-8 so this will work
# CONFIG
min_players = 3 # min players to trigger a status post
@ip2k
ip2k / harwriter.py
Created January 23, 2017 22:10 — forked from rouli/harwriter.py
A script to create a HAR file out of a mitmproxy's dump file
#!/usr/bin/env python
import binascii, sys, json
import version, tnetstring, flow
from datetime import datetime
def create_har(flows):
return {
"log":{
@ip2k
ip2k / git-repo-mirror.sh
Created September 13, 2016 17:58
Mirror git repos via pull. Grabs all commits, tags, branches, etc and only grabs changes once the initial pull-down is complete.
#!/bin/bash
REPO_BASE_URL='ssh://git@repo.example.com:1234/some-project-space'
REPOS='foo bar baz quux'
echo -e "\e[1;95;102mStarted at $(date) \e[0m"
BASEDIR="${PWD}"
for repo in $REPOS; do
dirname="${repo}.git"
echo -e "Now processing \e[1;95m${dirname}\e[0m"
@ip2k
ip2k / gist:3d81507c810314991bdf
Last active January 2, 2016 07:06
Add Transmission button to Kickass.to (requires a modified CORSProxy running on 127.0.0.1:1337)
// ==UserScript==
// @name Kickass Add Button
// @namespace http://your.homepage/
// @version 0.1
// @description enter something useful
// @author You
// @match https://kickass.tld/*
// @grant none
// ==/UserScript==
#!/usr/bin/env ruby
require 'nokogiri'
require 'pp'
require 'open-uri'
require 'sqlite3'
# set our filename and path names up
DBNAME = 'favdb.sqlite' # filename for SQLite DB
@ip2k
ip2k / sinatra-geoip-demo.rb
Created September 29, 2011 20:12
GeoIP in Sinatra
require 'sinatra'
require 'geoip'
geo = GeoIP.new('GeoLiteCity.dat')
get '/' do
begin
x = geo.country request.ip
puts x.inspect
unless x[:postal_code].empty?
"ZIP for #{request.ip}: #{x[:postal_code]}"
@ip2k
ip2k / gist:1244249
Created September 27, 2011 03:23
possible ruby bug
#!/usr/bin/env ruby
require 'yaml'
hashy = Hash["a" => 100, "b" => 200]
puts hashy.inspect
YAML::dump(hashy, File.open('test.yaml', 'w'))
puts YAML::load_file('test.yaml') # attempt 1
File.open( 'test.yaml' ) { |yf| puts YAML::load( yf ) } # attempt 2
@ip2k
ip2k / .screenrc
Created February 11, 2015 22:22
.screenrc
startup_message off
activity "%c activity -> %n%f %t"
#caption always "%{= Wk}%-w%{= Bw}%n %t%{-}%+w %-="
#vbell off
term screen-256color
hardstatus on
hardstatus alwayslastline '%{= M} %H%{= G} %l %= %{= w}%-w%{+b r}%n*%t%{-b r}%{w}%+w %= %{c}%d %D %{B}%c '
escape ^\\
@ip2k
ip2k / gist:9cc5d879d41b79f0ec3a
Created February 3, 2015 02:34
javascript show show for n ms animation
window.fn.showFor = function (jqSelector, fadeOutTimeMs, fadeInTimeMs) {
// usage: rosetta.fn.showFor('#element-id', 5000) // shows #element-id for 5 seconds, then slow fades out
if (! fadeInTimeMs) { fadeInTimeMs = 1000; }
if (! fadeOutTimeMs) { fadeOutTimeMs = 5000; }
$(jqSelector).removeClass('hidden').fadeIn(parseInt(fadeInTimeMs));
setTimeout(function () {
$(jqSelector).fadeOut(1000, function () {
@ip2k
ip2k / .bash_profile
Created January 27, 2015 21:03
pipe stdout of any command to a HipChat room
alias hcpipe='tee >(cat >&2 >&1)| curl --location -XPOST https://api.hipchat.com/v2/room/HIPCHAT-API-ROOM-NUMBER/notification?auth_token=YOUR-HIPCHAT-NOTIFY-AUTH-TOKEN-FOR-THAT-ROOM -H "Content-Type: text/plain" -d "/code $(cat 2>&1)"'