Skip to content

Instantly share code, notes, and snippets.

View alonisser's full-sized avatar

Alonisser alonisser

View GitHub Profile
@pcreux
pcreux / clone-heroku-app
Last active December 14, 2023 14:33
Script to clone a heroku app (including buildpacks, users, add-ons, environment variables, lab features)
#!/usr/bin/env ruby
# Copy a heroku app (buildpacks, add-ons, labs, config, users).
# This script is idempotent so it can run against an existing app.
#
# Usage:
# $> clone-heroku-app source-app target-app
require 'json'
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')
@mrchristine
mrchristine / spark_schema_save_n_load.py
Created May 28, 2019 21:12
Read / Write Spark Schema to JSON
##### READ SPARK DATAFRAME
df = spark.read.option("header", "true").option("inferSchema", "true").csv(fname)
# store the schema from the CSV w/ the header in the first file, and infer the types for the columns
df_schema = df.schema
##### SAVE JSON SCHEMA INTO S3 / BLOB STORAGE
# save the schema to load from the streaming job, which we will load during the next job
dbutils.fs.rm("/home/mwc/airline_schema.json", True)
with open("/dbfs/home/mwc/airline_schema.json", "w") as f:
@durden
durden / getsizeof_recursive.py
Last active February 13, 2023 13:59
Get size of Python object recursively to handle size of containers within containers
##### Taken from https://github.com/bosswissam/pysize
import sys
def get_size(obj, seen=None):
"""Recursively finds size of objects"""
size = sys.getsizeof(obj)
if seen is None:
seen = set()
@niranjv
niranjv / change_lambda_logger_format.py
Last active February 7, 2024 11:03
Change Python logger format in AWS Lambda
# 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)
@fabiodamasceno
fabiodamasceno / gulpfile.config.js
Last active March 29, 2017 07:00
Browserify Gulpfile
'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 November 8, 2022 11:49
Create Environment Variables in EC2 Hosts from EC2 Host Tags, just like Beanstalk or Heroku does!
######
# 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 February 15, 2018 08:54
Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
#!/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 August 29, 2015 14:06
Nginx Dashboard For Logstash
{
"title": "Nginx Web",
"services": {
"query": {
"list": {
"0": {
"query": "response:[200 TO 299]",
"alias": "OK",
"color": "#7EB26D",
"id": 0,
@mlouro
mlouro / gulpfile.js
Last active June 21, 2022 23:20
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');