Skip to content

Instantly share code, notes, and snippets.

View epequeno's full-sized avatar

Steven Pequeno epequeno

View GitHub Profile
@epequeno
epequeno / asg_ips.sh
Created September 11, 2017 13:15
IPs for ASG instances
#!/bin/bash
# get the IPs for current instance in ASG
region='us-east-1'
asgs=$(aws --region ${region} autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?contains(AutoScalingGroupName, `stag`)].[AutoScalingGroupName][]' --output text)
for asg in ${asgs[@]}; do
echo "${asg}"
instances=$(aws --region ${region} autoscaling describe-auto-scaling-groups --auto-scaling-group-names ${asg} --query 'AutoScalingGroups[].Instances[].[InstanceId][]' --output text)
for instance in ${instances[@]}; do
@epequeno
epequeno / beer.rs
Created May 30, 2017 00:10
solution to exercism beer-song problem
use std::collections::HashMap;
fn main() {
println!("{}", sing(3, 0));
for i in (0..11).rev() {
println!("{}", verse(i));
}
}
@epequeno
epequeno / big_fibo.go
Created May 23, 2017 04:06
use math/big to compute fibo with memoization
package main
import "fmt"
import "math/big"
// we can't use a reference type as a key (*big.Int) so we need to cast to string to keep track
var seen = make(map[string]*big.Int)
func fibo(n *big.Int) *big.Int {
zero := big.NewInt(0)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onClick)
import String exposing (..)
import Char exposing (..)
main =
Html.beginnerProgram { model = model
, view = view
, update = update
@epequeno
epequeno / cfn_build_script_sublime_text.md
Last active January 8, 2019 17:46
ST3 cloudformation build system
@epequeno
epequeno / fibo.rs
Created November 28, 2016 11:06
fibo in rust
fn main() {
for x in 1..11 {
println!("{} -> {}", x, fibo(x));
}
}
fn fibo(n: i32) -> f64 {
let phi = (1_f64 + 5_f64.sqrt()) / 2_f64;
(phi.powf(n as f64) / 5_f64.sqrt()).round()
}
@epequeno
epequeno / run.py
Created October 20, 2016 06:01
slackbot to monitor urls for 200 status code
# stdlib
import multiprocessing as mp
from time import sleep
from subprocess import call
from urllib.parse import quote
# 3rd party
import requests
from slackbot.bot import Bot, respond_to
import validators
$ cat tmp.txt
one
two
three
four
five
six
other
$ awk '/^t/ {q=1}q' tmp.txt
two
import Html exposing (..)
import Html.App as App
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Random
-- MAIN
main =
App.program
(lambda _, __, ___, ____, _____, ______, _______, ________:
getattr(
__import__(True.__class__.__name__[_] + [].__class__.__name__[__]),
().__class__.__eq__.__class__.__name__[:__] +
().__iter__().__class__.__name__[_____:________]
)(
_, (lambda _, __, ___: _(_, __, ___))(
lambda _, __, ___:
chr(___ % __) + _(_, __, ___ // __) if ___ else
(lambda: _).func_code.co_lnotab,