Skip to content

Instantly share code, notes, and snippets.

View fighterhit's full-sized avatar
💭
I may be slow to respond.

fighterhit

💭
I may be slow to respond.
View GitHub Profile
@jpetazzo
jpetazzo / README.md
Created December 3, 2013 19:58
Example of memory cgroup information

Let's start a container:

root@dockerhost:~# docker run -d -i ubuntu bash
0d62d8b0dc65998b0dc5b88d4e2bd331f560579199f05869088ac98266dac0b1

Now let's check the cgroup values:

@gesquive
gesquive / self-update-script.py
Last active November 3, 2024 09:35
Stick this in a python script to self update the script from an online source
def update(dl_url, force_update=False):
"""
Attempts to download the update url in order to find if an update is needed.
If an update is needed, the current script is backed up and the update is
saved in its place.
"""
import urllib
import re
from subprocess import call
def compare_versions(vA, vB):
@ungoldman
ungoldman / curl_post_json.md
Last active September 27, 2025 22:22
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@morhekil
morhekil / nginx.conf
Created August 14, 2014 12:18
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
@drmalex07
drmalex07 / getopt-example.sh
Last active May 3, 2025 11:08
A small example on Bash getopts. #bash #getopt #getopts
#!/bin/bash
#
# Example using getopt (vs builtin getopts) that can also handle long options.
# Another clean example can be found at:
# http://www.bahmanm.com/blogs/command-line-options-how-to-parse-in-bash-using-getopt
#
aflag=n
bflag=n
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@olih
olih / jq-cheetsheet.md
Last active December 5, 2025 21:17
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@ipbastola
ipbastola / jq to filter by value.md
Last active December 8, 2025 13:29
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@so0k
so0k / kubectl.md
Last active February 4, 2025 17:16
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@teknoraver
teknoraver / unixhttpc.go
Last active November 26, 2025 20:43
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"