Skip to content

Instantly share code, notes, and snippets.

View jaymecd's full-sized avatar

Nikolai Zujev jaymecd

View GitHub Profile
# brew install youtube-dl
function youtube_music
{
$(youtube-dl -f 37/22/18 "$1" --extract-audio --audio-format mp3 | tee /dev/tty)
}
function youtube_video
{
$(youtube-dl -f 37/22/18 "$1" | tee /dev/tty)
@jaymecd
jaymecd / ssh-known-hosts-mgmt.sh
Created October 20, 2013 13:34 — forked from bradland/ssh-known-hosts-mgmt.sh
known_hosts management commands
# This is a short collection of tools that are useful for managing your
# known_hosts file. In this case, I'm using the '-f' flag to specify the
# global known_hosts file because I'll be adding many deploy users on this
# system. Simply omit the -f flag to operate on ~/.ssh/known_hosts
# Add entry for host
ssh-keyscan -H github.com > /etc/ssh/ssh_known_hosts
# Scan known hosts
ssh-keygen -f /etc/ssh/ssh_known_hosts -H -F github.com
@jaymecd
jaymecd / multistage.rb
Created November 14, 2013 22:42
capistrano custom multistage task
# NB! must be loaded after [require 'capistrano/ext/multistage']
namespace :multistage do
desc "List available stages"
task :list, :except => { :no_release => true,:stages => true } do
print "#{stages.join(',')}\n"
end
end
# overload config to allow stage listing w/o selected stage
if callbacks[:start]
@jaymecd
jaymecd / 2-way-crypt.php
Last active December 28, 2015 23:19
2-way php encryption (mcrypt)
#!/usr/bin/env php
<?php
class Coder
{
const CRYPT_CIPHER = MCRYPT_RIJNDAEL_128;
const CRYPT_MODE = MCRYPT_MODE_ECB;
protected static function get_crypt_iv()
{
@jaymecd
jaymecd / cask_helpers.sh
Created December 2, 2013 14:24
Brew cask helpers (OSX)
function cask_install() {
if brew cask info "${@}" | grep "Not installed" > /dev/null; then
brew cask install "${@}"
else
echo "${@} is already installed."
fi
}
function cask_upgrade() {
if brew cask info "${@}" | grep "Not installed" > /dev/null; then
@jaymecd
jaymecd / pear_channel_remove.sh
Created January 6, 2014 10:06
remove all packages from PEAR channel
function pear_remove {
local channel="$1"
if [ -z $channel ]; then
echo "Error: channel must be provided"
return 1
fi
for pkg in $(pear list -c "$channel" | awk '{if ( $2 ~ /([0-9]+)\.([0-9]+)\.([0-9]+)/ ) print $1}') ; do
pear uninstall "$channel/$pkg"
@jaymecd
jaymecd / remove_arg.sh
Created February 13, 2014 15:02
Remove bash argument
#!/usr/bin/env bash
#
# Remove any argument matching --env= and prepend --env=test
#
args=("$@")
idx=0
# Install a Webserver
apt-get -y install apache2
# Target docroot to /home/satis/web/
# Install PHP5 CLI and needed programs.
apt-get -y install php5-cli php5-curl php5-json git wget
# Add a specifix user for our task
adduser satis
# Create a new Token
curl -u 'githubuser' -d '{"note":"Your Application"}' https://api.github.com/authorizations
# It is: "ebab4dc37e654bb230a9c69ebcd5f38e9a81e210"
#{
# "created_at": "2013-01-04T18:00:28Z",
# "app": {
# "url": "http://developer.github.com/v3/oauth/#oauth-authorizations-api",
# Cronjob for poor man monitoring of server health
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Every sunday, check for apt-get upgrades.
33 3 * * 0 root apt-get update ; apt-get -q --simulate upgrade
# Every sunday, check for SMART errors.
34 3 * * 0 root echo 'SMART Sectors'; smartctl -a /dev/sda | grep -i sector ; smartctl -a /dev/sdb | grep -i sector; echo 'SMART All'; smartctl -a /dev/sda ; smartctl -a /dev/sdb