Skip to content

Instantly share code, notes, and snippets.

View loadaverage's full-sized avatar
🌐

Vadym Vasyliev loadaverage

🌐
View GitHub Profile
@voxxit
voxxit / .zshrc
Last active November 15, 2024 02:11
How to keep your .bashrc / .zshrc free of secrets!
############## 1Password Stuff ###############
# Check for 1Password CLI, and install if necessary:
command -v op >&- || brew install --cask 1password-cli
# You can simply export the 1Password secret's deep link in
# place of any sensitive value held in an environment variable:
export JIRA_API_TOKEN="op://example_vault/JIRA_API_TOKEN/credential"
# To use this at runtime, use: `op run -- <app> ..args..`
@SehgalDivij
SehgalDivij / middleware.py
Last active September 10, 2024 20:08
Middleware in django to log all requests and responses(Inspired by another Github gist I cannot find the link to, now)
"""
Middleware to log all requests and responses.
Uses a logger configured by the name of django.request
to log all requests and responses according to configuration
specified for django.request.
"""
# import json
import logging
from django.utils.deprecation import MiddlewareMixin
@xrstf
xrstf / letsencrypt.md
Last active October 30, 2024 07:03
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@revolunet
revolunet / python-es6-comparison.md
Last active November 2, 2024 12:22
# Python VS JavaScript ES6 syntax comparison

Python VS ES6 syntax comparison

Python syntax here : 2.7 - online REPL

Javascript ES6 via Babel transpilation - online REPL

Imports

import math
@josephspurrier
josephspurrier / values_pointers.go
Last active November 19, 2024 10:43
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@mikaelbr
mikaelbr / destructuring.js
Last active December 20, 2024 20:11
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@threez
threez / node-http-parser.js
Created January 23, 2014 07:42
In this example I played with the internal node http parser. This might be useful to folks that have to parse HTTP manually. For more info look at: https://github.com/joyent/node/blob/master/lib/_http_client.js
var HTTPParser = process.binding('http_parser').HTTPParser;
var parser = require("http").parsers.alloc();
parser.reinitialize(HTTPParser.RESPONSE);
parser.onBody = function(body) {
console.log(body.toString());
}
parser.onIncoming = function(response) {
console.log(response.headers);
console.log(response.statusCode);
@branneman
branneman / better-nodejs-require-paths.md
Last active October 18, 2024 20:29
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions