Skip to content

Instantly share code, notes, and snippets.

@casualuser
casualuser / awk_netstat.sh
Created September 22, 2020 09:22 — forked from staaldraad/awk_netstat.sh
AWK to get details from /proc/net/tcp and /proc/net/udp when netstat and lsof are not available
# Gawk version
# Remote
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($3,index($3,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($3,i,2))}{print x":"strtonum("0x"substr($3,index($3,":")+1,4))}'
# Local
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($2,i,2))}{print x":"strtonum("0x"substr($2,index($2,":")+1,4))}'
# No Gawk
# Local
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@casualuser
casualuser / django-runserver-ssl.md
Created March 12, 2020 08:38 — forked from claudiosanches/django-runserver-ssl.md
Django - SSL with runserver

Instalation

[sudo] apt-get install stunnel

Configuration

cd path/to/django/project
@casualuser
casualuser / recovery.sh
Created December 23, 2019 11:56 — forked from jonathantneal/recovery.sh
Create or update macOS Mojave Recovery Partition Without Reinstalling
#!/bin/sh
# Set the macOS installer path as a variable
MACOS_INSTALLER="/Applications/$(ls /Applications | grep "Install macOS")"
MOUNT_POINT="$MACOS_INSTALLER/Contents/SharedSupport"
echo "macOS installer is \"$MACOS_INSTALLER\""
# Set the target disk as a variable
TARGET=$(diskutil info "$(bless --info --getBoot)" | awk -F':' '/Volume Name/ { print $2 }' | sed -e 's/^[[:space:]]*//')
echo "Target disk is \"$TARGET\""
@casualuser
casualuser / index.html
Created September 25, 2019 22:55 — forked from stefanneculai/index.html
Froala Editor with Webpack 4
<!doctype html>
<html>
<head>
<title>Froala with Webpack</title>
</head>
<body>
<div id="editor"></div>

Why we dropped Lerna from PouchDB

We dropped Lerna from our monorepo architecture in PouchDB 6.0.0. I got a question about this from @reconbot, so I thought I'd explain our reasoning.

First off, I don't want this post to be read as "Lerna sucks, don't use Lerna." We started out using Lerna, but eventually outgrew it because we wrote our own custom thing. Lerna is still a great idea if you're getting started with monorepos (monorepi?).

Backstory:

"tiers": [{"eventId": 5275, "mappedSeats": 0, "name": "to1", "color": "#e6194b", "price": 35.0, "seats": 100, "id": 3040}, {"eventId": 5275, "mappedSeats": 0, "name": "to2", "color": "#ffe119", "price": 25.0, "seats": 100, "id": 3041}, {"eventId": 5275, "mappedSeats": 0, "name": "to3", "color": "#f58231", "price": 15.0, "seats": 100, "id": 3042}, {"eventId": 5275, "mappedSeats": 0, "name": "ga", "color": "#911eb4", "price": 5.0, "seats": 100, "id": 3043}], "name": "test event", "eventBrief": {"date_time": "08:00PM", "title": "test event", "poster": "http://eventcartel.com/cache/31/1e/311eb76027aa06f057dad6ce2a8f7161.jpg", "eventUrl": "/events/test-event-None-tickets-5275/", "place": "5 Village Lodge Rd, Stratton Mountain, VT", "date_day": "Fri 10/19"}, "seatmapId": 61, "ga": {"tierId": 3040, "quantity": {"max_qty": 10, "current_qty": 0, "step": 1}, "unsoldSeats": 100, "name": "ga", "height": 1000, "width": 1000, "x": 4581, "y": 2520, "rotate": 0, "zoneId": "ga"}
@casualuser
casualuser / AWS_Single_LetsEncrypt.yaml
Created September 24, 2018 21:42 — forked from tony-gutierrez/AWS_Single_LetsEncrypt.yaml
AWS Elastic Beanstalk .ebextensions config for single instance free SSL using letsencrypt certbot and nginx. http://bluefletch.com/blog/domain-agnostic-letsencrypt-ssl-config-for-elastic-beanstalk-single-instances/
# Dont forget to set the env variable "certdomain", and either fill in your email below or use an env variable for that too.
# Also note that this config is using the LetsEncrypt staging server, remove the flag when ready!
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
@casualuser
casualuser / angularjs-providers-explained.md
Created August 2, 2018 08:11 — forked from demisx/angularjs-providers-explained.md
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

@casualuser
casualuser / gist:6f2493553f7165c826a6cb15e04e3e6f
Created June 23, 2018 11:43 — forked from lfender6445/gist:6226290
restrict googleplaces by United States so it only returns zipcodes and states
// Application Javascript - see https://github.com/lfender6445/google_places for full example
var autocomplete, input, address = {};
$(document).ready(function(){
input = $("#searchBox");
$("#searchBox").clearOnFocus();
$('form').submit(function(){ return false; });
});
var init = function(){