Skip to content

Instantly share code, notes, and snippets.

@lenew
lenew / install-redis.sh
Created March 22, 2016 06:24 — forked from FUT/install-redis.sh
Install Redis on EC2
1. Install Linux updates, set time zones, followed by GCC and Make
sudo yum -y update
sudo ln -sf /usr/share/zoneinfo/America/Indianapolis \
/etc/localtime
sudo yum -y install gcc make
2. Download, Untar and Make Redis 2.8 (check here http://redis.io/download)
package main
import (
"flag"
"fmt"
"github.com/miekg/dns"
"os"
)
var (
@lenew
lenew / dh.c
Created March 29, 2017 05:50 — forked from cloudwu/dh.c
Diffie-Hellman Key Exchange
// The biggest 64bit prime
#define P 0xffffffffffffffc5ull
#define G 5
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
// calc a * b % p , avoid 64bit overflow
@lenew
lenew / shadowsocks-http-proxy.go
Last active July 6, 2017 07:00
shadowsocks-go http proxy
//a simple go shadowsocks http proxy
package main
import (
"flag"
"fmt"
"log"
"net"
"net/http"
"os"
using Microsoft.IdentityModel.Tokens;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Text;
namespace JwtTest
{
class Program
{
static void Main(string[] args)
@lenew
lenew / Makefile
Created August 13, 2017 08:31
realtek r8168 driver module for OpenWRT or LEDE
#Download realtek r8168 linux driver from official site [http://www.realtek.com/downloads/downloadsView.aspx?PNid=13&PFid=5&Level=5&Conn=4&DownTypeID=3]
#Unpack source file
#Replace orginal Makefile with this file
#Put this source to 'package' folder of OpenWRT/LEDE SDK
#Build(make menuconfig, make defconfig, make)
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=r8168
*.cn
.163.com
.126.net
.csdn.net
.jd.com
.alicdn.com
.tanx.com
.mmstat.com
.360buy.com
.360buyimg.com
@lenew
lenew / CreateValidateJWT.cs
Created September 21, 2017 10:46 — forked from bschapendonk/CreateValidateJWT.cs
How to create and validate a JWT using System.IdentityModel.Tokens.Jwt
using System;
using System.IdentityModel.Tokens;
using System.Security.Claims;
using System.Security.Cryptography;
namespace CreateValidateJWT
{
class Program
{
static void Main(string[] args)
@lenew
lenew / tun-ping-linux.py
Created September 29, 2017 16:35 — forked from glacjay/tun-ping-linux.py
Reading/writing Linux's TUN/TAP device using Python.
import fcntl
import os
import struct
import subprocess
# Some constants used to ioctl the device file. I got them by a simple C
# program.
TUNSETIFF = 0x400454ca
TUNSETOWNER = TUNSETIFF + 2
//simple tool can forward a 'listen:port' to 'forward:port' though a 'socks5://server:port'
//usage socks5-forward listen:port forward:port socksurl
package main
import (
"io"
"log"
"net"
"os"
"net/url"