Skip to content

Instantly share code, notes, and snippets.

View bogtan's full-sized avatar

Bogdan Tănase bogtan

View GitHub Profile
@bogtan
bogtan / db_backup.sh
Created November 4, 2014 10:00
Backup remote PostgreSQL DB to local SQL file
ssh <username>@<hostname> 'pg_dump -U <remote_db_user> <remote_db_name>' > <local_filename>.sql
@bogtan
bogtan / watch.js
Created October 30, 2014 16:55
AngularJS $watch that waits multiple asynchronous calls to end.
scope.$watch('<variable>', function(<value>) {
$timeout(function() {
asyncronousCallback(<value>)
}, 500)
}, true)
@bogtan
bogtan / shortcuts
Last active August 29, 2015 14:06
SublimeText keyboard shortcuts
h1. Sublime Text 2 - Useful Shortcuts (PC)
Loosely ordered with the commands I use most towards the top. Sublime also offer "full documentation":http://www.sublimetext.com/docs/2/.
h2. Editing
| *Ctrl+C* | copy current line (if no selection) |
| *Ctrl+X* | cut current line (if no selection) |
| *Ctrl+⇧+K*| delete line |
| *Ctrl+↩* | insert line after |
@bogtan
bogtan / facebook-share-button.html
Created September 10, 2014 08:38
Prevent Facebook "A Link in Your Post Might Be Unsafe" message
<a href="javascript:void(0);" title="Share on Facebook" id="facebook-share-btn">Share</a>
@bogtan
bogtan / post-checkout
Last active August 29, 2015 14:04
Git post-checkout hook to remove .pyc files when changing branch
#!/usr/bin/env bash
# Delete .pyc files
cd ./$(git rev-parse --show-cdup)
# Delete OS X DS_Store files
find . -name ".DS_Store" -delete
TOTAL_PYC_FILES=$( find . -name "*.pyc" | wc -l | tr -d ' ' )
if [ $TOTAL_PYC_FILES -gt 0 ]; then
""" Simple youtube downloader """
import re
import sys
import requests
import urllib
def youtube_info(youtube_id):
""" Raises ValueError when video is not streamable - e.g. VEVO video """
info_url = 'http://www.youtube.com/get_video_info?video_id={0}'
@bogtan
bogtan / rts_bpp.sh
Created June 10, 2014 08:59
SD card reader in Debian Wheezy
#!/bin/sh
wget https://bugs.launchpad.net/bugs/971876/+attachment/2991730/+files/rts_bpp.tar.bz2
tar jxf rts_bpp.tar.bz2
cd rts_bpp
make
su -c 'make install ; modprobe rts_bpp ; depmod -a'
@bogtan
bogtan / head.html
Created March 12, 2014 15:15
HTML meta tags for social sharing and Apple devices
<!-- Standard Favicon -->
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!-- For iPhone 4 Retina display: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://www.example.com/apple-touch-icon-114x114.png">
<!-- For iPad: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://www.example.com/apple-touch-icon-72x72.png">
<!-- For iPhone: -->
<link rel="apple-touch-icon-precomposed" href="http://www.example.com/apple-touch-icon-57x57.png">
<!-- Facebook -->
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
CHECKS = [
class Color(object):
"""
utility to return ansi colored text.
"""
colors = {
'black': 30,
'red': 31,
'green': 32,
'yellow': 33,