Skip to content

Instantly share code, notes, and snippets.

View fanyer's full-sized avatar

Fy fanyer

  • Somewhere on Earth
View GitHub Profile
@fanyer
fanyer / EventSystem.js
Created July 26, 2018 09:10 — forked from simonberger/EventSystem.js
Global event system for React.js
class EventSystem {
constructor() {
this.queue = {};
}
publish(event, data) {
let queue = this.queue[event];
if (typeof queue === 'undefined') {
return false;
@fanyer
fanyer / eslint-pushed-changes.sh
Created July 20, 2018 08:12 — forked from stalniy/eslint-pushed-changes.sh
ESLINT + pre-receive git hook
#!/bin/bash
TEMPDIR=`mktemp -d`
ESLINTRC=$TEMPDIR/.eslintrc
COMMAND="eslint --color -c $ESLINTRC --rule 'import/no-unresolved: 0' --rule 'import/no-duplicates: 0' --rule 'import/export: 0'"
git show HEAD:.eslintrc > $ESLINTRC
echo "### Ensure changes follow our code style... ####"
# See https://www.kernel.org/pub/software/scm/git/docs/githooks.html#pre-receive
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/shm.h>
@fanyer
fanyer / tmux.conf
Created June 21, 2018 08:45 — forked from yilenpan/tmux.conf
tmux
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# prefix key to backtick (`)
# unbind C-b
# set-option -g prefix `
# So we can still use ` when needed (prefix + )
'use strict'
const assert = require('assert')
const url = require('url')
const http = require('http')
const https = require('https')
const TIMEOUT_IN_MILLISECONDS = 30 * 1000
const NS_PER_SEC = 1e9
const MS_PER_NS = 1e6
@fanyer
fanyer / multiple_ssh_setting.md
Created February 3, 2018 18:58 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@fanyer
fanyer / listen1_aha_playlist.md
Last active February 20, 2018 06:35
updated by Listen1(http://listen1.github.io/listen1/) at 20/02/2018, 14:35:36

本歌单由Listen1创建, 歌曲数:52,歌单数:2,点击查看更多

@fanyer
fanyer / shadow-dom.md
Created December 11, 2017 17:51 — forked from praveenpuglia/shadow-dom.md
Everything you need to know about Shadow DOM

Shadow DOM

Heads Up! It's all about the V1 Spec.

In a nutshell, Shadow DOM enables local scoping for HTML & CSS.

Shadow DOM fixes CSS and DOM. It introduces scoped styles to the web platform. Without tools or naming conventions, you can bundle CSS with markup, hide implementation details, and author self-contained components in vanilla JavaScript. - https://developers.google.com/web/fundamentals/getting-started/primers/shadowdom

It's like it's own little world which hardly affects or gets affected by the outside world.

@fanyer
fanyer / ssl.md
Created December 10, 2017 07:51 — forked from clowwindy/ssl.md
为什么不应该用 SSL 翻墙

SSL 设计目标:

  1. 防内容篡改
  2. 防冒充服务器身份
  3. 加密通信内容

而翻墙的目标:

  1. 不被检测出客户端在访问什么网站
  2. 不被检测出服务器在提供翻墙服务

测试平台:DigitalOcean VPS ubuntu14.04 x64, strongswan5.2.2

运行以下命令请使用root权限

一:安装strongswan

由于ubuntu软件仓库中strongswan版本较低,因此从官网源码编译安装

apt-get install build-essential     #编译环境
aptitude install libgmp10 libgmp3-dev libssl-dev pkg-config libpcsclite-dev libpam0g-dev     #编译所需要的软件