Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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;