Skip to content

Instantly share code, notes, and snippets.

View saml's full-sized avatar

Sam Lee saml

  • New York, NY
View GitHub Profile
@saml
saml / nginx-purge-cache.bash
Last active December 12, 2015 00:28
nginx proxy cache
#!/bin/bash
CACHE_PATH="/var/www/cache"
if (( $# < 1 ))
then
sudo rm -rf "$CACHE_PATH"/*
else
curl -H "X-Purge: 1" -g -s -v "$1"
fi
@saml
saml / logger.xml
Created January 31, 2013 17:47
play framework logger configuration
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application.log</file>
<encoder>
<pattern>%date %level %message%n%throwable{full}</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
@saml
saml / jira_greenhopper_board.js
Created February 7, 2013 15:13
bookmarklet for greenhopper version board direct link to specific project and board
(function(){
var pid = jQuery('#project-avatar').attr('src').match(/pid=(\d+)/)[1];
var go = function(pid) {
var bid = jQuery('#gh-bc-options .gh-selected a').attr('href').match(/changeView\(.(\d+)/)[1];
window.location.href = '/secure/VersionBoard.jspa?selectedBoardId=' + bid + '&selectedProjectId=' + pid;
};
var a = jQuery('#gh-bc-boards a');
if (a.length === 1) {
Boards.getDropdownOptions('gh-bc', 'BoardOptions');
}
  • Restaurant Name: Pita Pan
    • Header 1: Delivery & Takeout
    • Top Description:
      • Header 2: Lunch Specials
      • Top Description: Served Monday ~ Friday From 11am ~ 3pm
      • Bottom Description:
        • Header 3:
        • Top Description:
          • Header 4:
  • Bottom Description:
@saml
saml / akamai-debug.bash
Created February 11, 2013 22:50
akamai pragma debug headers
#!/bin/bash
curl -v -s -H "Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-ser" "$@" 2>&1 > /dev/null | grep X-Cache
@saml
saml / splitat.py
Created February 13, 2013 22:16
split stdin into different files at certain lines
import sys
import os
import re
pattern = re.compile(r'%s' % sys.argv[1])
filename_prefix = sys.argv[2]
filename_postfix = sys.argv[3]
curr_file = None
while True:
line = sys.stdin.readline()
if not line:
# -*- coding: utf-8 -*-
import csv
from cStringIO import StringIO
class School(object):
def __init__(self, name):
self.name = name
def __call__(self, row):
@saml
saml / sitemap.bash
Last active December 13, 2015 18:38
download sitemap and urls
#!/bin/bash
while read -r x; do wget -nc "$x" && gzip -d -f "$(basename "$x")"; done < <(grep '<loc>' sitemap.xml |sed 's!\s*<.\?loc>!!g')
grep --no-filename '<loc>' sitemap[1-8].xml |sed 's!\s*<.\?loc>!!g'|sort|uniq
@saml
saml / concurrent write quiz.md
Created February 15, 2013 18:50
concurrent writes

Implement these:

delete(key)   
write(key, val)
get(key)

delete removes value associated with the key. If key does not exist, noop. write adds new key value if key doesn't exist, else it overwrites value associated with key. get returns value associated with key. If key does not exist, return whatever.

Privacy Policy
Protecting your private information is our policy.
This statement of privacy applies to the PRODUCT_TITLE software product, and its website http://example.com/ , and governs data collection and usage. For the purposes of this privacy policy, all references to COMPANY_NAME or COMPANY_ABBREVIATION include PRODUCT_TITLE and http://example.com/ ; all references to PRODUCT_TITLE include COMPANY_NAME and http://example.com/ . The PRODUCT_TITLE website is an application information and distribution site. By using the website, you consent to the data practices described in this statement.
Collection of your Personal Information
If you purchase COMPANY_ABBREVIATION's products and services, we collect billing information, which may include credit card information. This information is used to complete the purchase transaction. We may gather additional personal or non-personal information in the future.