Skip to content

Instantly share code, notes, and snippets.

@swooningfish
swooningfish / .htaccess
Last active September 27, 2015 16:38
.htaccess file for apache2 and kohana
# Turn on URL rewriting
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_ADDR} !^192\.168\.0\.7
RewriteCond %{HTTP_HOST} ^(www.example\.com)(:80)?
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]
@swooningfish
swooningfish / check_ip.py
Created June 29, 2012 17:26 — forked from Morrolan/check_ip.py
RaspberryPi IP address emailer
#!/usr/bin/python
# The idea behind this script is if plugging a RaspberryPi into a foreign network whilst running it headless
# (i.e. without a monitor/TV), you need to know what the IP address is to SSH into it.
#
# This script emails you the IP address if it detects an ethernet address other than it's usual address
# that it normally has, i.e. on your home network.
import subprocess
import smtplib
@swooningfish
swooningfish / 1_Instructions.md
Created November 22, 2012 23:34 — forked from Daniel15/1_Twitter autoresponder bot.md
Twitter autoresponder bot

Twitter autoresponder bot

By Daniel15 (dan.cx) This is a very simple Twitter autoresponder bot. It requires PECL OAuth extension to be installed (run "pecl install oauth", or if on Windows, grab php-oauth.dll. If using cPanel you can install it via WHM). The authentication is designed for command-line usage, it won't work too well via a web browser. You'll have to sign up for an application on Twitter's site to get the consumer key and secret.

Could be modified to be more advanced (match regular expressions to answer questions, etc.)

#!/bin/bash
#
# myshaper - DSL/Cable modem outbound traffic shaper and prioritizer.
# Based on the ADSL/Cable wondershaper (www.lartc.org)
#
# Written by Dan Singletary (8/7/02)
#
# NOTE!! - This script assumes your kernel has been patched with the
# appropriate HTB queue and IMQ patches available here:
# (subnote: future kernels may not require patching)
#flush all rules
iptables -F
#drop all traffic on input and forward chains
iptables -P INPUT DROP
iptables -P FORWARD DROP
#allow ouput chain (it's trusted)
iptables -P OUTPUT ACCEPT
iptables -F
iptables -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
@swooningfish
swooningfish / ffmpeg.compile.sh
Last active March 11, 2019 22:25
Compile FFmpeg on Ubuntu
# Source from https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide
#Remove any existing packages:
sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
#Get the dependencies (Ubuntu Desktop users):
sudo apt-get update
sudo apt-get -y install autoconf build-essential checkinstall git libass-dev libfaac-dev \
@swooningfish
swooningfish / fetchurl.sh
Created January 7, 2013 00:46
Small utility to fetch and unpack archives on the web (with cache)
#!/bin/sh
#
# Small utility to fetch and unpack archives on the web (with cache)
#
# Depends on : curl, tar
#
set -e
set +u
find . | xargs grep 'string' -sl
find . -iname '*php' | xargs grep 'string' -sl
find . -name *.php | grep -lir "string" *
find . -name *.php | grep -lir "string" *
@swooningfish
swooningfish / kohana_db_escape.php
Created January 9, 2013 11:11
This removes the db escaping of kohana 2.x
<?
$config = Kohana::config('database.default');
$config['escape'] = FALSE;
$db = new Database($config);
$db->select("DISTINCT CONCAT(city, state, country) location");
// .. run query stuff..
?>