Skip to content

Instantly share code, notes, and snippets.

View pbojinov's full-sized avatar

Petar Bojinov pbojinov

View GitHub Profile
@pbojinov
pbojinov / 00-node6.config
Created March 6, 2018 06:50 — forked from Nainterceptor/00-node6.config
Quick & dirty hack to get NodeJS 6 on AWS Elastic BeanStalk
option_settings:
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeCommand
value: "npm start"
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeVersion
value: "4.4.3"
commands:
050-node-script-installer:

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@pbojinov
pbojinov / install-charles-proxy.sh
Last active April 8, 2018 02:33 — forked from heyalexej/install-charles-proxy.sh
install charles proxy from deb source
#!/usr/bin/env sh
set -e
# install charles proxy from deb sources.
# http://www.charlesproxy.com
sudo sh -c 'echo "deb http://www.charlesproxy.com/packages/apt/ charles-proxy main" > /etc/apt/sources.list.d/charles-proxy.list'
wget -q http://www.charlesproxy.com/packages/apt/PublicKey -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y charles-proxy
@pbojinov
pbojinov / uri.js
Last active April 8, 2018 02:33 — forked from jlong/uri.js
Easy URI parsing by creating an anchor element and accessing its properties
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@pbojinov
pbojinov / msconvert.js
Last active April 8, 2018 02:33 — forked from remino/msconvert.js
/**
* Convert milliseconds to Hour:Minute:Seconds || Minute:Seconds
*
* @param {int} milliseconds
* @return {Object} h = hour, m = minute, s = seconds
*/
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
// tinyxhr by Shimon Doodkin - licanse: public doamin - https://gist.github.com/4706967
//
// tinyxhr("http://site.com/ajaxaction",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data) });
// tinyxhr("http://site.com/ajaxaction",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data) },'POST','value1=1&value2=2');
// tinyxhr("http://site.com/ajaxaction.json",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data); console.log(JSON.parse(data)) },'POST',JSON.stringify({value:1}),'application/javascript');
// cb - a callback function like: function (err,data,XMLHttpRequestObject){ if (err) throw err; }
//
function tinyxhr(url,cb,method,post,contenttype)
{
/**
* Shuffle string like crazy
*
* @param {int} length desired
* @return {string} the shuffled string
*/
String.prototype.shuffle = function(size) {
var arr = this.split('');
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x){};
arr = arr.join('');
jQuery.fn.autoresize = function (options) {
options = options || {}
return this.each(function () {
// Init Sizes
var parent = $(this).parent();
var imageWidth = $(this).width();
var imageHeight = $(this).height();
var parentWidth = parent.width();
var parentHeight = parent.height();
var ratio, newSide;
// Example:
JavaScript.load("/javascripts/something.js");
// With callback (that’s the good thing):
JavaScript.load("http://www.someawesomedomain.com/api.js", function() {
API.use(); // or whatever api.js provides ...
});
@pbojinov
pbojinov / selector.js
Created February 20, 2013 19:03
jQuery like selector
var $ = function (selector) {
var cl, id, alls, arrEle = [];
if (/^\./.test(selector)) {
cl = selector.replace(".", "");
alls = document.getElementsByTagName("*"), l = alls.length;
for (var i=0; i<l; i+=1) {
var name = alls[i].className, arrName = [];
if (name) {
arrName = name.split(" "), lName = arrName.length;
for (var j=0; j<lName; j+=1) {