Skip to content

Instantly share code, notes, and snippets.

@rymndhng
rymndhng / ssm
Created February 22, 2020 07:17
ssm using pipes
#!/bin/sh -x
#
# CLI Tool for accessing instances via ssm without having to pass in params
#
# Dependencies: awscli, zsh (Included by default on Catalina)
#
HELP=$(cat <<-EOF
Usage:
ssm i-073404e8ece4624b5 [OPTIONAL] --profile staging
@rymndhng
rymndhng / allowed_host.clj
Created October 27, 2019 16:28
Check if the host is in a private range
(defn allowed-host?
"Checks whether the given Inet Address for outbound request is allowed"
[^java.net.InetAddress inet-addr]
(try
(not (or (.isLinkLocalAddress inet-addr) ; 169.0.0.0/8
(.isLoopbackAddress inet-addr) ; 127.0.0.1
(.isAnyLocalAddress inet-addr) ; 0.0.0.0
(.isMulticastAddress inet-addr) ; 224.0.0.0 to 239.255.255.255
(.isSiteLocalAddress inet-addr) ; 10.0.0.0/8, 192.168.0.0/16
))
@rymndhng
rymndhng / bookmarklet.js
Last active April 27, 2021 22:38
JIRA Issue Bookmarklet
javascript:(function() {
"support old jira first";
const descriptionElement = document.getElementById("description");
if (descriptionElement) {
descriptionElement.value = "*What*:\n\n*Why*:\n\n*What does success look like?*\n\n*Testing Notes*\n\n*Technical Notes/Hints*\n\n";
return;
}
"support new jira issue view";
@rymndhng
rymndhng / git-get
Last active February 29, 2024 05:09
Git Get
#!/bin/bash -x
#
# Clones Git Projects into directory of <projects_dir>/<group>/<repo_name>
#
# Tested with support for Github, Bitbucket & Sourcehut.
#
# By default, clones to $HOME/projects. This can be overriden by setting
# GIT_GET_PROJECTS_DIR to another directory.
#
# Usage:
@rymndhng
rymndhng / act.txt
Last active October 15, 2017 20:11
See that `${1:$(string-inflection-upcase-function yas-text)}` is used 4 times.
# -*- mode: snippet -*-
# name: action
# key: act
# expand-env: ((yas-indent-line 'fixed))
# Depends on string-inflection package
# --
export const ${1:$(string-inflection-upcase-function yas-text)} = '${1:$(string-inflection-upcase-function yas-text)}'
type ${1:$$(string-inflection-camelcase-function yas-text)}Payload = {
$0
}
@rymndhng
rymndhng / 0PrismaticToJson.md
Last active August 8, 2023 16:25
Prismatic Schema to Json Schema

Prismatic Schema to Json Schema

Simple parser that takes Prismatic/Schema in and dumps JsonSchema out. Waow!

@rymndhng
rymndhng / Clojure Block Comment YaSnippet
Last active November 10, 2015 21:58
Lisp Snippet to add block comment to fill column.
An awesome snippet for adding block comment lines in lisps
# Usage:
Type the following:
```
bc <tab> Subscription Handlers <tab>
```
@rymndhng
rymndhng / ext.clj
Created October 23, 2015 06:07
CLJ-HTTP Dynamic Basic Auth
(ns ext
"This module adds default parameters to requests such as the ability to dynamically set the
user credentials. This pattern could be used to do many things such
as append {:debug true}, useful in an interactive environment."
(:require [clj-http.client :as http]))
(def ^:dynamic *additional-params*
"Available at any time to set additional params to
Automatically bound when `with-middleware` is used."
{})
@rymndhng
rymndhng / main.py
Created January 3, 2015 22:20
Simple Python Transactional Object
def delete_instance(instance, args):
"""Given an instance, deletes it!"""
if instance:
print "Rolling back %s" % instance.id
instance.terminate()
@Rollback(delete_instance)
def create_instance(conn, kwargs):
"""Performs creation of instance by wrapping over the AWS API and injecting
@rymndhng
rymndhng / solve.py
Last active August 29, 2015 14:12
Solves valid number parsing for: https://oj.leetcode.com/problems/valid-number/. Parsing strings for valid integer value is something you use in your Programming Languages. Here -- I tried to model the code similar to how I would conceptually think of the problem. In this case -- Python was great for providing a minimal interface
# use a state machine model
class State:
def __init__(self, name, chars):
self.name = name
self.chars = chars
def __contains__(self, item):
return item in self.chars
def __repr__(self):