Skip to content

Instantly share code, notes, and snippets.

View dimmg's full-sized avatar

Gîra Dumitru dimmg

  • Chișinău, Moldova
View GitHub Profile
# check internet connection
ping -c 3 google.com
# update pacman database
pacman -Syy
# install reflector
pacman -S reflector
# setup reflector
@dimmg
dimmg / pg_backup.sh
Last active February 1, 2017 15:36
basic postgresql backup
#!/bin/bash
BACKUP_DIRECTORY="/var/lib/_postgresql/backup"
LOGFILE="$BACKUP_DIRECTORY/backup.log"
CURRENT_DATE=$(date "+%Y%m%d")
FILENAME=$BACKUP_DIRECTORY/$1_$CURRENT_DATE.sql
@dimmg
dimmg / application_controller.rb
Last active January 23, 2017 14:17
rails localization setup
class ApplicationController < ActionController::Base
before_filter :set_locale
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
UNLOCALIZED_NAMESPACES = %w(admin)
def set_locale
@dimmg
dimmg / Preferences.sublime-settings.json
Last active November 19, 2016 13:18
Sublime Text 3 preferences
{
// Theme settings
"auto_complete": true,
"auto_indent": true,
"bold_folder_labels": false,
"caret_extra_width": 1,
"color_scheme": "Packages/Boxy Theme/schemes/Boxy Yesterday.tmTheme",
"font_size": 9,
"theme": "Boxy Yesterday.sublime-theme",
@dimmg
dimmg / config.py
Created August 23, 2016 09:16
fabric + gunicorn + upstart + nginx
HOST = '172.39.10.30'
PROJECTS_DIR = '/home/exampleuser/'
USER = 'exampleuser'
PROJECT_NAME = 'example'
APP_DIR = '{0}{1}/'.format(PROJECTS_DIR, PROJECT_NAME)
VIRTUALENVS_DIR = '{0}.virtualenvs/'.format(PROJECTS_DIR)
VIRTUALENV_PATH = '{0}{1}/'.format(VIRTUALENVS_DIR, PROJECT_NAME)
LOGS_DIR = '{0}logs/'.format(APP_DIR)
REPOSITORY = 'git@github.com:example-team/example.git'
BRANCH = 'master'
@dimmg
dimmg / rvm-ruby-ror.md
Last active April 16, 2016 10:00
rvm + ruby + ror installation

RVM

  1. gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
  2. \curl -sSL https://get.rvm.io | bash -s stable
  3. add [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" to the end of your unix shell source file (ex: .bashrc, .zshrc)
  4. if it says that .rvm/scripts/rvm not found run cp /usr/share/rvm/scripts ~/.rvm (optionally)

Ruby

  1. rvm list known to see all available ruby versions
@dimmg
dimmg / mailchimp-python.py
Created February 4, 2016 16:33
mailchimp v3.0 with python
import json
import requests
# mailchimp api_key and list_id
MAILCHIMP_API_KEY = 'da29dawdn2138dwdawdn21k38-us10'
MAILCHIMP_LIST_ID = 'dfi2ndwa2'
us_ = MAILCHIMP_API_KEY.split('-')[1]
mailchimp_api_root = "https://" + us_ + ".api.mailchimp.com/3.0/"