Skip to content

Instantly share code, notes, and snippets.

View stafot's full-sized avatar
🐧

Stavros Foteinopoulos stafot

🐧
View GitHub Profile
@dwmkerr
dwmkerr / gpr.sh
Last active October 22, 2023 12:10
A shell command to push and open a pull request. Tested on OSX/Ubuntu. No dependencies.
# This function pushes the current branch to 'origin'. If a web address is shown
# in the output, it opens it up. On GitHub, GitLab and BitBucket, this means it
# will open the pull request for you!
#
# This is also part of the 'dotfiles' configration at:
# github.com/effective-shell/dotfiles
# Push the current branch to origin, set upstream, open the PR page if possible.
# Inspired by: https://gist.github.com/tobiasbueschel/ba385f25432c6b75f63f31eb2edf77b5
# How to get the current branch: https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch
@bvaughn
bvaughn / index.md
Last active May 4, 2024 11:25
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

@dwmkerr
dwmkerr / k8s-patch.go
Last active September 19, 2023 11:42
Example showing how to patch Kubernetes resources in Golang. Companion to the article 'https://dwmkerr.com/patching-kubernetes-resources-in-golang/'.
// Example showing how to patch kubernetes resources.
// This is the companion to my article 'Patching Kubernetes Resources in Golang':
// https://dwmkerr.com/patching-kubernetes-resources-in-golang/
package main
import (
"encoding/json"
"fmt"
types "k8s.io/apimachinery/pkg/types"
@mhausenblas
mhausenblas / cli-fu.md
Created July 5, 2018 13:30
Michael's bash snippets
@pmoust
pmoust / root.sh
Last active March 20, 2018 08:50
dockah
docker run -it --rm --security-opt=seccomp:unconfined \
--security-opt=apparmor:unconfined \
--privileged --pid=host --userns=host \
debian:jessie@sha256:51cd80bb935b76fbbf49640750736abc63ab7084d5331e198326b20063e7f13c \
nsenter -t 1 -m -u -n -i -F /bin/sh
@iMilnb
iMilnb / README.md
Last active January 18, 2024 08:08
AWS Terraform configuration: Stream CloudWatch Logs to ElasticSearch

Rationale

This snippet is a sample showing how to implement CloudWatch Logs streaming to ElasticSearch using terraform. I wrote this gist because I didn't found a clear, end-to-end example on how to achieve this task. In particular, I understood the resource "aws_lambda_permission" "cloudwatch_allow" part by reading a couple of bug reports plus this stackoverflow post.

The js file is actually the Lambda function automatically created by AWS when creating this pipeline through the web console. I only added a endpoint variable handling so it is configurable from terraform.

@thisisshi
thisisshi / emojis.js
Last active April 8, 2019 07:39
Quick and Dirty Emoji Export from Slack
// Go to: https://<team>.slack.com/customize/emoji
// Open Developer Console
// Copy/Paste and Run this in the console:
var spans = document.getElementsByTagName('span');
var basharray = "( "
for (var i=0;i<spans.length;i++) {
var link = spans[i].getAttribute("data-original");
if(link != null){
basharray = basharray.concat(link, " ")
@xigang
xigang / sort_time.go
Created May 4, 2017 04:04
Sorting by time.Time in Golang
package main
import (
"fmt"
"sort"
"time"
)
type reviews_data struct {
review_id string
@alexsapran
alexsapran / aws.zsh
Last active October 12, 2018 05:02
AWS CLI bash wrapper dot file
_warning(){
echo -e "\e[31m${@}\e[0m"
}
_info(){
echo -e $@
}
_success(){
echo -e "\e[32m${@}\e[0m"
}
@skounis
skounis / cors-test.sh
Created February 12, 2016 13:38
Test CORS headers with curl
#!/bin/bash
curl -X GET -H "Origin: http://example.com" --verbose http://foo.com/bar
curl -X POST -H "Origin: http://example.com" --verbose http://foo.com/bar
curl -X PUT -H "Origin: http://example.com" --verbose http://foo.com/bar