- Fruit = 1-2 servings
- Animal protein = 4 - 6 servings
- Healthy fats = 5 - 9 servings
- Healthy vegetables = 6 - 11 servings
- Healthy fats = 50%
struct list_node { | |
void* data; | |
struct list_node* next; | |
}; | |
struct list { | |
struct list_node* head; | |
}; | |
struct list* list_create() { |
## 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 |
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)) |
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 = { |
#!/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" |
// 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) | |
} |