Skip to content

Instantly share code, notes, and snippets.

View zjhiphop's full-sized avatar
🎯
Focusing

newboy zjhiphop

🎯
Focusing
  • cloud-tea
  • USA
View GitHub Profile
/* MongoDB-UserCollection-Data-Change_Send-Change-SocketIO.js */
'use strict'
module.exports = function (
app,
io,
User // Collection Name
) {
// SET WATCH ON COLLECTION
const changeStream = User.watch();
@zjhiphop
zjhiphop / main.py
Created March 13, 2019 06:22 — forked from littlecodersh/main.py
Main script behind itchat robot
#coding=utf8
import itchat
# tuling plugin can be get here:
# https://github.com/littlecodersh/EasierLife/tree/master/Plugins/Tuling
from tuling import get_response
@itchat.msg_register('Text')
def text_reply(msg):
if u'作者' in msg['Text'] or u'主人' in msg['Text']:
return u'你可以在这里了解他:https://github.com/littlecodersh'
@zjhiphop
zjhiphop / CDPATH.md
Created November 6, 2018 06:08 — forked from flackend/CDPATH.md
Instructions for setting up CDPATH completions on Mac.

CDPATH

Overview

This will allow you to include additional directories to what cd will look at for completions. From the bash man page:

The search path for the cd command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the cd command.

Usage

@zjhiphop
zjhiphop / public-stun-list.txt
Created July 24, 2018 09:57 — forked from mondain/public-stun-list.txt
Public STUN server list
23.21.150.121:3478
iphone-stun.strato-iphone.de:3478
numb.viagenie.ca:3478
s1.taraba.net:3478
s2.taraba.net:3478
stun.12connect.com:3478
stun.12voip.com:3478
stun.1und1.de:3478
stun.2talk.co.nz:3478
stun.2talk.com:3478
@zjhiphop
zjhiphop / the-scratch.conf
Created July 4, 2018 07:02 — forked from korczis/the-scratch.conf
Nginx Node.js Proxy with caching, websockets, gzip
proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
# the IP(s) on which your node server is running. I chose port 3000.
upstream app_the_scratch {
server 127.0.0.1:3000 weight=1 fail_timeout=60s;
}
# the nginx server instance
server {
@zjhiphop
zjhiphop / tcp-socketio-sample.js
Created September 18, 2017 07:09 — forked from maripiyoko/tcp-socketio-sample.js
Node.js Tcp server & Socket.io
// socket io
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
fs = require('fs');
app.listen(3000, function() {
console.log('Socket IO Server is listening on port 3000');
});
function handler(req, res) {
@zjhiphop
zjhiphop / RestServer.php
Created August 30, 2017 06:12 — forked from jasdeepkhalsa/RestServer.php
Simple PHP REST / JSON Server with example.php by Jake Sankey (http://jakesankey.com/blog/2012/09/php-simple-rest-server/)
<?php
class RestServer
{
public $serviceClass;
public function __construct($serviceClass)
{
$this->serviceClass = $serviceClass;
}
@zjhiphop
zjhiphop / gist:872ec0cd0ccaf6b5ac7d5bc880f8ab13
Created April 20, 2017 08:27 — forked from Faithree/gist:f8b84de4a300a6a42c2f4a1a46a08872
关于vue+node前后端分离,前端跨域的方案
昨天在做登陆请求的时候,脑子一抽,想试试原生的ajax来请求后台,这时候我就写下了下面的代码,
```
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) {
console.log(xhr.responseText)
} else {
//错误处理
@zjhiphop
zjhiphop / avoiding-exceptions.js
Created February 5, 2017 02:54 — forked from eiriklv/avoiding-exceptions.js
Exception free JavaScript?
/**
* WHY? - BECAUSE EXCEPTIONS/TRY/CATCH IS A GLOBAL HORRIBLE MESS :-(
* Check out error handling in golang: https://blog.golang.org/error-handling-and-go
*/
/**
* Wrap an "unsafe" promise
*/
function safePromise(promise) {
return promise
@zjhiphop
zjhiphop / nginx_config.md
Created November 7, 2016 10:17 — forked from Mioke/nginx_config.md
Mac OS下安装及配置nginx