Skip to content

Instantly share code, notes, and snippets.

View vps.sh
#!/bin/sh
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get install -y software-properties-common python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo add-apt-repository -y ppa:nginx/development # or ppa:nginx/stable
View cpp_task.md

Наибольшая общая подстрока

  • Ограничение времени: 1.5 секунды
  • Ограничение памяти: 512Mb
  • Ввод stdin/input.txt
  • Вывод stdout/output.txt

Задача

Даны K строк, нужно найти их наибольшую общую подстроку

@nkt
nkt / rm_chrome_passwords.js
Last active Aug 29, 2015
Removes all chrome saved passwords
View rm_chrome_passwords.js
var removeButtons = document.querySelectorAll('#saved-passwords-list .row-delete-button')
Array.prototype.slice.call(removeButtons).forEach(function (el) {
el.click()
})
View ApiResponse.php
<?php
namespace App\CoreBundle\HttpFoundation;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\ConstraintViolationListInterface;
/**
* @author Nikita Gusakov <dev@nkt.me>
View stash-install.sh
#!/bin/sh
STASH_VERSION='3.8.0'
wget "https://www.atlassian.com/software/stash/downloads/binary/atlassian-stash-${STASH_VERSION}.tar.gz"
tar xvzf "atlassian-stash-${STASH_VERSION}.tar.gz"
sudo adduser --disabled-login --shell /bin/bash --gecos 'Stash' stash
sudo mv "atlassian-stash-${STASH_VERSION}" /home/stash/stash
View gitlab.sh
#!/bin/bash
apt-get update -y
apt-get upgrade -y
apt-get install sudo -y
sudo apt-get install -y vim
sudo update-alternatives --set editor /usr/bin/vim.basic
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake
View unpack.sh
unpack() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
View upgrade-postgres-9.3-to-9.4.md

TL;DR

sudo pg_dropcluster 9.4 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main

@nkt
nkt / measure.sql
Created Feb 23, 2015
Postgres function for calculating measure in meters between two points
View measure.sql
CREATE FUNCTION measure(_from POINT, _to POINT)
RETURNS DOUBLE PRECISION AS $$
DECLARE
d_lat DOUBLE PRECISION;
d_lon DOUBLE PRECISION;
_a DOUBLE PRECISION;
_c DOUBLE PRECISION;
_d DOUBLE PRECISION;
BEGIN
d_lat = (_to [0] - _from [0]) * pi() / 180;
@nkt
nkt / deploy.js
Last active Aug 29, 2015
Simple standalone deploy server written on Node.js
View deploy.js
var childProcess = require('child_process');
var http = require('http');
var util = require('util');
var path = require('path');
var fs = require('fs');
var listen = process.env.LISTEN || 8000;
var home = process.env.HOME;
var key = process.env.DEPLOY_KEY;