Skip to content

Instantly share code, notes, and snippets.

View tennessine's full-sized avatar
🐟
扫描二维码,加我为好友

爱吃猫粮的鱼 tennessine

🐟
扫描二维码,加我为好友
View GitHub Profile
var express = require('express');
var redis = require('redis');
const serverType = process.argv[2];
const serverHost = process.argv[3];
const serverPort = parseInt(process.argv[4]);
const redisPort = 6379;
const redisHost = '127.0.0.1';
var express = require('express');
var redis = require('redis');
const serverType = process.argv[2];
const serverHost = process.argv[3];
const serverPort = parseInt(process.argv[4]);
const redisPort = 6379;
const redisHost = '127.0.0.1';
@tennessine
tennessine / server.js
Created December 14, 2015 10:36 — forked from tagr/server.js
Node.js/Express: Add Expires header to /images and /stylesheets directories
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
#include <Servo.h>
Servo myservo;
const int servoPin = 9;
const int buttonPin = 12;
const int ledPin = 13;
void setup() {
myservo.attach(servoPin);
@tennessine
tennessine / haproxy.cfg
Created November 19, 2016 04:15
Here's a sample WORKING haproxy config for websockets / socketio. We were able to get socketio working on an Amazon ELB with just one node, but when we added multiple nodes, we saw weird client issues. So, we decided to use HAProxy on Ubuntu 12.04 and spent significant time trying to get just the right configuration (haproxy.cfg). Note though th…
global
#debug
#daemon
log 127.0.0.1 local0
defaults
log global
option httplog
frontend unsecured *:80
@tennessine
tennessine / highlight_query.sh
Created January 3, 2017 03:40 — forked from anonymous/highlight_query.sh
This is a script to reproduce a highlighting issue with the text_phrase_prefix query
#!/bin/sh
curl -XPOST 'http://localhost:9200/example_index/'
curl -XPOST 'http://localhost:9200/example_index/example_type/_mapping?pretty=true' -d \
'{
"example_type": {
"Properties": {
"name": {
"type": "string",
@tennessine
tennessine / on-jsx.markdown
Created February 20, 2017 04:41 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'

@tennessine
tennessine / Readme.md
Created March 23, 2017 03:34 — forked from mxstbr/Readme.md
Enable tab completion for JSX with Emmet in Atom

Enable tab completion for JSX with Emmet in Atom

This guide assumes you have the emmet and language-babel packages already installed in Atom

Gif of the tab completion working

  1. Open the keymap.cson file by clicking on Atom -> Keymap… in the menu bar
  2. Add these lines of code to your keymap:
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
@tennessine
tennessine / ID.js
Created March 7, 2018 05:50
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@tennessine
tennessine / 32.asm
Created November 15, 2018 10:48 — forked from FiloSottile/32.asm
NASM Hello World for x86 and x86_64 Intel Mac OS X (get yourself an updated nasm with brew)
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
global start
section .text
start:
push dword msg.len
push dword msg
push dword 1
mov eax, 4