Skip to content

Instantly share code, notes, and snippets.

View strrife's full-sized avatar

Alexander Mikhalchenko strrife

View GitHub Profile
@strrife
strrife / slack-space-notofier.php
Created December 12, 2016 13:27
After a few crashes because of no free space left here's a script that notifies you in Slack "errors" channel
<?php
define('THRESHOLD', 80);
$res = shell_exec('/bin/df -h | /bin/grep \'/dev/sda2\' | /usr/bin/awk \'{print $5}\'');
$res = floatval(str_replace('%', '', trim($res)));
if($res > THRESHOLD){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://hooks.slack.com/services/T01234567/B11234567/123456712345671234567');
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode([
@strrife
strrife / toto.sh
Last active January 25, 2016 19:28
sudo apt-get update -y
sudo apt-get install -y git
sudo gem install sass
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo apt-get install -y build-essential tcl8.5
wget http://download.redis.io/releases/redis-stable.tar.gz
WARNING: the code that follows will make you cry; a safety pig is provided below for your benefit.
_
_._ _..._ .-', _.._(`))
'-. ` ' /-._.-' ',/
) \ '.
/ _ _ | \
| a a / |
\ .-. ;
'-('' ).-' ,' ;
_
_._ _..._ .-', _.._(`))
'-. ` ' /-._.-' ',/
) \ '.
/ _ _ | \
| a a / |
\ .-. ;
'-('' ).-' ,' ;
'-; | .'
\ \ /
@jish
jish / promise.js
Created October 28, 2014 22:35
An example "always" behavior for ES6 promises. This only works if you do not create / return intermediate promises.
// A thing I want to do
// This flow only involves **one** promise, for example an ajax call
// None of the subsequent `then` or `catch` calls, return new promises.
var explode = false;
var promise = new Promise(function(resolve, reject) {
if (explode) {
@nghuuphuoc
nghuuphuoc / 1) Install
Last active September 4, 2023 09:29
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@szilagyi
szilagyi / base64_css_arrows
Created September 19, 2013 14:17
base64 arrows
/* arrows */
.arrow-right {background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAJUlEQVR42mNgAILy8vL/DLgASBKnApgkVgXIkhgKiNKJ005s4gDLbCZBiSxfygAAAABJRU5ErkJggg==") no-repeat scroll 0 0 transparent}
.arrow-bottom {background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAG0lEQVR42mNgwAfKy8v/48I4FeA0AacVDFQBAP9wJkE/KhUMAAAAAElFTkSuQmCC") no-repeat scroll 0 0 transparent}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@skull-squadron
skull-squadron / gist:952660
Created May 3, 2011 01:18
Restart ssh-agent
killall ssh-agent; eval `ssh-agent`