Skip to content

Instantly share code, notes, and snippets.

@cyriac
cyriac / fix_mackup_links.py
Created May 12, 2017 09:36
Fix broken links on Mackup when migrating dropbox location
@cyriac
cyriac / gist:dae5d3963563091e002dc9208d616ef5
Created February 24, 2017 07:43
Self maintaining gitlab cron
0 0 * * * /usr/bin/letsencrypt renew >> /var/log/le-renew.log
0 */12 * * * gitlab-rake gitlab:backup:create >> /var/log/gitlab-backup.log
0 0 * * * find /var/opt/gitlab/backups/ -name "*_gitlab_backup.tar" -mtime +1 -delete
0 0 * * 6 apt-get update && apt-get upgrade -y gitlab-ce
@cyriac
cyriac / compile_logo.html
Last active November 19, 2016 15:55
Single element Compile logo
<!-- http://codepen.io/pen/WoRdgW -->
<div class="logo"></div>
@cyriac
cyriac / split_to_chunks.awk
Created May 10, 2016 07:22
Split a file into specific size chunks
awk '!(NR%<size>){i++;}{print > "<filename_>"i"<.extension>";}' i=1 <filename.extension>
@cyriac
cyriac / select2.bookmarklet.js
Created April 19, 2016 03:52 — forked from seasick/select2.bookmarklet.js
Bookmarklet to turn <select>s into <select²>s
javascript:void%20function(){function%20e(e,n){var%20o=document.createElement(%22script%22);o.onload=function(){console.log(e+%22%20loaded%22),n()},o.onerror=function(o){console.log(e+%22%20errored%22,o),n(o)},o.src=e,document.body.appendChild(o)}function%20n(e,n){c.link=document.createElement(%22link%22),c.link.onload=function(){n()},c.link.onerror=function(e){n(e)},c.link.href=e,c.link.rel=%22stylesheet%22,c.link.type=%22text/css%22,document.body.appendChild(c.link)}function%20o(n){return%20window.jquery||window.$%3Fn():void%20e(c.jquery,n)}function%20t(){n(c.css,function(n){return%20n%3Fconsole.log(%22err%20loading%20css%22,n):void%20o(function(n){return%20n%3Fconsole.log(%22err%20loading%20jquery%22,n):void%20e(c.js,function(e){if(e)return%20console.log(%22err%20loading%20select2%20js%22,e);var%20n=[].slice.call(document.querySelectorAll(%22select%22));n.forEach(function(e){jQuery(e).select2({dropdownAutoWidth:!0})})})})})}var%20c={js:%22https://cdn.rawgit.com/select2/select2/3.5.4/select2.min.js%22,css:%
@cyriac
cyriac / csv_to_list_of_dict.py
Last active August 29, 2015 14:16
csv_to_list_of_dict
import csv
mrows = []
# Creates list of dict from csv
with open('final.csv', mode='r') as infile:
reader = csv.DictReader(infile)
for row in reader:
mrows.append(row)
header = row.keys()
@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
@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 / 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 / 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/