Skip to content

Instantly share code, notes, and snippets.

View scottstensland's full-sized avatar
💭
You learn more from a person at play than a year of conversation - Plato

Scott Stensland scottstensland

💭
You learn more from a person at play than a year of conversation - Plato
View GitHub Profile
@StevenACoffman
StevenACoffman / goGetPrivate.md
Last active April 28, 2024 13:59 — forked from dmitshur/gist:6927554
How to `go get` private repos using SSH key auth instead of password auth.

Set GOPRIVATE to match your github organization

Cloning the repo using one of the below techniques should correctly but you may still getting an unrecognized import error.

As it stands for Go v1.13, I found in the doc that we should use the GOPRIVATE variable like so:

GOPRIVATE=github.com/ORGANISATION_OR_USER_NAME go get -u -f github.com/ORGANISATION_OR_USER_NAME/REPO_NAME

The 'go env -w' command (see 'go help env') can be used to set these variables for future go command invocations.

How to go get private repos using SSH key auth instead of password auth.

@dmitshur
dmitshur / main.go
Last active March 16, 2020 10:59
A simple server for HTTPS and HTTP protocols.
// A simple server for HTTPS and HTTP protocols. It implements these behaviors:
//
// • uses Let's Encrypt to acquire and automatically refresh HTTPS certificates
//
// • redirects HTTPS requests to canonical hosts, reverse proxies requests to internal backing servers
//
// • redirects all HTTP requests to HTTPS
//
// • gates certain endpoints with basic auth, using bcrypt-hashed passwords
//
@ramast
ramast / pulse-recorder.py
Last active September 3, 2023 11:12
Record a program's output with PulseAudio
#!/usr/bin/env python3
# Based on code from these stackoverflow answers:
# https://askubuntu.com/questions/60837/record-a-programs-output-with-pulseaudio/910879#910879
import re
import subprocess
import sys
import os
import signal
from time import sleep
@vkarpov15
vkarpov15 / promise1.js
Created April 5, 2018 12:38
Write Your Own Node.js Promise Library from Scratch, Part 1
class MyPromise {
constructor(executor) {
if (typeof executor !== 'function') {
throw new Error('Executor must be a function');
}
// Internal state. `$state` is the state of the promise, and `$chained` is
// an array of the functions we need to call once this promise is settled.
this.$state = 'PENDING';
this.$chained = [];
@fubarhouse
fubarhouse / loop_files_folders_recursively.go
Last active January 2, 2023 10:31 — forked from francoishill/loop_files_folders_recursively.go
Loop through files and folders recursively in golang
package main
import (
"fmt"
"os"
"path/filepath"
)
func run() ([]string, error) {
searchDir := "c:/path/to/dir"
@ankanch
ankanch / getlocalIP.go
Created October 25, 2017 13:13
[Golang] Get Public IP address via Public IP API
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.ipify.org?format=text" // we are using a pulib IP API, we're using ipify here, below are some others
// https://www.ipify.org
// http://myexternalip.com
@ramast
ramast / pulse-recorder.bash
Last active March 20, 2024 22:38
Record pulseaudio output to mp3 file
#!/bin/bash
# Credit: This code is based on answers provided by Waschtl and KrisWebDev
# https://askubuntu.com/questions/60837/record-a-programs-output-with-pulseaudio
# NOTE: An improved script written in python can be found here https://gist.github.com/ramast/c47bd5e57586e9c2deb74975e27089f0
cleanup(){
if [ -z "$module_id" ]
then
exit 3
fi
"""
Implements a simple HTTP/1.0 Server
"""
import socket
def handle_request(request):
"""Handles the HTTP request."""
@Volcanoscar
Volcanoscar / greyscale.frag
Created January 19, 2017 08:28 — forked from wiseoldduck/greyscale.frag
A simple glsl color -> greyscale shader, using luminosity method
// fragment shader
//
// RGBA color to RGBA greyscale
//
// smooth transition based on u_colorFactor: 0.0 = original, 1.0 = greyscale
//
// http://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/
// "The luminosity method is a more sophisticated version of the average method.
// It also averages the values, but it forms a weighted average to account for human perception.
// We’re more sensitive to green than other colors, so green is weighted most heavily. The formula
@ebraminio
ebraminio / upload.go
Last active March 22, 2023 06:01
golang upload client and server
// curl -X POST -H "Content-Type: application/octet-stream" --data-binary '@filename' http://127.0.0.1:5050/upload
package main
import (
"fmt"
"io"
"net/http"
"os"
"time"