Skip to content

Instantly share code, notes, and snippets.

@samueltc
samueltc / gist:2dad265b519f6ecb4e95
Created May 9, 2014 19:18
squid cache_peer with crawlera/proxyhub
Change: $scrapinhub/crawlera_hostname$, $username$, $password$ and you're ready to go.
Tested with squid3
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
hosts_file /etc/hosts
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
@samueltc
samueltc / gist:13e62ae4ec48e35bc098
Created February 25, 2015 16:26
global-perf-minified.js
This file has been truncated, but you can view the full file.
(function(a, b) {
function d() {
if (!n.isReady) {
try {
t.documentElement.doScroll("left")
} catch (k) {
setTimeout(d, 1);
return
}
n.ready()
@samueltc
samueltc / gist:adc403eddee75402b1039234ada47d49
Created November 20, 2016 12:51
apt-get segfault on ami-8cc8cde4
On debian-etch-x86_64-5
Problem:
$ apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
You might want to run `apt-get -f install' to correct these.
The following packages have unmet dependencies:
Segmentation fault
from pyspark import SparkContext, SparkConf
from boto.s3.connection import S3Connection
def process(key):
return key.name
if __name__=='__main__':
bucket_name = 'test-bucket'
conn = S3Connection()
bucket = conn.get_bucket(bucket_name)
@samueltc
samueltc / parse.py
Created March 13, 2017 14:15
visa desjardins statement to xero csv statement
import sys
import re
from pprint import pprint
import csv
from unidecode import unidecode
TR = re.compile(r'(?P<transaction_day>\d{2})\s+(?P<transaction_month>\d{2})\s+(?P<inscription_day>\d{2})\s+(?P<inscription_month>\d{2})\s+(?P<sequence>\d{3})\s+(?P<reference>\d{23})?(?P<payee>.*?)\s*(?P<amount>[\s0-9,]+)(?P<transaction_type>CR)?$')
FIELDS = ['Date','Amount','Payee','Description','Reference']
def parse(year):
@samueltc
samueltc / ubuntu16-apache2-mysql5-php4.md
Created August 22, 2018 13:10
Ubuntu 16.04, Apache 2.2, MySQL 5.0 and PHP 4.4
# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.5 LTS
Release:	16.04
Codename:	xenial

apt-get update
apt-get upgrade
psql postgres
CREATE ROLE new_user WITH PASSWORD 'big secure pass';
psql new_db
GRANT CONNECT ON DATABASE new_db TO new_user;
GRANT USAGE ON SCHEMA public TO new_user;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO new_user;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO new_user;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public TO new_user;
GRANT CONNECT ON DATABASE new_db TO new_user;
PERC H700 raid cli (megacli64)
Add disk to an existing virtual drive:
megacli -LDRecon -Start -r0 -Add -PhysDrv[32:5] -l<virtual drive group id> -a<adapter id>

Edgewater 200 AW, 200A, 200AW default cli access:

login: root
password: @#$%^&*!()

Also works for Edgemarc 4550.

@samueltc
samueltc / publish.py
Created July 22, 2020 13:40
simple e-mail sender using AWS SES
#!/usr/bin/env python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
import sys
import glob
import os