Skip to content

Instantly share code, notes, and snippets.

@nileshgr
nileshgr / gist:3388917
Created August 18, 2012 18:32
Delete all twitter DMs using this python script
#!/usr/bin/python2
# Go to dev.twitter.com/apps and create a new app; put the information here.
# You need the tweepy library.
consumer_secret = ''
consumer_key = ''
access_token_key = ''
access_token_secret = ''
@nileshgr
nileshgr / gist:3768589
Created September 23, 2012 02:26
Gitolite-Trac post-recieve hook
#!/bin/bash
# Gitolite-Trac post-receive hook
# Script written by Nilesh Govindrajan; http://nileshgr.com
# Updated by giotti to support multiple repositories.
# Assumptions:
# 1: all trac environments are saved under one common directory
# defined in tracenv. e.g. /path/to/all/my/trac/envs
# 2: all repositories of an environment follow the naming-pattern
# <environment><delimeter><repository name>[<delimeter><repository name continued>...],
# e.g. someproject-somerepository, or someproject-somerepository-with-extra-text
@nileshgr
nileshgr / gist:5106229
Last active December 14, 2015 15:09
Shell snippet (zsh/bash) to convert / in id3tags (Flyte songs) to comma followed by space
NOTE -- You need eyeD3 python library and id3lib (C++ library) for the commands eyeD3 and id3info respectively.
find -name '*.mp3' | while IFS= read -r file; do
artists_org=$(id3info "$file" | grep TPE1 | awk -F ': ' ' { print $2 }')
artists_new=$(echo $artists_org | sed 's@/@, @g' | sed 's/ *$//g')
eyeD3 -a "$artists_new" "$file"
done
@nileshgr
nileshgr / loadtweetarchive.php
Last active December 17, 2015 01:49
Import Twitter Archive into Tweet Nest.
BACKUP YOUR EXISTING DB IF ANY!!!
Download your Twitter Archive, extract -- get a fresh one.
Upload data/js/tweets to your server.
Login to server and execute the following commands:
mv tweets tweets_src
mkdir tweets
cd tweets
@nileshgr
nileshgr / gist:5958106
Created July 9, 2013 15:04
Fallback for WebP serving using nginx So you want webp files to be named as .jpeg.webp in your htdocs. You link to images in your HTML as .jpeg. Nginx will detect if browser supports webp and automatically serve webp or jpeg (File extensions do NOT decide the type).
if ($http_accept ~* "webp") {
set $webp "true";
}
if (-e $request_filename.webp) {
set $webp "${webp}-local";
}
if ($webp = "true-local") {
rewrite (.*) $1.webp last;
@nileshgr
nileshgr / ipfw.rules
Last active June 11, 2021 11:58
IPFW rules for internal and external networking in FreeBSD jails
#!/bin/sh
alias ipfw=/sbin/ipfw
ipfw -f flush
# Make sure you have ipfw_nat_load=yes in loader.conf
# Map port 2201 on first public IP to first jail's port 22
ipfw nat 1 config ip <public ip> unreg_only same_ports redirect_port tcp 192.168.0.1:22 2201
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} =/
RewriteCond %{HTTP_HOST} =www.site.com
RewriteRule (.*) http://www.site.com/folder/ [L]
<Macro php $username $siteroot>
AddHandler php-fcgi .php
FastCgiExternalServer $siteroot/cgi-bin/php.fcgi -socket /var/run/php-fpm-$username.sock -pass-header Authorization -idle-timeout 600
Action php-fcgi /cgi-bin/php.fcgi
</Macro>
<Macro phpvhost $hostname $siteroot $username $aliases>
<VirtualHost *:80>
ServerName $hostname
ServerAlias www.$hostname $aliases
# To specify the start up order of your ezjails, use these lines to
# create a Jail dependency tree. See rcorder(8) for more details.
#
# PROVIDE: standard_ezjail
# REQUIRE:
# BEFORE:
#
export jail_mail_hostname="mail"
export jail_mail_ip="lo2|10.0.0.2/24,re0|<ipv4>,re0|<ipv6>"
WRKDIRPREFIX= /var/ports
DISTDIR= /var/ports/distfiles
PACKAGES= /var/ports/packages
INDEXDIR= /var/ports
CPUTYPE=corei7-avx
CFLAGS+= -O2 -pipe
CXXFLAGS+= -O2 -pipe
COPTFLAGS= -O2 -pipe
PGSQL_DEFAULT?=9.3