Skip to content

Instantly share code, notes, and snippets.

View noma4i's full-sized avatar
💭
🦑 Daily Kraken

Alexander Tsirel noma4i

💭
🦑 Daily Kraken
View GitHub Profile
@noma4i
noma4i / mysql_dump_remotehost_progress_bar.sh
Last active September 2, 2015 03:50
Quick snippet to Copy MySQL database from remote host with Progress Bar pipe
# Transfer MySQL Database dump
mysqldump -u USER_NAME -h REMOTE_HOST --password=USER_PASWORD --compress --databases DATABASE_NAME | pv | gzip -c > DATABASE_NAME.sql.gz
# Rollout dump to local MySQL
gunzip -c DATABASE_NAME.sql.gz | mysql -u root -p DATABASE_NAME
@noma4i
noma4i / deploy.rb
Last active September 2, 2015 01:04 — forked from jbonney/deploy.rb
Mina deployment file to setup new host for Rails applications. Creates the folder structure, fill up the database.yml file, create the associated DB and user and set up new Apache virtual host file.
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Usually mina focuses on deploying to one host and the deploy options are therefore simple.
# In our case, there is a number of possible servers to deploy to, it is therefore necessary to
# specify the host that we are targeting.
server = ENV['server']
# Since the same host can have multiple applications running in parallel, it is necessary to
@noma4i
noma4i / rmate-setup.sh
Last active August 29, 2015 14:27 — forked from tekwiz/rmate-setup.sh
Download & setup rmate
#!/usr/bin/env bash
##
# Run with:
#
# curl -sSL https://gist.githubusercontent.com/noma4i/1346b3997978c5ae2643/raw/68830673a7f70bf47264841b4d523a4ddc7eb687/rmate-setup.sh | bash -s
#
mkdir -p ~/bin
curl -Lo ~/bin/rmate https://raw.github.com/textmate/rmate/master/bin/rmate
validate email: /\A([\w\.\-\+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
validate url: ^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix
validate ip: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i
validate ip ranges: /^\b(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]?)\b$/i
validate netmask: /^(((128|192|224|240|248|252|254)\.0\.0\.0)|(255\.(0|128|192|224|240|248|252|254)\.0\.0)|(255\.255\.(0|128|192|224|240|248|252|254)\.0)|(255\.255\.255\.(0|128|192|224|240|248|252|254)))$/i
@noma4i
noma4i / gist:e271ee12e83743e3a7bf
Last active August 29, 2015 14:17
mysql timezone support
CREATE TABLE `time_zone` (
`Time_zone_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Use_leap_seconds` enum('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (`Time_zone_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1676 DEFAULT CHARSET=utf8 COMMENT='Time zones';
CREATE TABLE `time_zone_leap_second` (
`Transition_time` bigint(20) NOT NULL,
`Correction` int(11) NOT NULL,
PRIMARY KEY (`Transition_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Leap seconds information for time zones';
Downloading/unpacking pip
Downloading/unpacking setuptools
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...
Downloading/unpacking python-keystoneclient
Downloading/unpacking python-swiftclient
Downloading/unpacking iso8601>=0.1.9 (from python-keystoneclient)
Downloading iso8601-0.1.10.tar.gz
Running setup.py (path:c:\users\admini~1\appdata\local\temp\1\pip_build_Administrator\
@noma4i
noma4i / gist:ba5e58268be74ea4b33c
Created August 10, 2014 06:41
Sublime config
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/User/Solarized (dark).tmTheme",
"font_size": 12,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Handlebars",
@noma4i
noma4i / init.rb
Created August 5, 2014 12:42
Proper init.rb for Redmine Project plan loader plugin
require 'redmine'
require_dependency 'string'
require_dependency 'element'
require_dependency 'views_issues_index_bottom_hook'
ActionDispatch::Callbacks.to_prepare do
SettingsHelper.__send__(:include, SettingsHelperPatch)
Mailer.__send__(:include, LoaderMailer)
Issue.__send__(:include, IssuePatch)
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
#DROPBOX SYNCING
#==============
# bash_profile
rm -rf .bash_profile
ln -s ~/Dropbox/.bash_profile .bash_profile
# Sublime 2 Preferences
cd ~/Library/Application\ Support/Sublime\ Text\ 2/
ln -s ~/Dropbox/appdata/sublime/Installed\ Packages ./Installed\ Packages