Skip to content

Instantly share code, notes, and snippets.

View strrife's full-sized avatar

Alexander Mikhalchenko strrife

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include "mpi.h"
unsigned long micros = 0;
float millis = 0.0;
clock_t start, end;
@strrife
strrife / wp-shortcode-function.php
Last active March 17, 2016 20:02
Call custom function from shortcode
add_shortcode( 'call_function', 'custom_function_call' );
/**
* @param $attributes
* $attributes['name'] - function name to call
* $attributes['args'] - arguments to be passed
* @return string
*/
function custom_function_call( $attributes ) {
$pattern = false;
@strrife
strrife / dead-simple-jquery-mvc.js
Last active November 9, 2015 21:11
jQuery dead-simple mvc.
(function bindDeadSimpleMvc($) {
var updateBindings = function () {
console.log($(this).attr('placeholder'));
$('[data-bind="' + $(this).attr('data-bind-variable') + '"]').html($(this).val());
};
$('input[data-bind-variable]').on('change keyup', updateBindings).each(updateBindings);
})(jQuery);
@strrife
strrife / 1) Redis
Last active November 18, 2015 19:28 — forked from nghuuphuoc/1) Install
Install Redis on Centos 6
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
yum -y --enablerepo=remi,remi-test install redis
function delay(time) {
return new Promise(function (fulfill) {
setTimeout(fulfill, time);
});
}
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-get install -y nodejs
sudo npm i -g grunt-cli bower forever
sudo npm i -g node-sass
@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
@strrife
strrife / .bash_profile
Last active April 11, 2016 19:11
<3 Aliases
alias fuck="sudo"
alias gitf="git fetch"
alias gimme="brew install"
alias vhosts="fuck nano /etc/apache2/extra/httpd-vhosts.conf"
alias jspf="jspm i --unlink --force"
alias rserv="brew services restart
alias a2r="sudo apachectl -k restart"
alias dm="docker-machine"
denv(){
.stars {
position: relative;
font-size: 20px;
}
.stars.big
{
font-size: 40px !important;
}
@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([