Skip to content

Instantly share code, notes, and snippets.

View trungie's full-sized avatar

Trung Hoang trungie

View GitHub Profile
@bedecarroll
bedecarroll / install_host_client_vib.yml
Created December 6, 2015 05:52
Ansible playbook to install the VMware ESXi Embedded Host Client. Requires the VIB (esxui-signed.vib) to be in the folder as the playbook. Will install or upgrade as required.
---
- hosts: esxi
tasks:
- name: Get list of installed VIBs
shell: esxcli software vib get -n "esx-ui"
register: vibs
changed_when: false
ignore_errors: yes
@glogiotatidis
glogiotatidis / remove-gpg-user.sh
Created May 24, 2016 11:50
Git-crypt remove user.
#!/bin/bash
#
# Script to remove GPG key from git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
@kevin-lee
kevin-lee / JProfiler-with-Docker.md
Created August 10, 2016 15:55
JVM Profiler with Docker

JProfiler with Docker

Docker

DockerFile

DockerFile should have JProfiler installation.

RUN wget <JProfiler file location> -P /tmp/ && \
  tar -xzf /tmp/<JProfiler file> -C /usr/local && \
  rm /tmp/<JProfiler file>
@duyet
duyet / duyetdev-spark-to-parquet.scala
Created September 21, 2016 03:35
Spark convert CSV to Parquet.
def convert(sqlContext: SQLContext, filename: String, schema: StructType, tablename: String) {
// import text-based table first into a data frame.
// make sure to use com.databricks:spark-csv version 1.3+
// which has consistent treatment of empty strings as nulls.
val df = sqlContext.read
.format("com.databricks.spark.csv")
.schema(schema)
.option("delimiter","|")
.option("nullValue","")
.option("treatEmptyValuesAsNulls","true")
@balupton
balupton / README.md
Last active February 23, 2022 04:19
Convert XPS to PDF

Convert XPS to PDF on macOS

# IF you are on alpine, install the dependencies
apk add curl git bash

# IF you are on ubuntu, install the dependencies
apt update
apt install curl git bash

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@kabbi
kabbi / ota.ino
Created October 25, 2018 18:29
Base ArduinoOTA + WifiManager for esp8266
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
#include <ArduinoOTA.h>
#include <WebSocketsClient.h>
#include <DNSServer.h>
void setup() {
Serial.begin(115200);
@glnds
glnds / aws-transfer-sftp.yaml
Last active February 23, 2024 09:53
CloudFormation template for AWS Transfer for SFTP
---
AWSTemplateFormatVersion: '2010-09-09'
Description: some-sftp-server
Parameters:
HostedZoneIdParam:
Type: String
Description: Hosted Zone ID
SFTPHostnameParam:
Type: String
##Dockerfile
FROM centos:7
RUN yum update -y && yum install -y wget perl openssl-devel dmidecode
RUN wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash
RUN yum install -y srvadmin-idracadm7
RUN cp /opt/dell/srvadmin/bin/idracadm7 /usr/local/bin/racadm
##Build via... (run inside somedir/Dockerfile)