Skip to content

Instantly share code, notes, and snippets.

@angelo-v
angelo-v / jwt-decode.sh
Last active May 3, 2024 10:56
Decode a JWT via command line
# will not work in all cases, see https://gist.github.com/angelo-v/e0208a18d455e2e6ea3c40ad637aac53#gistcomment-3439904
function jwt-decode() {
sed 's/\./\n/g' <<< $(cut -d. -f1,2 <<< $1) | base64 --decode | jq
}
JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
jwt-decode $JWT
@aws-scripting-guy
aws-scripting-guy / gist:884ffa9d44bd14f7493a670543284552
Created April 2, 2016 18:33
AWS EC2 metadata. Check attached IAM role from EC2 instance. Get temporary credentials.
# Get IAM Role name from Instance Profile Id
curl http://169.254.169.254/latest/meta-data/iam/info
# Get credentials
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/<role-name>
# More info
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
@kwarunek
kwarunek / yieldable_asyncio_udp_client.py
Last active October 4, 2018 11:24
Yieldable/awaitable asyncio UDP client (sendto only actually)
import asyncio
import socket
class UDPClient():
def __init__(self, host, port, loop=None):
self._loop = asyncio.get_event_loop() if loop is None else loop
self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self._sock.setblocking(False)
self._addr = (host, port)
@nelstrom
nelstrom / plover-nkro-on-ergodox.md
Last active April 2, 2024 20:18
Instructions on how to get a Plover keymap working with NKRO on ErgoDox keyboard.

[Plover][] is an awesome open source stenography program, but to run the software [you need an NKRO keyboard][nkro]. The [ErgoDox keyboard][ergodox] can be made to run in NKRO mode by following these steps.

Install dependencies

These instructions are based on this document, which assumes you're using Windows. I'm using a mac, and I had to download and install the [CrossPack for AVR Development][crosspack] before the build process worked.

Download the source

The NKRO firmware and Plover keymap can be found in the simon_layout branch of @shayneholmes fork of tmk_keyboard. Get the source:

@jaredwinick
jaredwinick / README.md
Last active January 26, 2023 21:54
Z-Order Curve with Query

Z-Order curves are used to encode multiple dimensions to one dimension while maintaining locality. This feature makes them useful for indexing multidimensional data such as geospatial data. In BigTable-like systems (Accumulo, HBase, Cassandra a z-order curve index can translate a bounding box query to a single range scan. As this example shows, sometimes the locality properties of the curve are very good and few points outside the bounding box are scanned. Other times though, many points outside the bounding box are scanned if using a single range.

This example was inspired by Mike Bostock's Quadtree example

@seanlilmateus
seanlilmateus / gist:1536136
Created December 29, 2011 20:51
macruby core animation Fireworks, have a nice macruby new year
#!/usr/local/bin/macruby
framework 'Cocoa'
framework 'QuartzCore'
framework 'CoreGraphics' # Mountain Lion Update
class FireworkDelegate
attr_accessor :window
def initWithURL(url)
case url
@pvinis
pvinis / face_detector.rb
Created December 7, 2011 12:06
run with "macruby face_detector.rb" or "macruby face_detector.rb https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-snc7/304055_10150415385415891_522505890_10347873_1682210515_n.jpg?dl=1" for a photo of me with woody and buzz lightyear :p
framework 'Cocoa'
class NSColor
def toCGColor
color_RGB = colorUsingColorSpaceName(NSCalibratedRGBColorSpace)
## approach #1
# components = Array.new(4){Pointer.new(:double)}
# color_RGB.getRed(components[0],
# green: components[1],
# blue: components[2],
@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@EmmanuelOga
EmmanuelOga / callback.rb
Created December 1, 2011 15:54
callback test.
require 'benchmark'
class Proc
def slow_callback(callable, *args)
self === Class.new do
method_name = callable.to_sym
define_method(method_name) { |&block| block.nil? ? true : block.call(*args) }
define_method("#{method_name}?") { true }
def method_missing(method_name, *args, &block) false; end
end.new
@ralfebert
ralfebert / gist:1255969
Created October 1, 2011 12:17
Ruby String helpers: indent, to_javadoc, markdown, pygmentize
# Placed in Public Domain by Ralf Ebert, 2008
#
# THIS SOFTWARE IS PROVIDED BY Ralf Ebert ''AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL Ralf Ebert BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT