Skip to content

Instantly share code, notes, and snippets.

View taybin's full-sized avatar
🤷‍♂️
¯\_(ツ)_/¯

Taybin Rutkin taybin

🤷‍♂️
¯\_(ツ)_/¯
View GitHub Profile
@fracasula
fracasula / context_cancel.go
Last active May 19, 2022 20:49
GoLang exiting from multiple go routines with context and wait group
package main
// Here's a simple example to show how to properly terminate multiple go routines by using a context.
// Thanks to the WaitGroup we'll be able to end all go routines gracefully before the main function ends.
import (
"context"
"fmt"
"math/rand"
"os"
@esamattis
esamattis / systemdunit.py
Last active November 10, 2021 23:04
Install Systemd units using Ansible
"""
Install Systemd units using Ansible
Handles unit restarting and systemd daemon reloading when the unit changes.
Also stops the unit correctly when uninstalled
In your playbook put this file to library/systemdunit.py and make sure the
server has python-sh package installed
@keshavbahadoor
keshavbahadoor / sql_to_csv.py
Created May 11, 2017 15:14
Convert SQL Query to CSV File in Python
# Generic reader method
# Reads data, prints columns, and prints each row to file
def do_query_to_csv_file(cursor, sql, csv_file):
try:
cursor.execute(sql)
file_header = ''
f = open(file_dir + csv_file + '.csv', 'w')
columns = [column[0] for column in cursor.description]
for col in columns:
import groovy.json.JsonSlurper
import org.sonatype.nexus.repository.storage.Asset
import org.sonatype.nexus.repository.storage.StorageFacet
def DOCKER_REPOSITORY_NAME = 'docker-hosted'
def dockerRepository = repository.repositoryManager.get(DOCKER_REPOSITORY_NAME)
def dockerBlobStore = blobStore.blobStoreManager.get(dockerRepository.configuration.attributes.storage.blobStoreName)
def storageTx = dockerRepository.facet(StorageFacet.class).txSupplier().get()
try {
@gerbsen
gerbsen / ssh_agent_start.fish
Last active January 26, 2024 08:13 — forked from schaary/ssh_agent_start.fish
Auto-launching ssh-agent in fish shell
# content has to be in .config/fish/config.fish
# if it does not exist, create the file
setenv SSH_ENV $HOME/.ssh/environment
function start_agent
echo "Initializing new SSH agent ..."
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
echo "succeeded"
chmod 600 $SSH_ENV
. $SSH_ENV > /dev/null
@mramato
mramato / DrawHorizonPoint.js
Created July 14, 2015 01:45
A simple Cesium example of drawing a label at the horizon point.
var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;
var ellipsoid = scene.globe.ellipsoid;
var entity = viewer.entities.add({
label : {
show : true,
outlineColor: Cesium.Color.BLACK,
verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
@terranware
terranware / eb-sns.json
Created May 12, 2015 20:19
Sample Elastic Beanstalk SNS Event
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:us-east-1...ElasticBeanstalkNotifications-Environment-foo-app...",
"Sns": {
"Type": "Notification",
"MessageId": "111",
"TopicArn": "arn:aws:sns:us-east-1...ElasticBeanstalkNotifications-Environment-foo-app",
cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git
@ArtemGr
ArtemGr / makefile
Last active February 15, 2024 14:29
SPI helper for a PostgreSQL CHECK when using one-to-many with a jsonb.
all: spi.so
spi.so: spi.o makefile
g++ -shared -o spi.so spi.o
cp --remove-destination spi.so /var/lib/postgresql/spi.so
spi.o: spi.cc makefile
g++ -g -O2 -Wall -std=c++11 -fpic -c -o spi.o -I/usr/include/postgresql -I/usr/include/postgresql/9.4/server spi.cc
clean:
@jboner
jboner / latency.txt
Last active May 5, 2024 03:12
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD