Skip to content

Instantly share code, notes, and snippets.

#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/sys_domain.h>
#include <sys/kern_control.h>
#include <net/if_utun.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
@cute
cute / main.c
Created August 27, 2018 02:54 — forked from josephg/main.c
kqueue network & file example
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/event.h>
#include <netdb.h>
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
@cute
cute / PSPDFEnvironment.m
Created August 21, 2018 00:29 — forked from steipete/PSPDFEnvironment.m
Example for DISPATCH_SOURCE_TYPE_MEMORYPRESSURE (Mac only, since 10.9) ... Since we share code between iOS and mac, I'm trying to be a good system citizen and reimplement the equivalent of UIApplicationDidReceiveMemoryWarningNotification on the Mac.
NSString *const PSPDFApplicationDidReceiveMemoryWarningNotification = @"PSPDFApplicationDidReceiveMemoryWarningNotification";
// Test with sudo memory_pressure -l critical. Don't forget to re-set afterwards!
__attribute__((constructor)) static void PSPDFInstallLowMemoryNotificationWarningMac(void) {
static dispatch_source_t source;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN|DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
dispatch_source_set_event_handler(source, ^{
dispatch_source_memorypressure_flags_t pressureLevel = dispatch_source_get_data(source);
@cute
cute / music.js
Created August 20, 2018 06:33 — forked from kevincennis/music.js
simple, lightweight sequencer in javascript with the web audio api
// For more documentation and a newer version,
// check out the full repo: https://github.com/kevincennis/TinyMusic
@cute
cute / 0. remote.conf
Created August 7, 2018 05:07 — forked from clowwindy/0. remote.conf
SigmaVPN configure
[peername]
proto = nacltai
proto_publickey = LOCAL_PUBKEY
proto_privatekey = REMOTE_PRIKEY
local = tuntap
local_interface = tunnel
local_tunmode = 1
peer = udp
peer_localaddr = REMOTE_IP
peer_localport = 8000
{
"name": "libsodium",
"version": "1.0.16",
"license": "ISC license",
"homepage": "https://github.com/jedisct1/libsodium",
"authors": {
"Frank Dennis": "j@pureftpd.org"
},
"summary": "Sodium is a portable, cross-compilable, installable, packageable, API-compatible version of NaCl.",
"source": {
@cute
cute / test.js
Created December 29, 2017 07:55
alert(1)
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo $DIR

1:设置

sudo vi /etc/sysctl.conf
net.ipv4.ip_forward=1
sudo sysctl -p

2:安装

https://www.wireguard.com/install/
@cute
cute / QR-Code-Example
Created November 20, 2017 13:08 — forked from BPScott/QR-Code-Example
QR Code generation and instant preview from the command line
# Generating throwaway QR codes from the command line for shunting URLS to mobile devices
brew install qrencode
qrencode -o - http://www.google.com | open -f -a preview