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
@Rican7
Rican7 / Bash 4 coprocesses and external data mapping
Last active December 11, 2015 19:44
Bash mapping data from an external file
NOTE! This requires Bash v4.x
@Rican7
Rican7 / processpls
Created October 16, 2015 18:50
Bash process. Pls.
#!/usr/bin/env bash
readonly PROGRESS_BAR_WIDTH=25
readonly PROGRESS_BAR_STEP_CHAR='#'
echo "Processing..."
for i in $(seq ${PROGRESS_BAR_WIDTH}); do
steps=$(printf "${PROGRESS_BAR_STEP_CHAR}%.0s" $(seq $i))
formatted=$(printf "%-${PROGRESS_BAR_WIDTH}s" ${steps})
@Rican7
Rican7 / autoset-hostname.sh
Last active November 9, 2015 18:22
Automatically set a structured, formatted hostname containing the AWS EC2 Instance ID for an EC2 virtual machine running RHEL/CentOS 6.x.
#!/usr/bin/env bash
# Enable strict error handling
set -u -o pipefail
# Define our hostname formats
readonly HOSTNAME_FORMAT="%s.my-service-name.environment-name"
readonly FQDN_HOSTNAME_FORMAT="%s.service.example.com"
# Get the current hostname
@Rican7
Rican7 / conventional-json.go
Last active November 27, 2023 07:10
Marshal JSON in Golang using common lower-snake-case object key conventions
package main
import (
"bytes"
"encoding/json"
"fmt"
"regexp"
"time"
)
@Rican7
Rican7 / loop-curl.sh
Created November 18, 2015 06:20
Perform a cURL variable path request in a loop
#!/usr/bin/env bash
readonly ACCESS_TOKEN=""
readonly IDS=(
1
2
3
)
for id in ${IDS[@]};
@Rican7
Rican7 / list-interface-types-for-go-project.sh
Last active March 1, 2016 19:23
List interface types for a Go project using Sift (https://sift-tool.org/)
#!/usr/bin/env sh
# NOTE! This requires the "Sift" tool, GNU "sed", and Go (Golang)
#
# https://sift-tool.org/
# https://github.com/svent/sift
# https://www.gnu.org/software/sed/
# https://golang.org/
# https://golang.org/cmd/go/#hdr-Show_documentation_for_package_or_symbol
@Rican7
Rican7 / configure-vim
Last active September 15, 2016 22:03
My VIM compilation configure line
#!/usr/bin/env bash
./configure --prefix=/usr/local --with-features=huge --enable-perlinterp --enable-pythoninterp --enable-python3interp --enable-rubyinterp --enable-luainterp --enable-cscope [email protected]
@Rican7
Rican7 / unicode_rune_handling.go
Created March 10, 2016 19:01
Unicode rune handling in multiple languages
package main
import (
"fmt"
"unicode/utf8"
)
const strangeMessage = "TᕼIᔕ ᗰᕮᔕᔕᗩGᕮ Iᔕ ᑭᖇOTᕮᑕTᕮᗪ ᗷY ᗩ ᔕᑭᕮᑕIᗩᒪ ᖴOᑎT. IT'ᔕ IᗰᑭOᔕᔕIᗷᒪᕮ TO ᑕOᑭY IT. TᖇY ᗩᑎᗪ YOᑌ ᗯIᒪᒪ ᖴᗩIᒪ"
func main() {
@Rican7
Rican7 / parse_windowszones.php
Last active November 22, 2018 09:42
Parsing Unicode CLDR Windows Timezones in PHP
<?php
// The location of the Unicode CLDR "windowsZones" mappings here
const XML_URL = 'http://unicode.org/cldr/data/common/supplemental/windowsZones.xml';
const XML_ZONE_MAP_XPATH = '/supplementalData/windowsZones/mapTimezones/mapZone';
const ZONE_TERRITORY_ATTRIBUTE = 'territory';
const ZONE_IANA_NAME_ATTRIBUTE = 'type';
const ZONE_WINDOWS_NAME_ATTRIBUTE = 'other';
@Rican7
Rican7 / parse_ews_wsdl_supported_operation_input_headers.php
Created March 24, 2016 23:29
Parsing an EWS (Exchange Web Services) WSDL to determine the supported input headers per service operation in PHP
<?php
// The location of the EWS WSDL here (Office365 here for example)
const WSDL_URL = 'https://outlook.office365.com/EWS/Services.wsdl';
const NAMESPACE_WSDL_PREFIX = 'wsdl';
const NAMESPACE_WSDL_URI = 'http://schemas.xmlsoap.org/wsdl/';
const NAMESPACE_SOAP_PREFIX = 'soap';
const NAMESPACE_SOAP_URI = 'http://schemas.xmlsoap.org/wsdl/soap/';