Skip to content

Instantly share code, notes, and snippets.

View harrifeng's full-sized avatar

Harri Feng harrifeng

View GitHub Profile
@briangershon
briangershon / gist:fa9feb08e6a65d52bdc35c738d8cf104
Created January 8, 2017 07:57
Log Request Body for Debugging (golang)
buf, bodyErr := ioutil.ReadAll(r.Body)
if bodyErr != nil {
log.Print("bodyErr ", bodyErr.Error())
http.Error(w, bodyErr.Error(), http.StatusInternalServerError)
return
}
rdr1 := ioutil.NopCloser(bytes.NewBuffer(buf))
rdr2 := ioutil.NopCloser(bytes.NewBuffer(buf))
log.Printf("BODY: %q", rdr1)
@harrifeng
harrifeng / sqlite_select_show_title.sql
Created December 8, 2016 10:01
Show sqlite column when use select and align column
sqlite> .mode column
sqlite> .headers on
.mode column
.headers on
@harrifeng
harrifeng / rails_find_path_method.rb
Created November 10, 2016 03:55
Very important way to list all the path that already set in routes
Rails.application.routes.named_routes.helpers.select {|h| h.to_s =~ /some_search/ }
anonymous
anonymous / index.html
Created November 2, 2016 07:30
JS Bin redux study No.6 // source https://jsbin.com/dowupa
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="redux study No.6">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js">
</script>
</head>
anonymous
anonymous / index.html
Created November 2, 2016 07:19
JS Bin redux study No.6 // source https://jsbin.com/fapori
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="redux study No.6">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js">
</script>
</head>
@oelmekki
oelmekki / doc.md
Created December 30, 2015 19:37
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

摘译自 robots.thoughtbot.com

launchctl 命令加载,卸载开机自动运行的服务,在 OS X 中,服务本身存储在 .plist 文件中(即 property list),这些文件的位置一般在 ~/Library/LaunchAgents/Library/LaunchAgents。可以使用 launchctl load $PATH_TO_LISTunload them with launchctl unload $PATH_TO_LIST 命令来加载/卸载他们。加载就是允许这个程序开机执行,卸载反之。

如果你使用 Homebrew 安装过 mysql 那么下面的安装后提示你可能比较熟悉

To have launchd start mysql at login:
   ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
@tknerr
tknerr / README.md
Last active January 23, 2024 16:42
Vagrant with Ansible Provisioner on Windows

Vagrant with Ansible Provisioner on Windows

Long story short, ansible does not work on a Windows control machine, so you basically have to:

  • either run ansible --connection=local ... in the target vm
  • set up a separate control vm where ansible is installed via shell provisioner

Below are Vagrantfile examples for both approaches

Within the Target VM

@andreagrandi
andreagrandi / parse_json_post.go
Created August 19, 2014 13:28
Parse a JSON http POST in GoLang
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type test_struct struct {
Test string
@kevinhughes27
kevinhughes27 / Makefile
Created April 4, 2013 15:51
g++ Makefile for OpenCV Project
CC = g++
CFLAGS = -g -Wall
SRCS = HelloWorld.cpp
PROG = HelloWorld
OPENCV = `pkg-config opencv --cflags --libs`
LIBS = $(OPENCV)
$(PROG):$(SRCS)
$(CC) $(CFLAGS) -o $(PROG) $(SRCS) $(LIBS)