Skip to content

Instantly share code, notes, and snippets.

View v2e4lisp's full-sized avatar

Yan Wenjun v2e4lisp

View GitHub Profile
@v2e4lisp
v2e4lisp / s3-file-upload.js
Created October 22, 2018 06:09 — forked from keithweaver/s3-file-upload.js
S3 File Upload to AWS S3
const AWS = require('aws-sdk');
const Busboy = require('busboy');
const BUCKET_NAME = '';
const IAM_USER_KEY = '';
const IAM_USER_SECRET = '';
function uploadToS3(file) {
let s3bucket = new AWS.S3({
accessKeyId: IAM_USER_KEY,

markdown to PDF

pandoc doc.md --pdf-engine=/Library/TeX/texbin/pdflatex -V geometry:margin=1in -s -o leveldb-doc.pdf
@v2e4lisp
v2e4lisp / nginx-tuning.md
Created March 25, 2018 08:05 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
def utf8cut(ba, l):
if len(ba) <= l:
return ba
pos = l
while (pos > 0):
b = ba[pos]
@v2e4lisp
v2e4lisp / _readme.md
Last active August 29, 2015 14:28 — forked from shime/_readme.md
installation script for tmux 1.9a

Having trouble installing the latest stable version of tmux?

I know, official package for your OS/distro is outdated and you just want the newest version of tmux.

Well, this script should save you some time with that.

Prerequisities

  • gcc
@v2e4lisp
v2e4lisp / hash.c
Last active August 29, 2015 14:26 — forked from tonious/hash.c
A quick hashtable implementation in c.
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
struct entry_s {
char *key;
char *value;
@v2e4lisp
v2e4lisp / install-tmux
Last active August 29, 2015 14:25 — forked from rothgar/install-tmux
# Install tmux on Centos release 6.5
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local

date structure

list

functions

  • head
  • tail
  • init
@v2e4lisp
v2e4lisp / mac-notify.el
Created January 22, 2015 16:31
Invoke mac notifier to display a message
(defun mac-notify (&optional content title)
"Invoke mac notifier to display a message
using terminal-notifier(https://github.com/alloy/terminal-notifier)
brew install terminal-notifier "
(let ((title (or title "Emacs"))
(content (or content "No Content")))
(call-process-shell-command
(format "terminal-notifier -title '%s' -message '%s'"
title
;; copy to clipboard from emacs in terminal
;;
;; if you use emacs in tmux you should enable pbcopy in tmux first
;; http://superuser.com/questions/231130/unable-to-use-pbcopy-while-in-tmux-session
;;
;; (require 'region-bindings-mode)
(defun pbcopy-region (start end)
(interactive "r")
(pbcopy (buffer-substring start end))