Skip to content

Instantly share code, notes, and snippets.

View fanyer's full-sized avatar

Fy fanyer

  • Somewhere on Earth
View GitHub Profile
'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 / 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 + )
#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 / 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
@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;
let fs = require("fs");
let pako = require("pako");
let str = fs.readFileSync(
__dirname + "/903977b432af87d0cfb7766bbe038a8f76ca78"
);
function Uint8ToString(u8a) {
let CHUNK_SZ = 0x800000;
let c = [];
for (let i = 0; i < u8a.length; i += CHUNK_SZ) {
@fanyer
fanyer / sms.py
Created October 4, 2018 12:28 — forked from lihongjie0209/sms.py
from androidhelper import Android
from time import sleep
import json
import urllib2
d = Android()
url = "youserver/sms/notify"
while(True):
messages = d.smsGetMessages(False)
for i in messages.result:
from PIL import Image # 导入Pillow的Image模块
IMG = "/Users/fanyer/Downloads/b.png" # 需要处理掉的图片路径
filePath = "/Users/fanyer/test/b.txt" # 处理结果的保存路径
ascii_char = list("$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. ")
height = 45
width = 100
# 重点。将256灰度映射到70个字符上
// react-native/local-cli/server/util/attachWebsocketServer.js
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
@fanyer
fanyer / build.gradle
Created May 14, 2019 13:52 — forked from TurekBot/build.gradle
Gradle Shadow Example
group 'com.github.yourusername'
version '1.0-SNAPSHOT'
//These are dependencies that have to do with just the build. See: https://stackoverflow.com/a/23627293/5432315
buildscript {
repositories {
jcenter()
}
dependencies {
//This is necessary to use the gradle shadow plugin