Skip to content

Instantly share code, notes, and snippets.

View montanaflynn's full-sized avatar

Montana Flynn montanaflynn

View GitHub Profile
// instrumentedWriter is a wrapper around gin.ResponseWriter that calls
// BeforeWriteHeaderCallback before response headers is written.
type instrumentedWriter struct {
gin.ResponseWriter
BeforeWriteHeaderCallback func()
}
func (w *instrumentedWriter) Write(data []byte) (int, error) {
w.runBeforeWriteHeaderCallbackOnce()
return w.ResponseWriter.Write(data)
@yig
yig / zoom-defang.sh
Last active September 11, 2023 11:54
Defang the macOS Zoom Installer. Extracts a .app that can be dragged to /Applications.
#!/bin/sh
## Author: Yotam Gingold
## License: CC0 (public domain) https://creativecommons.org/share-your-work/public-domain/cc0/
## URL: https://gist.github.com/yig/af5bbb054bb9c4de39abc9156e6863e1/
## Download the latest Zoom installer.
echo "==> Downloading the latest Zoom installer."
cd ~/Downloads
## Intel:
@colinjfw
colinjfw / kustomize-deploy.sh
Last active December 23, 2021 18:28
Kubernetes deployment strategy using Kustomize and a few basic tools. Replaces helm charts with simple tooling solutions.
# Kustomize based apply workflow. Requires jq, yq, kubectl, kustomize, mustache.
#
# Expected variables
# - namespace Namespace for all resources.
# - release A unique name to give to this collection of manifests.
# - revision Release revision.
# - images Image replacements.
# - variables Variable replacements.
#
# Example inputs:
@jakoblorz
jakoblorz / README.md
Created May 17, 2019 16:22
Simple global state without depending on any additonal state manager. Uses and exposes React Hooks.

I used this structure in multiple projects and had a blast using it which is why I want to share it. It automatically propagates state changes to all dependent states and does not require additional state managing packages such as redux or mobx.

It enables architectures where e.g. the navbar is at the same level as all other components while still receiving updates about e.g. current user: If in this example the Index View logs the user in, there will also be a re-render in the navbar as its state has changed. This construction removes the state-silos of each component. Using useState instead of useReflectedState still enables the usage of component-specific state.

import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter as Router, Route } from "react-router-dom";

import Navbar from "./views/Navbar";
import Index from "./views/Index";
@arkokoley
arkokoley / star.py
Created February 28, 2018 18:08
Auto star repo in github
'''
Author: Gaurav Koley (arkokoley@live.in)
'''
import requests
import sys
from requests.auth import HTTPBasicAuth
username = raw_input("username: ")
password = raw_input("password: ")
@kmonsoor
kmonsoor / getBrowser.js
Created January 18, 2017 10:25
Get Browser's name and it's version number ...
function getBrowser() {
var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName = navigator.appName;
var fullVersion = '' + parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion, 10);
var nameOffset, verOffset, ix;
// In Opera, the true version is after "Opera" or after "Version"
if ((verOffset = nAgt.indexOf("Opera")) != -1) {
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

When the manifest file of my project/the root project, call it A, contains a dep/constraint statement for another project, say X, that doesn't appear in A's import statements, there are three modes in which tools can interpret that:

  1. X must be present in the result (A's lock+vendor), and it must meet the version constraint.
    • (There's a variant where it works like this when it’s the root manifest giving the dep on X, but if it’s a non-root manifest, things work like 2)
  2. X needn't be present in the result, and even if it is, it needn't meet the constraint. (Basically, the constraint is cruft and we ignore it)
  3. X needn't necessarily be present in the result, but if it is (because some other dep actually does import X), then it must meet A's stated constraint.
    • (Again, there's a variant where it works like this for the root manifest, but like 2 for a non-root manifest.)

The first mode's biggest benefit is up-front intuitiveness for users. As we've discussed, it corresponds nicely to a get or add-

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

anonymous
anonymous / enter_info.html
Created March 16, 2016 02:21
anonymously share salary
<!DOCTYPE html>
<head>
<title>salary: submit info</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/base-min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
padding: 1em;
}