Skip to content

Instantly share code, notes, and snippets.

@cyriac
cyriac / console.js
Created May 1, 2014 10:32
Handling console log messages on old browsers
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
console.log = function() {};
}
@cyriac
cyriac / gitlab-backup.cron
Created May 23, 2014 20:15
Gitlab backup to Amazon S3
0 2 * * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production
0 4 * * * s3cmd sync --skip-existing --delete-removed /home/git/gitlab/tmp/backups/ s3://<backup-bucket-name>/gitlab/
.findhere.com
.freeservers.com
.zzn.com
0-mail.com
001.igg.biz
0039.cf
0039.ga
0039.gq
0039.ml
00b2bcr51qv59xst2.cf
@cyriac
cyriac / list_of_dict_to_csv
Created August 11, 2014 06:26
Python snippet to convert list of homogenous dict to csv
import csv
list_of_dict = [.....]
keys = list_of_dict[0].keys()
f = open('file.csv', 'wb')
dict_writer = csv.DictWriter(f, keys)
dict_writer.writer.writerow(keys)
dict_writer.writerows(list_of_dict)
@cyriac
cyriac / rsync_simple.sh
Created August 18, 2014 17:50
A useful rsync between folders
rsync -pvr --delete --exclude-from=file_with_excludes folder1/ userB@hostB:folder2/
@cyriac
cyriac / gitlab-omnibus-backup.sh
Created August 22, 2014 13:28
Gitlab Omnibus backup to Amazon S3
gitlab-rake gitlab:backup:create
find /var/opt/gitlab/backups -mtime +7 -exec rm {} \;
s3cmd sync --skip-existing --delete-removed /var/opt/gitlab/backups/ s3://<s3-bucket-name>/gitlab/backups/
@cyriac
cyriac / google_contacts_cleaner.py
Created November 13, 2014 12:38
Removes bad contacts created from old orkut days. Keeps only contacts with phone numbers, useful for iCloud contacts import
# Usage: python google_contacts_cleaner.py input.vcf output.vcf
import sys
input_file = sys.argv[1]
output_file = sys.argv[2]
total_card_count = 0
final_card_count = 0
with open(input_file,'r') as f:
@cyriac
cyriac / openvpn-install.sh
Created February 25, 2015 06:09
openVPN setup script
#!/bin/bash
# Slightly modified version from https://raw.githubusercontent.com/Nyr/openvpn-install/master/openvpn-install.sh
# Run with sudo ./openvpn-install.sh and not sudo sh ./openvpn-install.sh as read command has issues with external triggering of scripts
# OpenVPN road warrior installer for Debian, Ubuntu and CentOS
# This script will work on Debian, Ubuntu, CentOS and probably other distros
# of the same families, although no support is offered for them. It isn't
# bulletproof but it will probably work if you simply want to setup a VPN on
# your Debian/Ubuntu/CentOS box. It has been designed to be as unobtrusive and
# universal as possible.
@cyriac
cyriac / pptp-vpn.yml
Created February 25, 2015 09:13
PPTP VPN setup - ansible
---
- hosts: all
sudo: yes
tasks:
- name: set hostname using hostname command
command: hostname {{ inventory_hostname }}
- name: set hostname in /etc/hostname
shell: echo {{ inventory_hostname }} > /etc/hostname
- name: Set ip_forward (ipv4)
sysctl: name="net.ipv4.ip_forward" value=1 sysctl_set=yes state=present reload=yes