Skip to content

Instantly share code, notes, and snippets.

@plasticut
plasticut / make_swap.sh
Last active June 6, 2017 20:29
Create and attach swap partition
dd if=/dev/zero of=/extraswap bs=1M count=512
mkswap /extraswap
echo '/extraswap none swap sw 0 0' >> /etc/fstab
chmod 600 /extraswap
swapon -a
@plasticut
plasticut / setup_dokku.sh
Created December 24, 2014 14:26
Setup dokku
export DOKKU_HOST=$HOSTNAME
export PUBLIC_KEY=~/.ssh/id_rsa.pub
export DEVELOPER=john
cat $PUBLIC_KEY | ssh root@$DOKKU_HOST "sudo sshcommand acl-add dokku $DEVELOPER"
@plasticut
plasticut / install-redis-server
Last active August 29, 2015 14:12
Redis server instalation via ppa on ubuntu
sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get install redis-server
sudo sed -i 's/^bind 127.0.0.1/bind <% your private network ip %>/g' /etc/redis/redis.conf
sudo service redis-server restart
@plasticut
plasticut / derby-element-model
Last active August 29, 2015 14:04
get model from element context
Comp.prototype.onClick = function(ev, el) {
var item = this.model.root.at(el.$bindStart.context.expression.pathSegments(el.$bindStart.context).join('.'));
};
////
app.on('model', function(model) {
model.fromEl = function(el) {
var ctx = el.$bindStart.context;
return this.at(ctx.expression.pathSegments(ctx).join('.'));
@plasticut
plasticut / file-sort.js
Last active January 4, 2016 08:18
Placing files into folders on the date the file was created (Размещение файлов по папкам относительно даты создания файла)
var path = require('path');
var fs = require('fs');
var noColor = process.argv.indexOf("--nocolor") > -1;
var testMode = process.argv.indexOf("--test") > -1;
function two(num) {
return ("0" + num).slice(-2);
}
@plasticut
plasticut / setup-workspace.sh
Last active December 31, 2015 09:59
Ubuntu 13.10 in VirtualBox Install nodejs, redis, mongodb, git, mc Mount virtualbox shared folder
#!/bin/sh
## login: uuser
## passw: 1234567
## Install nodejs, mongodb and deps
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
@plasticut
plasticut / fix-modal-offset.js
Last active December 31, 2015 00:38
Fix bootstrap modal body offset bug
function fixModalOffet() {
var el = document.createElement("div");
el.style.width = "1px";
el.style.height = "1px";
el.style.overflow = "scroll";
el.style.position = "absolute";
el.style.top = "-9999px";
document.body.appendChild(el);
var style = document.createElement('style');
style.type = 'text/css';