Skip to content

Instantly share code, notes, and snippets.

@mmirolim
mmirolim / list.c
Created August 9, 2019 21:26 — forked from icheishvili/list.c
Linked List in C with Iterator
struct list_node {
void* data;
struct list_node* next;
};
struct list {
struct list_node* head;
};
struct list* list_create() {
@mmirolim
mmirolim / cloud_metadata.txt
Created June 25, 2019 21:07 — forked from jhaddix/cloud_metadata.txt
Cloud Metadata Dictionary useful for SSRF Testing
## AWS
# from http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-categories
http://169.254.169.254/latest/user-data
http://169.254.169.254/latest/user-data/iam/security-credentials/[ROLE NAME]
http://169.254.169.254/latest/meta-data/iam/security-credentials/[ROLE NAME]
http://169.254.169.254/latest/meta-data/ami-id
http://169.254.169.254/latest/meta-data/reservation-id
http://169.254.169.254/latest/meta-data/hostname
http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key
@mmirolim
mmirolim / gen-list-with-exclude-list_test.go
Last active April 29, 2019 16:46
kiss with loops to generate []int [1,9] but excluding list []int [1,9]
package main
import "testing"
func generateBitset(vals []int) []int {
var x uint16 = 65535 >> 7
for _, v := range vals {
x = x ^ 1<<uint16(v-1)
}
const { performance } = require('perf_hooks');
const fibo = fib()
function fib() {
let x = 0
let y = 1
return function () {
const temp = x;
x = x + y;
package maxproduct
import "fmt"
// find max product of 3 numbers
func maxProduct(ints []int) int {
// scan for 3 max values and 2 smallest numbers (possible negative)
max := 0
// 32 bit
minVal := 1<<31 - 1
package reverse
func reverseStr(str string, specialChars string) string {
dic := map[byte]bool{}
for i := 0; i < len(specialChars); i++ {
dic[specialChars[i]] = true
}
// assume all are ascii characters
out := make([]byte, len(str))
@mmirolim
mmirolim / whyfparticle.scala
Last active May 24, 2018 18:42
FP ideas implementation
package main
import scala.annotation.tailrec
object FP extends App {
println("test solution")
val nums = List(1, -1, 1, 2,-1)
def comp(in: List[Int]): Int = {
@mmirolim
mmirolim / s3_count_size.sh
Created April 5, 2018 15:11
total size of s3 storage
#!/bin/bash
for bucket in $(aws s3 ls |awk '{print $3}'); do
echo $bucket
for size in $(aws s3 ls s3://${bucket} --recursive |awk '{print $3}'); do
total=$(expr $total + $size);
echo "total=$total b"
done
done
echo "total=$total b"
@mmirolim
mmirolim / set_struct_prop_from_env.go
Created January 24, 2018 08:35
Set struct props from env
// prints evn variable names
func printEnvNames(cfg interface{}) error {
envs := make([]string, 0, 10)
collectEnv := func(elem reflect.Value, i int) error {
// get env variable name from struct.field tag
name := elem.Type().Field(i).Tag.Get("env")
// skip if env tag not set
if name != "" {
envs = append(envs, name)
}
@mmirolim
mmirolim / Bulletproof_foods.md
Created November 5, 2017 11:57 — forked from JamesDullaghan/Bulletproof_foods.md
Dave Aspreys bulletproof diet food list

How many servings should I eat per day?

  • Fruit = 1-2 servings
  • Animal protein = 4 - 6 servings
  • Healthy fats = 5 - 9 servings
  • Healthy vegetables = 6 - 11 servings

How should I allocate my calories per day?

  • Healthy fats = 50%