Skip to content

Instantly share code, notes, and snippets.

View lkraav's full-sized avatar
🎯
Focusing

Leho Kraav lkraav

🎯
Focusing
View GitHub Profile
@tomschlick
tomschlick / Environments to bypass .htpasswd protection
Created November 8, 2009 08:30
This allows you to set certain urls/domains that are allowed to bypass a htpasswd protection layer, which is very useful for multiple environment setups (developement, staging, production)
#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI "/testing_uri$" test_uri
#allows everything if its on a certain host
SetEnvIf HOST "^testing.yoursite.com" testing_url
SetEnvIf HOST "^yoursite.com" live_url
Order Deny,Allow
AuthName "Restricted Area"
AuthType Basic
@eric1234
eric1234 / git-fork-compare
Created October 29, 2010 18:40
Scripts to review diverging git forks
#!/bin/sh
# Provides a way to compare a fork against the original it is based
# on so you can get a general idea of what is in a fork.
#
# git-fork-compare <original> <fork>
TMP_GIT=`mktemp -d`;
rmdir $TMP_GIT;
git clone -q $2 $TMP_GIT;
cd $TMP_GIT;
@ewilderj
ewilderj / friends.py
Created December 9, 2010 18:19
Make a graph of your social network from those you follow
# a messy hack written by Edd Dumbill. http://twitter.com/edd
# You may need to rerun this script if you hit a Twitter Error because you
# use up API rate limiting. That's why we pickle the results, so we can resume
# where we left off.
# get the twitter module using 'easy_install twitter'
from twitter.api import Twitter, TwitterError
from twitter.oauth import OAuth
@kylef
kylef / pyeval.py
Last active September 25, 2015 01:27
Python Evaluate for ZNC modpython
import sys
import re
from code import InteractiveInterpreter
import znc
class pyeval(znc.Module, InteractiveInterpreter):
module_types = [znc.CModInfo.UserModule, znc.CModInfo.NetworkModule]
description = 'Evaluates python code'
@ffub
ffub / gist:1084424
Created July 15, 2011 10:10
Balsamiq HTML export
#!/usr/bin/php
<?php
error_reporting(E_ALL);
if (count($argv) <= 1) {
print("usage createMockup src_dir dst_dir images_dir\n");
print("\tsrc_dir : dir where all bmml file are\n");
print("\tdst_dir : dir where write all html files\n");
print("\timages_dir : dir where all export mockup png are (will be copied to the \$dst_dir/images directory)\n");
exit(1);
}
@wyattanderson
wyattanderson / gist:1264760
Created October 5, 2011 15:38
Unique Hostname Colorization
# Calculate a short checksum of the real hostname to determine a unique color
if [[ $TERM =~ "256color" ]]; then
host_color="38;5;$((16 + $(hostname | cksum | cut -c1-3) % 256))";
else
host_color="1;$((31 + $(hostname | cksum | cut -c1-3) % 6))";
fi
@ocean90
ocean90 / box-shadow.html
Last active April 11, 2024 13:54
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@Viper007Bond
Viper007Bond / gist:1297669
Created October 19, 2011 07:27
Determining if modifying the main query or not in WordPress
<?php
# See bigdawggi's comment below for a good combined example
// Pre-3.3
function cf_google_search_kill_wp_search( $where, $query ) {
global $wp_the_query;
if( ! is_admin() && $query->is_search() && $query === $wp_the_query ) {
$where = ' AND 1=0';
@peteboere
peteboere / jquery.alterclass.js
Created December 24, 2011 12:49
jQuery alterClass plugin: Remove element classes with wildcard matching. Optionally add classes.
/**
* jQuery alterClass plugin
*
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
*
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*
*/
@ssp
ssp / git-extract-file.markdown
Created January 23, 2012 13:21
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch