Skip to content

Instantly share code, notes, and snippets.

Avatar

Alonisser alonisser

View GitHub Profile
View setInterval-bunching.js
let i = 0
const start = Date.now()
setInterval(() => console.log(++i, Date.now() - start), 1000)
console.time('bigcalc')
for (let i = 0; i < 10000000000; ++i) {
Math.cos(37863443 * Math.exp(23749374))
}
console.timeEnd('bigcalc')
@niranjv
niranjv / change_lambda_logger_format.py
Last active Feb 18, 2021
Change Python logger format in AWS Lambda
View change_lambda_logger_format.py
# Python logger in AWS Lambda has a preset format. To change the format of the logging statement,
# remove the logging handler & add a new handler with the required format
import logging
import sys
def setup_logging():
logger = logging.getLogger()
for h in logger.handlers:
logger.removeHandler(h)
View gulpfile.config.js
'use strict';
var config = {
sass : {
errLogToConsole: true,
outputStyle: 'compressed'
},
bower: './bower_components',
source: {
main: '.src/',
html:{
@marcellodesales
marcellodesales / ec2-host-from-tag-to-env-vars.sh
Last active Feb 10, 2021
Create Environment Variables in EC2 Hosts from EC2 Host Tags, just like Beanstalk or Heroku does!
View ec2-host-from-tag-to-env-vars.sh
######
# Author: Marcello de Sales (marcello.desales@gmail.com)
# Description: Create Create Environment Variables in EC2 Hosts from EC2 Host Tags
#
### Requirements:
# * Install jq library (sudo apt-get install -y jq)
# * Install the EC2 Instance Metadata Query Tool (http://aws.amazon.com/code/1825)
#
### Installation:
# * Add the Policy EC2:DescribeTags to a User
@tomconte
tomconte / event_hubs_send.py
Last active Feb 15, 2018
Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
View event_hubs_send.py
#!/usr/bin/python
# Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
import sys
import commands
from proton import *
# Event Hub address & credentials
# amqps://<keyname>:<key>@<namespace>.servicebus.windows.net/<eventhubname>
@erez-rabih
erez-rabih / nginx-dashboard.json
Last active Aug 29, 2015
Nginx Dashboard For Logstash
View nginx-dashboard.json
{
"title": "Nginx Web",
"services": {
"query": {
"list": {
"0": {
"query": "response:[200 TO 299]",
"alias": "OK",
"color": "#7EB26D",
"id": 0,
@mlouro
mlouro / gulpfile.js
Last active Sep 22, 2020
gulpfile.js with browserify, jshint, libsass, browserSync for livereload, image optimization and system notifications on errors
View gulpfile.js
'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');
@eezis
eezis / update postgres last value.py
Last active Oct 7, 2017
A code snippet to update the "last_value" of postgres's sequence generator when it is out of sync with the actual values in your tables.
View update postgres last value.py
"""
This utility addresses the InegrityError that occurs when you try to add a new record to
(probably a recently ported) postgres database while using Django, here's more . . .
duplicate key value violates unique constraint "<app>_<table>_pkey"
DETAIL: Key (id)=(2) already exists.
The problem here is that the Postgres sequence generators are out of sync with your data.
Here's a good overview: http://www.vlent.nl/weblog/2011/05/06/integrityerror-duplicate-key-value-violates-unique-constraint/
@Stanback
Stanback / nginx.conf
Last active Feb 3, 2021
Example Nginx configuration for serving pre-rendered HTML from Javascript pages/apps using the Prerender Service (https://github.com/collectiveip/prerender).Instead of using try_files (which can cause unnecessary overhead on busy servers), you could check $uri for specific file extensions and set $prerender appropriately.
View nginx.conf
# Note (November 2016):
# This config is rather outdated and left here for historical reasons, please refer to prerender.io for the latest setup information
# Serving static html to Googlebot is now considered bad practice as you should be using the escaped fragment crawling protocol
server {
listen 80;
listen [::]:80;
server_name yourserver.com;
root /path/to/your/htdocs;
@plentz
plentz / nginx.conf
Last active Feb 27, 2021
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
View nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048