Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jim3ma's full-sized avatar
🎯
Focusing

Jim Ma jim3ma

🎯
Focusing
View GitHub Profile
@jim3ma
jim3ma / LICENSE
Created September 13, 2023 09:38 — forked from shaneutt/LICENSE
Golang: Demonstrate creating a CA Certificate, and Creating and Signing Certs with the CA
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@jim3ma
jim3ma / aes_cbc_pkcs5.go
Created August 19, 2023 11:21 — forked from hothero/aes_cbc_pkcs5.go
AES/CBC/PKCS5Padding implementation by Golang (can work with JAVA, C#, etc.)
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"fmt"
)
@jim3ma
jim3ma / ioctlsnoop.bt
Last active December 19, 2022 05:57
ioctl bpftrace script
#!/usr/bin/env bpftrace
/*
* ioctlsnoop Trace ioctl() syscalls.
* For Linux, uses bpftrace and eBPF.
*
* USAGE: ioctlsnoop.bt
*
* Copyright 2022 Jim Ma.
* Licensed under the Apache License, Version 2.0 (the "License")
*

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocal you use. And there're two common protocals: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocal. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
@jim3ma
jim3ma / retry.sh
Created November 15, 2021 06:52 — forked from felipou/retry.sh
Retry command
#!/bin/bash
#
# Created by Felipe Machado - 2016/02/14
#
# A retry command for bash
# Retries the given command up to MAX_RETRIES, with an interval of SLEEP_TIME
# between each retry. Just put it on your bash_profile and be happy :)
# Usage:
# retry [-s SLEEP_TIME] [-m MAX_RETRIES] COMMAND_WITH_ARGUMENTS
#
@jim3ma
jim3ma / mount-ram.sh
Created September 24, 2020 12:56 — forked from koshigoe/mount-ram.sh
Like tmpfs in Mac OSX
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
@jim3ma
jim3ma / gist:3d0ec24c2ecc00db62612596f8ccd6a4
Created July 31, 2019 03:57 — forked from anonymous/gist:5543343
Golang major minor device numbers
package main
import (
"flag"
"fmt"
"syscall"
// #include <sys/sysmacros.h>
"C"
)
@jim3ma
jim3ma / recvfd.c
Created August 22, 2018 14:53
Send a file descriptor over an abstract unix domain socket
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <strings.h>
#include <errno.h>
#define NAME ".socket"
@jim3ma
jim3ma / recvfd.c
Last active August 21, 2018 06:26 — forked from kokjo/sendfd.c
Send a file descriptor over an abstract unix domain socket
// compile with: gcc -static -o recvfd recvfd.c
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <strings.h>
/**
* Receives file descriptor using given socket
*
* @param socket to be used for fd recepion
@jim3ma
jim3ma / blog-webpack-2.md
Created January 16, 2018 12:35 — forked from xjamundx/blog-webpack-2.md
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.