Skip to content

Instantly share code, notes, and snippets.

View gleicon's full-sized avatar

Gleicon Moraes gleicon

View GitHub Profile
@gleicon
gleicon / detect.swift
Created February 7, 2021 13:33
Swift test to detect light/dark mode
// swiftc detect.swift -o detect
import Cocoa
func detectDarkTheme() {
let isDark = UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark"
if isDark {
print("Mode is Dark")
} else {
@gleicon
gleicon / cross_check_aws_ri_and_instances.py
Created April 5, 2019 18:51
cross check reservation IDs against running instances on aws
import boto3
import pprint
from collections import defaultdict
ec2 = boto3.client('ec2')
resp = ec2.describe_instances()
running_instances = defaultdict (lambda:0)
running_instances_apps = defaultdict(set)
@gleicon
gleicon / musical_notes.h
Last active February 8, 2019 16:28
arduino robot brain for gabi
// Reference: This list was adapted from the table located here:
// http://www.phy.mtu.edu/~suits/notefreqs.html
const float note_C0 = 16.35; //C0
const float note_Db0 = 17.32; //C#0/Db0
const float note_D0 = 18.35; //D0
const float note_Eb0 = 19.45; //D#0/Eb0
const float note_E0 = 20.6; //E0
const float note_F0 = 21.83; //F0
const float note_Gb0 = 23.12; //F#0/Gb0
const float note_G0 = 24.5; //G0

EDIT: go to https://golang.org/, skip the rest of this doc.

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Fligh

@gleicon
gleicon / list_objects_google_storage_boto3.py
Last active October 11, 2023 14:27
How to use boto3 with google cloud storage and python to emulate s3 access.
from boto3.session import Session
from botocore.client import Config
from botocore.handlers import set_list_objects_encoding_type_url
import boto3
ACCESS_KEY = "xx"
SECRET_KEY = "yy"
boto3.set_stream_logger('')
@gleicon
gleicon / README.md
Created August 9, 2017 16:35 — forked from lucindo/README.md
Using Graphite/Grafana to gather Locust.io test data

Using Locust.io with Grafana

On your locust master server:

  • Install and configure Graphite. Follow a good tutorial
  • Install and configure Grafana: tutorial

Use logra.py on your locust test file. See locustfile.py.

@gleicon
gleicon / kafka_inject_from_es.py
Last active April 22, 2021 20:28
es -> kafka
import xmltodict
import json
import sys
import getopt
import time
from datetime import datetime
import collections
from elasticsearch import Elasticsearch
import logging
from kafka import KafkaProducer
@gleicon
gleicon / service-checklist.md
Created January 15, 2017 00:03 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@gleicon
gleicon / snapshots.py
Created December 29, 2016 13:00 — forked from Eyjafjallajokull/README.md
AWS EBS - Find unused snapshots - this script generates csv raport about snapshot usage
import re
import boto3
import csv
from botocore.exceptions import ClientError
ec2 = boto3.client('ec2')
def get_snapshots():
return ec2.describe_snapshots(OwnerIds=['self'])['Snapshots']