Skip to content

Instantly share code, notes, and snippets.

@zgorizzo69
zgorizzo69 / Drone CI-grafana dashboard.json
Created March 25, 2020 12:47
grafana dashboard for Drone.io Drone CI with kubernetes runner
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@douglasmiranda
douglasmiranda / drone.md
Created November 26, 2018 22:59
Status: how Drone deals with monorepo; dir/file changed conditions

Well there's no builtin way of doing.

The problem is:

We need a way of skipping steps, or conditional pipelines that are triggered when some dir/* files.* were changed since last commit.

Useful if you maintain a:

  • Monorepo
@alkrauss48
alkrauss48 / Dockerfile
Last active November 10, 2022 16:24
Running a docker container as a non-root user
# By default, Docker containers run as the root user. This is bad because:
# 1) You're more likely to modify up settings that you shouldn't be
# 2) If an attacker gets access to your container - well, that's bad if they're root.
# Here's how you can run change a Docker container to run as a non-root user
## CREATE APP USER ##
# Create the home directory for the new app user.
RUN mkdir -p /home/app
@pcn
pcn / example.md
Last active September 14, 2023 19:40
Using jq to get+filter aws data

I've been playing with jq, and I've been having a hard time finding examples of how it works with output from a service like AWS (which I use a lot).

Here is one I use a lot with vagrant-ec2.

When we're launching and killing a lot of instances, the AWS API is the only way to track down which instances are live, ready, dead, etc.

To find instances that are tagged with e.g. {"Key" = "Name", "Value" = "Web-00'} in the middle of a vagrant dev cycle, or a prod launch/replace cycle, you can do something like this:

@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@praseodym
praseodym / AESGCMUpdateAAD2.java
Last active June 7, 2021 16:38
JDK8 AES-GCM code example
import javax.crypto.*;
import javax.crypto.spec.GCMParameterSpec;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import java.util.Arrays;
public class AESGCMUpdateAAD2 {
// AES-GCM parameters
public static final int AES_KEY_SIZE = 128; // in bits
@debasishg
debasishg / gist:8172796
Last active March 15, 2024 15:05
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&rep=rep1&t
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@siddontang
siddontang / hmac.lua
Created May 18, 2013 09:24
openresty string hmac implementation
local ffi = require "ffi"
local sha512 = require "resty.sha512"
local aes = require "resty.aes"
local ffi_new = ffi.new
local ffi_str = ffi.string
local C = ffi.C
local setmetatable = setmetatable
local error = error
@nosolopau
nosolopau / s3.js
Last active May 4, 2017 08:53
Amazon S3 upload policy generation with JavaScript (Node.js).
var crypto = require("crypto");
var moment = require("moment")
var s3 = {
generateS3Policy: function (fileName) {
var s3Policy = {
'conditions': [
{'bucket': CONF.s3.bucket},
['starts-with', '$key', 'uploads/' + fileName],
{'acl': 'public-read'},