Skip to content

Instantly share code, notes, and snippets.

View gerzhan's full-sized avatar

Nikolay Gerzhan gerzhan

View GitHub Profile
@gerzhan
gerzhan / nginx.conf
Created August 8, 2016 02:38 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@gerzhan
gerzhan / gist:5986229a3633ec991af57cc64f775da9
Created May 23, 2016 08:43 — forked from solenoid/gist:1372386
javascript ObjectId generator
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
};
@gerzhan
gerzhan / json_postgres.js
Created May 19, 2016 08:04 — forked from lucdew/json_postgres.js
Example of json document storage in postgresql and querying (with knex.js)
var connectionString = 'postgres://localhost:5432/postgres';
var Promise=require('bluebird');
var knex = require('knex')({
client: 'pg',
connection: {
user: 'postgres',
database: 'postgres',
port: 5432,

SQLite3 Electron windows integration

This guide is based on the very informative discussion in this article: Using node_sqlite3 with Electron

Install sqlite3

npm install sqlite3 --save
@gerzhan
gerzhan / electron-api.md
Created April 24, 2016 04:59 — forked from mrmlnc/electron-api.md
Electron API

Базовые возможности

process — это объект, позволяющий получить информацию о типе запущенного процесса (рендеринг или основной процесс), версию Chrome и Electron, а также путь до выполняемого js-файла.

Пользовательские элементы DOM:

Объект File — это абстракция над нативным File, передающая стандартному HTML5 file API путь к физическому расположению файла в файловой системе пользователя.

@gerzhan
gerzhan / Angular_array_movement.js
Created April 3, 2016 11:05 — forked from jfornoff/Angular_array_movement.js
This is some common element moving functionalitywithin JS Arrays, packaged in a Angular.js factory
app.factory('ArrayService', function(){
return {
deleteElement: function(array, element) {
var index = array.indexOf(element);
if(index == -1){
return false;
}
array.splice(index, 1);
function MyCustomError(message) {
this.message = message;
this.name = "MyCustomError";
Error.captureStackTrace(this, MyCustomError);
}
// or util.inherits(MyCustomError, Error);
MyCustomError.prototype = Object.create(Error.prototype);
MyCustomError.prototype.constructor = MyCustomError;
@gerzhan
gerzhan / gulpfile.js
Created March 22, 2016 07:00 — forked from mlouro/gulpfile.js
gulpfile.js with browserify, jshint, libsass, browserSync for livereload, image optimization and system notifications on errors
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var exec = require('child_process').exec;
var notify = require('gulp-notify');
@gerzhan
gerzhan / gist:442a57975d814dcc13e4
Created February 2, 2016 07:52 — forked from dgieselaar/gist:8b20e9d593e1806a098b
Code splitting, lazy-loading, import statements, Angular + newNgRouter + ocLazyLoad + webpack
import _ from 'lodash';
import angular from 'angular';
import 'angular-new-router';
import 'oclazyload';
function AppController ( ) {
}
AppController.$routeConfig = [];
@gerzhan
gerzhan / Python3 Virtualenv Setup
Created January 20, 2016 09:00 — forked from evansneath/Python3 Virtualenv Setup
Setting up and using Python3 Virtualenv
To install virtualenv via pip
$ pip3 install virtualenv
Note that virtualenv installs to the python3 directory. For me it's:
$ /usr/local/share/python3/virtualenv
Create a virtualenvs directory to store all virtual environments
$ mkdir somewhere/virtualenvs
Make a new virtual environment with no packages