Skip to content

Instantly share code, notes, and snippets.

View noopnik's full-sized avatar

Nikita noopnik

View GitHub Profile
@noopnik
noopnik / ip4
Created December 7, 2016 17:25 — forked from DeadAlready/ip4
IPv4 firewall setup
*filter
# Default policy is to drop all traffic
-P INPUT DROP
-P FORWARD DROP
-P OUTPUT DROP
# Allow all loopback traffic
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
@noopnik
noopnik / fooapp.conf
Created December 7, 2016 17:25 — forked from DeadAlready/fooapp.conf
Nginx secure configuration
# Remove server identifiers to help against enumeration
server_tokens off;
# Add some protection headers for ClickJacking
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
# Redirect to https
server {
listen 80;
@noopnik
noopnik / simple-nodejs-iv-encrypt-decrypt.js
Created July 28, 2016 10:13 — forked from yoavniran/simple-nodejs-iv-encrypt-decrypt.js
nodejs crypto - simple encrypt & decrypt using IV (Initialization Vector)
"use strict";
var crypto = require("crypto");
var EncryptionHelper = (function () {
function getKeyAndIV(key, callback) {
crypto.pseudoRandomBytes(16, function (err, ivBuffer) {
var keyBuffer = (key instanceof Buffer) ? key : new Buffer(key) ;
@noopnik
noopnik / what-forces-layout.md
Last active September 22, 2015 09:35 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@noopnik
noopnik / gulpfile.js
Last active August 29, 2015 14:27 — forked from darkwing/gulpfile.js
var gulp = require('gulp');
var runSequence = require('run-sequence');
var minifyCss = require('gulp-minify-css');
var buildDir = './build/';
var minifyCssSettings = { advanced: true, aggressiveMerging: true };
// Main build
gulp.task('build', function() {
@noopnik
noopnik / protips.js
Last active August 29, 2015 14:24 — forked from nolanlawson/protips.js
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");