Skip to content

Instantly share code, notes, and snippets.

@cloudwu
cloudwu / sortnumber.c
Created August 1, 2023 05:38
sort telephone number
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#define N (100000063/64)
struct bitset {
uint64_t bits[N];
@goldengrape
goldengrape / learnmusic.py
Created December 9, 2018 20:43
learnmusic.py
#! python2
# NOTE: The first line in this script specifies that it should always be run using Python 2.7.
# The `midiutil` module is currently not available for Python 3.
'''Generates a MIDI file with 12 random notes in C major, using the midiutil module. The instrument is also picked randomly. The result is then played with the sound.MIDIPlayer class.
If nothing happens, make sure that your device isn't muted.
'''
from midiutil.MidiFile import MIDIFile
@goldengrape
goldengrape / Face_Recognition_tinker.py
Created November 20, 2017 06:05
通过并联神经网络改进deeplearning.ai中人脸识别作业
# coding: utf-8
# # 持续训练
#
# 问题提出: 如果人脸识别在使用中发现准确率并不够高, 是否可以继续改进? 如何在已有的基础之上继续改进?
#
# 解决方法: 建立并联的判别神经网络, 将A人脸的128位编码和待测人脸的128位编码作为输入, 二值判别输出
# * 路径A: 计算二阶范数距离, 并以原题目中的阈值作为分界, 形成输出
# * 路径B: 待训练神经网络, 早期时参数值都很小, 因此输出值也很小, 但可被训练.
library(tidyverse)
library(gganimate)
NUMPLAYERS = 45
ROUNDS = 5000
INITWEALTH = 45
#initialize the bank
#columns wealths of the NUMPLAYERS players
#rows show wealths of each of the ROUNDS ticks of the clocks
@diyism
diyism / install TOR with meek.txt
Last active July 30, 2022 18:42
install TOR with meek
#thanks to:
https://www.torproject.org/docs/debian
http://askubuntu.com/questions/501496/how-to-install-tor-with-meek-support
https://plus.google.com/+GhostAssassin/posts/26zCmDmjYXP
#In /etc/apt/sources.list:
deb http://deb.torproject.org/torproject.org trusty main
deb-src http://deb.torproject.org/torproject.org trusty main
#Run:
sudo apt-get update
@jgamblin
jgamblin / Top10SC.py
Last active December 19, 2016 22:11
List Top 10 Vuln System With Details
#!/usr/bin/env python3
from securitycenter import SecurityCenter5
import subprocess
def vulns():
sc = SecurityCenter5('nessus')
sc.login('nessusapi', 'Afinepassword!')
response = sc.get('status')
hosts = sc.analysis(tool='sumip', page=0, page_size=10, sortDir='desc',sortField='score')
@diyism
diyism / dns2https.php
Last active July 26, 2021 13:42
dns2https.php
<?php
/*
udp/tcp dns client for google dns over https (https://dns.google.com)
ubuntu上使用:
在/etc/rc.local里加/usr/bin/php /home/<your_name>/dns2https.php
执行:
systemctl disable unbound
systemctl disable dnscrypt-proxy
@terrywang
terrywang / config
Last active October 13, 2022 20:39
Secure Enhanced ~/.ssh/config OpenSSH client per-user configuration file
# User ssh configuration file ~/.ssh/config
# Gist https://gist.github.com/terrywang/3997931
# man ssh_config for more information
# Inspired by the blog post below to fight the NSA
# https://stribika.github.io/2015/01/04/secure-secure-shell.html
# Github needs diffie-hellman-group-exchange-sha1 some of the time but not always
# Host github.com
# KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
@developer88
developer88 / deploy.rb
Last active June 21, 2018 13:05
Deploy phpBB with Mina
require 'mina/bundler'
require 'mina/git'
set :application, "forum"
set :domain, '%SERVERNAME%'
set :deploy_to, "%PATH-TO-APPLICATION%"
set :repository, '%REPOSITORY-URL%.git'
set :branch, 'master'
set :login, "%LOGIN%"
@klzgrad
klzgrad / Naive-VPN.md
Created November 17, 2014 00:43
朴素VPN:一个纯内核级静态隧道

朴素VPN:一个纯内核级静态隧道

由于路由管控系统的建立,实时动态黑洞路由已成为最有效的封锁手段,TCP连接重置和DNS污染成为次要手段,利用漏洞的穿墙方法已不再具有普遍意义。对此应对方法是多样化协议的VPN来抵抗识别。这里介绍一种太简单、有时很朴素的“穷人VPN”。

朴素VPN只需要一次内核配置(Linux内核),即可永久稳定运行,不需要任何用户态守护进程。所有流量转换和加密全部由内核完成,原生性能,开销几乎没有。静态配置,避免动态握手和参数协商产生指纹特征导致被识别。并且支持NAT,移动的内网用户可以使用此方法。支持广泛,基于L2TPv3标准,Linux内核3.2+都有支持,其他操作系统原则上也能支持。但有两个局限:需要root权限;一个隧道只支持一个用户。

朴素VPN利用UDP封装的静态L2TP隧道实现VPN,内核XFRM实现静态IPsec。实际上IP-in-IP隧道即可实现VPN,但是这种协议无法穿越NAT,因此必须利用UDP封装。内核3.18将支持Foo-over-UDP,在UDP里面直接封装IP,与静态的L2TP-over-UDP很类似。

创建一个朴素VPN