Skip to content

Instantly share code, notes, and snippets.

View Rican7's full-sized avatar
😮
My dotfiles just keep getting better... and its been OVER 10 YEARS NOW! ⌚😮🤯

Trevor N. Suarez Rican7

😮
My dotfiles just keep getting better... and its been OVER 10 YEARS NOW! ⌚😮🤯
View GitHub Profile
@danrigsby
danrigsby / packer-ami-id
Last active December 14, 2023 15:07
Get AMI ID from a packer build
packer build packer.json 2>&1 | sudo tee output.txt
tail -2 output.txt | head -2 | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }' > sudo ami.txt
@cryptix
cryptix / client.go
Created June 22, 2014 11:09
multipart upload with io.Pipe
package main
import (
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"runtime"
@Seldaek
Seldaek / sort.js
Last active August 29, 2015 14:04
PHP Wiki Vote Chrono-sort
// Run this in web console
var rows = $('table tr').get();
rows.sort(function(a, b) {
var keyA = $(a).find('img[src="/lib/images/success.png"]').attr('title') || '0';
var keyB = $(b).find('img[src="/lib/images/success.png"]').attr('title') || '0';
if (keyA < keyB) return -1; if (keyA > keyB) return 1; return 0;
});
$.each(rows, function(index, row) {$('table tbody').append(row);});
@auroraeosrose
auroraeosrose / gist:2e90ace602224e00494d
Last active August 29, 2015 14:05
Fixing PHP streams
  1. Interfaces for streams wrappers (clean up apis) - primarily userland, small to no BC
  2. Resources -> objects (engine storage and attachment) - primarily core, some BC issues
  3. finish implementations for callbacks - primarily feature addition
  4. async IO features (see: jpauli) - feature addition with core implications and some BC issues
  5. curl:// stream wrapper - feature addition (functionality of --with-curl-wrappers but with curl:// as prefix)
  6. filtering api - buckets hard to use, user_filter class is api possessed - userland and BC
  7. factory registration for wrapper creation - feature addition
  8. ability to plug into transports from php land instead of requiring C extensions

Streams Interfaces:

@irgeek
irgeek / README.md
Last active December 10, 2021 16:42
Finding AMIs after building an image with Packer

Finding Packer-generated AMIs automatically after builds

The basic technique is to have Packer add a tag with a unique value during the build, and use AWS' built-in filtering capabilities to find that specific AMI after the build finishes.

  • template.json - Shows the settings that need to be added to your template
  • build.sh - Shows how to use the template to do a build and retrieve the AMI information
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@doctorallen
doctorallen / timereport.sh
Last active August 29, 2015 14:13
Run A Time Report
#!/usr/bin/env bash
# You will want to also add the git today command: https://github.com/doctorallen/dotfiles/blob/master/.gitconfig#L49
root=$1
if [ -n "$root"]
then
echo "Error: please define the root directory location for your report."
read root
fi
lastchar=${#root}-1
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 28, 2025 12:54
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@ksimka
ksimka / inarray_flipisset_arraysearch.php
Created March 4, 2015 13:24
in_array vs array_flip+isset vs array_search
<?php
$a = [];
//$s = 123456;
$s = 's6tbdfgj222dJGk';
$rs = str_repeat("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 10);
$numGen = function() {
return rand(1, 9999999);
};
@mcos
mcos / generate_token.go
Created March 27, 2015 14:37
Generate a 128 character random string in Go
package main
import (
"crypto/rand"
"fmt"
)
func randStr(strSize int) string {
dictionary := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"