Skip to content

Instantly share code, notes, and snippets.

View apremalal's full-sized avatar

Anuruddha apremalal

View GitHub Profile
@Zitrax
Zitrax / stringformat_constexpr_if.cpp
Last active November 7, 2023 23:06
stringformat with constexpr if
#include <string>
#include <iostream>
#include <memory>
/**
* Convert all std::strings to const char* using constexpr if (C++17)
*/
template<typename T>
auto convert(T&& t) {
@anokun7
anokun7 / main.go
Created August 1, 2017 16:05 — forked from filewalkwithme/main.go
Listening multiple ports on golang http servers
package main
import (
"net/http"
)
func main() {
finish := make(chan bool)
server8001 := http.NewServeMux()
@estk
estk / main.go
Created December 14, 2016 21:12
A Tour of Go: Web Crawler Solution
package main
import (
"fmt"
"sync"
)
type Crawler struct {
crawled map[string]bool
mux sync.Mutex
@pkuczynski
pkuczynski / parse_yaml.sh
Last active July 9, 2024 04:42
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}