Skip to content

Instantly share code, notes, and snippets.

View TemaSM's full-sized avatar

Tema Smirnov TemaSM

View GitHub Profile
@TemaSM
TemaSM / Sails.js Nginx Cluster
Last active August 29, 2015 14:26 — forked from uhho/node nginx configuration
Sample nginx configuration for NodeJS + SocketIO app
# Load balancer configuration
upstream exampleApp {
# Directs to the process with least number of connections.
least_conn;
# One failed response will take a server out of circulation for 20 seconds.
server 127.0.0.1:10080 fail_timeout=20s;
#server 127.0.0.1:10081 fail_timeout=20s;
#server 127.0.0.1:10082 fail_timeout=20s;
#server 127.0.0.1:10083 fail_timeout=20s;
@TemaSM
TemaSM / latest.php
Last active February 13, 2017 05:08
[PHP] Get file by latest version from current directory (electron-builder / nsis-web)
<?
// Author: Tema Smirnov [https://github.com/TemaSM] © 2017
$iVersion= 0;
$filename = "<filename>.ext";
$regexp = "/([-A-z]+)-([\.0-9]+)-([a-z]+)-([a-z0-9]+).+nsis.7z/";
/* Example: MyProject-0.0.1-alpha-x64.nsis.7z
0 => MyProject-0.0.1-alpha-x64.nsis.7z
1 => MyProject
2 => 0.0.1
3 => alpha
@TemaSM
TemaSM / [WIN] GitKraken Context Menu - Remove.reg
Created April 17, 2017 13:33
Remove GitKraken from Windows Context Menu
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Directory\Background\shell\GitKraken]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\GitKraken\command]
@TemaSM
TemaSM / dh-usage.js
Created April 27, 2017 10:18 — forked from bellbind/dh-usage.js
[nodejs][javascript] Diffie-Hellman key exchange by nodejs-0.5
// node.js 0.5 Diffie-Hellman example
var assert = require("assert");
var crypto = require("crypto");
// the prime is shared by everyone
var server = crypto.createDiffieHellman(512);
var prime = server.getPrime();
// sharing secret key on a pair
@TemaSM
TemaSM / download-curl-latest-github-release.sh
Created July 5, 2017 12:05
Download latest GitHub project/repo release via curl
# Method №1:
curl -s https://api.github.com/repos/<author>/<repo>/releases/latest | grep browser_download_url | cut -d '"' -f 4 | xargs curl > release.zip
# Method №2:
curl "$(curl -s https://api.github.com/repos/<author>/<repo>/releases/latest | grep browser_download_url | cut -d '"' -f 4)" -o release.zip
# http://www.starkandwayne.com/blog/how-to-download-the-latest-release-from-github/
# https://unix.stackexchange.com/questions/323604/pipe-the-result-of-a-cut-command-to-curl
@TemaSM
TemaSM / harlem-shake.js
Last active April 1, 2018 05:00
Beautified version of original HarlemShake script by Moovweb
function doTheHarlemShake() {
// OPTIONS
let minHeight = 30,
minWidth = 30,
maxHeight = 350,
maxWidth = 350,
mp3Src = '//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake.mp3',
shakeMeClass = 'mw-harlem_shake_me',
@TemaSM
TemaSM / splice-object-array.js
Created November 24, 2017 03:22 — forked from scottopolis/splice-object-array.js
Remove object from array of objects in Javascript
// source: http://stackoverflow.com/questions/16491758/remove-objects-from-array-by-object-property
// we have an array of objects, we want to remove one object using only the id property
var apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
// get index of object with id:37
var removeIndex = apps.map(function(item) { return item.id; }).indexOf(37);
// remove object
apps.splice(removeIndex, 1);
@TemaSM
TemaSM / FileContainer.vue
Created December 21, 2017 03:50 — forked from dohomi/FileContainer.vue
File container for vuetify and graph.cool. It lists files provided by a prop with link to the public url. Below it shows a file upload field
<template>
<div>
<h3 class="subheading" v-if="!hideLabel">{{label}}</h3>
<v-list v-if="mediaList">
<v-list-tile v-for="(item,i) in mediaList" :key="i">
<v-list-tile-avatar @click="onItemClick(item.url)">
<img :src="item.url" :alt="item.name" :title="item.name"/>
</v-list-tile-avatar>
<v-list-tile-content @click="onItemClick(item.url)">
<v-list-tile-title>{{item.contentType}}</v-list-tile-title>
@TemaSM
TemaSM / docker.logs-clear.sh
Created December 25, 2017 10:50
Clear Docker Containers logs
sudo find /var/lib/docker/containers/ -type f -name '*-json.log' -delete
@TemaSM
TemaSM / commit-message-guidelines.md
Created November 14, 2018 19:13 — forked from robertpainsi/commit-message-guidelines.md
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages