Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ankit Goyal goyalankit

🏠
Working from home
View GitHub Profile
@m-radzikowski
m-radzikowski / script-template.sh
Last active Apr 12, 2021
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
View script-template.sh
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@dpino
dpino / ns-inet.sh
Last active Apr 6, 2021
Setup a network namespace with Internet access
View ns-inet.sh
#!/usr/bin/env bash
# set -x
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit 1
fi
# Returns all available interfaces, except "lo" and "veth*".
@cvan
cvan / HOWTO.md
Last active Feb 3, 2021
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default
View HOWTO.md

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you
@tevino
tevino / epoll.go
Last active Apr 7, 2021
An example of using epoll in Go
View epoll.go
package main
import (
"fmt"
"net"
"os"
"syscall"
)
const (
@nerdalert
nerdalert / Netfilter-IPTables-Diagrams.md
Last active Apr 3, 2021
Linux NetFilter, IP Tables and Conntrack Diagrams
View Netfilter-IPTables-Diagrams.md

Linux NetFilter, IP Tables and Conntrack Diagrams

IPTABLES TABLES and CHAINS

IPTables has the following 4 built-in tables.

1) Filter Table

Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.

@softwaredoug
softwaredoug / asyncio.md
Last active Jan 3, 2019
Python Asyncio Notes
View asyncio.md

This is a document full of notes of all the things that have hung me up getting into Python's new asyncio library. I mostly use it for tools that schlep data around between file systems, databases, and search engines for work. So lots of io. Usually I use gevent and python 2.7. But recently I've been trying to get more into asyncio and here I'm going to document all the things that I felt important to know or that tripped me up.

1. Thoroughly understand yield, and non asyncio coroutines

The first thing you need to do is write some coroutines without asyncio. This means understanding the yield keyword and how it can be used to create generators. Then next the protocol for sending/receiving from generator objects.

Recall generators are a special kind of iterator. When you specify a generator like so, you can use it in a for loop:

def generator()
    for i in range(0, 5):
@jpsim
jpsim / JAZMusician.h
Created Jul 7, 2014
SourceKit Playground
View JAZMusician.h
//
// JAZMusician.h
// JazzyApp
//
#import <Foundation/Foundation.h>
/**
JAZMusician models, you guessed it... Jazz Musicians!
From Ellington to Marsalis, this class has you covered.
@goyalankit
goyalankit / bash_to_zsh_history.rb
Last active Feb 24, 2021
Import bash history to zsh history.
View bash_to_zsh_history.rb
#################################################################
# = This script transfers bash history to zsh history
# = Change bash and zsh history files, if you don't use defaults
#
# = Usage: ruby bash_to_zsh_history.rb
#
# = Author: Ankit Goyal
#################################################################
# change if you don't use default values
@ncw
ncw / README.txt
Last active Mar 3, 2021 — forked from spikebike/client output
Client side certificates with go
View README.txt
This demonstrates how to make client side certificates with go
First generate the certificates with
./makecert.sh test@test.com
Run the server in one terminal
go run server.go
@ggPeti
ggPeti / spiral.rb
Last active Dec 26, 2015
Procedural Ruby solution for the Spiral task
View spiral.rb
def spiral(h, w, r, c)
spiral = []
step_counts = (1..Float::INFINITY).lazy.flat_map { |n| [n, n] }
directions = [:up, :left, :down, :right].cycle
while spiral.length < h * w
spiral << (r - 1) * w + c if r.between?(1, h) && c.between?(1, w)
if (current_step_count ||= 0).zero?