Skip to content

Instantly share code, notes, and snippets.

View yarkovaleksei's full-sized avatar
🏠
Working from home

Yarkov Aleksey yarkovaleksei

🏠
Working from home
  • Russia, Rostov-on-Don
View GitHub Profile
@yarkovaleksei
yarkovaleksei / node-translit.js
Created August 27, 2017 16:30 — forked from mad-gooze/node-translit.js
Simple translit module for node.js - Простой модуль транслитерации кирилицы для node.js
module.exports = function(text) {
return text.replace(/([а-яё])|([\s_-])|([^a-z\d])/gi,
function (all, ch, space, words, i) {
if (space || words) {
return space ? '-' : '';
}
var code = ch.charCodeAt(0),
index = code == 1025 || code == 1105 ? 0 :
code > 1071 ? code - 1071 : code - 1039,
t = ['yo', 'a', 'b', 'v', 'g', 'd', 'e', 'zh',
@yarkovaleksei
yarkovaleksei / post-merge
Created August 25, 2017 12:06 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@yarkovaleksei
yarkovaleksei / event-listeners.js
Created April 17, 2017 21:44 — forked from danburzo/README.md
Get all event listeners on the page in Google Chrome
var items = Array.prototype.slice.call(
document.querySelectorAll('*')
).map(function(element) {
var listeners = getEventListeners(element);
return {
element: element,
listeners: Object.keys(listeners).map(function(k) {
return { event: k, listeners: listeners[k] };
})
};
#!/bin/sh
#########################
## PASSWORD GEN SCRIPT ##
## -drewzh.com- ##
#########################
echo "Please enter your master password:"
stty -echo
read -r master
stty echo
@yarkovaleksei
yarkovaleksei / mongod
Last active March 10, 2017 16:10 — forked from madhums/mongod
mongod init script. Placed in /etc/init.d/mongod
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongodb
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Mongodb startup script
# Description: Mongodb start stop daemon sends SIGINT to terminate
# say man signal to see details
# Please check the startup params and replication options
@yarkovaleksei
yarkovaleksei / git-deployment.md
Created February 22, 2017 18:36 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

var crypto = require('crypto');
var express = require('express');
var app = express();
var blowfishCipher = crypto.createCipher('blowfish', "asdf");
app.locals.root_path = __dirname;
var crypting = function( text, algorithm, crypt ){
var cipher;
map $http_upgrade $connection_upgrade {
default "upgrade";
"" "";
}
server {
listen 80;
location / {
proxy_pass http://docker;
# Простой пример
server {
listen 80;
server_name localhost;
charset koi8-r;
location / {
root /var/www/nodejs/public;
index index.html;
try_files $uri $uri/ @backend;
@yarkovaleksei
yarkovaleksei / bash.sh
Created February 10, 2017 19:26 — forked from jbutko/bash.sh
Nginx
# upgrade nginx
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
# cache
proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g
inactive=60m use_temp_path=off;
server {