Skip to content

Instantly share code, notes, and snippets.

View aleskiontherun's full-sized avatar

Aleksei Vesnin aleskiontherun

View GitHub Profile
#!/usr/bin/env bash
RUBY_VERSION_MAJOR="2.1"
RUBY_VERSION="2.1.2"
apt-get -y update && apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/${RUBY_VERSION_MAJOR}/ruby-${RUBY_VERSION}.tar.gz
tar -xvzf ruby-${RUBY_VERSION}.tar.gz
cd ruby-${RUBY_VERSION} && ./configure --prefix=/usr/local && make && make install
@aleskiontherun
aleskiontherun / pinba_api_phpdoc.php
Last active December 18, 2015 14:19
A list of pinba functions with phpdoc
<?php
/**
* Creates and starts new timer.
* @param array $tags an array of tags and their values in the form of "tag" => "value". Cannot contain numeric indexes for obvious reasons.
* @param array $data optional array with user data, not sent to the server.
* @return resource Always returns new timer resource.
*/
function pinba_timer_start($tags, $data = array()){}

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@aleskiontherun
aleskiontherun / rrd-last-value
Last active August 11, 2020 06:20
Get a last value stored in rrd file within the rrdtool in CLI
rrdtool lastupdate /path/to.rrd | sed ':a;N;$!ba;s/.*: \([0-9]*\)/\1/g'
@aleskiontherun
aleskiontherun / ryanair-expand-countries
Last active August 29, 2015 13:56
Log "country - cities" from Ryanair compact destination cities list
/**
* 1. Selct a city in the "From" field list
* 2. Open the "To" field list
*
* Some times there is a simple cities list without countries, which is very uncomfortable
* This gist is for those cases
*
* 3. Copy this code into your Firebug (or other) console and execute
*
* Don't forget to perform step 2 every time you select a new "From" city
@aleskiontherun
aleskiontherun / gist:0c5e0045ee6953b037c2
Created August 20, 2014 15:11
User timezone detection
<?php
// CLIENTSIDE:
if (!Yii::app()->user->timezone): ?>
<script type="text/javascript">
$(function () {
var visitortime = new Date();
$.ajax({
type: "GET",
#!/bin/bash
#
# The MIT License (MIT)
#
# Copyright (c) 2014 Mathias Leppich <mleppich@muhqu.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@aleskiontherun
aleskiontherun / ffmpeg.sh
Last active September 5, 2016 04:56
Creating HTML5 video files with ffmpeg
# Based on https://blog.mediacru.sh/2013/12/23/The-right-way-to-encode-HTML5-video.html
# ogv
ffmpeg -i input.mp4 -q 5 -pix_fmt yuv420p -vcodec libtheora -vf "crop=1200:680:360:200" -an output.ogv
# Cropped WebM without audio
ffmpeg -i input.mp4 -c:v libvpx -pix_fmt yuv420p -quality good -b:v 2M -crf 5 -vf "crop=1200:680:360:200,scale=trunc(in_w/2)*2:trunc(in_h/2)*2" -an -f webm output.webm
# Same mp4
ffmpeg -i input.mp4 -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -preset slower -b:v 2M -crf 18 -maxrate 4000k -bufsize 1835k -vf "crop=1200:680:360:200,scale=trunc(in_w/2)*2:trunc(in_h/2)*2" -an -movflags faststart -f mp4 output.mp4
@aleskiontherun
aleskiontherun / yii-session-timeouts
Last active August 29, 2015 14:12
Yii login/session timeouts
CHttpSession.timout - session data will be cleaned up (default - 1440)
CHttpSession.cookieParams.lifetime - session cookie lifetime (default - 0 means "until the browser is closed.")
CWebUser.authTimeout - user is logged out if inactive (not set - after the current session expires)
CWebUser.absoluteAuthTimeout - user is logged out regardless of activity (not set - ommited)
==
CWebUser.allowAutoLogin = true
CWebUser.autoRenewCookie = false

Useful knife commands for a local Chef repo

Generate Chef secret

openssl rand -base64 512 | tr -d '\r\n' > /path/to/secret

Create encrypted data bag

export EDITOR=nano; knife data bag create BAG_NAME ITEM_NAME -z --secret-file /path/to/chef_secret