Skip to content

Instantly share code, notes, and snippets.

@jim3ma
jim3ma / mount-ram.sh
Created Sep 24, 2020 — forked from koshigoe/mount-ram.sh
Like tmpfs in Mac OSX
View mount-ram.sh
#!/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 Jul 31, 2019 — forked from anonymous/gist:5543343
Golang major minor device numbers
View gist:3d0ec24c2ecc00db62612596f8ccd6a4
package main
import (
"flag"
"fmt"
"syscall"
// #include <sys/sysmacros.h>
"C"
)
@jim3ma
jim3ma / recvfd.c
Created Aug 22, 2018
Send a file descriptor over an abstract unix domain socket
View recvfd.c
#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 Aug 21, 2018 — forked from kokjo/sendfd.c
Send a file descriptor over an abstract unix domain socket
View recvfd.c
// 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 Jan 16, 2018 — forked from xjamundx/blog-webpack-2.md
From Require.js to Webpack - Part 2 (the how)
View blog-webpack-2.md

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.

View V2EX 每日签到.py
# coding: utf-8
# 更新于2017/10/02,python3测试通过
import re
import requests
# 领取 X 铜币
# 每日登录奖励已领取
base_headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.57 Safari/537.36 OPR/40.0.2308.15 (Edition beta)', 'Referer': 'https://www.v2ex.com/signin', 'Origin': 'https://www.v2ex.com'}
@jim3ma
jim3ma / trial.key
Created Aug 28, 2017 — forked from huqi/trial.key
Beyond Compare 4 license for Mac
View trial.key
Beyond Compare 4
Licensed to: ASIO Allsoftinone
Quantity: 1 user
Serial number: 1822-9597
License type: Pro Edition for Windows
--- BEGIN LICENSE KEY ---
H1bJTd2SauPv5Garuaq0Ig43uqq5NJOEw94wxdZTpU-pFB9GmyPk677gJ
vC1Ro6sbAvKR4pVwtxdCfuoZDb6hJ5bVQKqlfihJfSYZt-xVrVU27+0Ja
hFbqTmYskatMTgPyjvv99CF2Te8ec+Ys2SPxyZAF0YwOCNOWmsyqN5y9t
@jim3ma
jim3ma / redir-daemon.c
Last active Apr 24, 2017
A simple example daemon for netfilter/iptables REDIRECT based transparent proxies http://svn.clifford.at/tools/trunk/examples/redir-daemon.c
View redir-daemon.c
/*
* A simple example daemon for netfilter/iptables REDIRECT based
* transparent proxies
*
* Also a nice demo for simple tcp client/server apps.
*
* Copyright (C) 2008 RIEGL Research ForschungsGmbH
* Copyright (C) 2008 Clifford Wolf <clifford@clifford.at>
*
* This program is free software; you can redistribute it and/or modify
@jim3ma
jim3ma / background.sh
Created Mar 14, 2017 — forked from zaius/background.sh
How to redirect a running process output to a file and log out
View background.sh
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@jim3ma
jim3ma / http_proxy.go
Created Jan 25, 2017
Register Dialer Type for HTTP&HTTPS Proxy in golang
View http_proxy.go
package main
import (
"bufio"
"fmt"
"net"
"net/http"
"net/url"
"crypto/tls"