Skip to content

Instantly share code, notes, and snippets.

View yangsibai's full-sized avatar
🎯
Focusing

sibo yangsibai

🎯
Focusing
  • Chengdu
View GitHub Profile
@yangsibai
yangsibai / README.md
Created December 23, 2015 12:43 — forked from fuermosi777/README.md
React ScrollView Component

To use:

import ScrollView from 'ScrollView.jsx`;
...
render() {
    return (
    <ScrollView>
        {aListThatScrolls}
     </ScrollView>
    );
{
"Users": ["UserA","UserB"],
"Groups": ["GroupA"]
}
@yangsibai
yangsibai / image_helper.go
Last active August 23, 2023 07:17
Getting an Images Type and Size in Golang (or any other language)
// from: <http://openmymind.net/Getting-An-Images-Type-And-Size/>
func getFormat(file *os.File) (string) {
bytes := make([]byte, 4)
n, _ := file.ReadAt(bytes, 0)
if n < 4 { return "" }
if bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 { return "png" }
if bytes[0] == 0xFF && bytes[1] == 0xD8 { return "jpg" }
if bytes[0] == 0x47 && bytes[1] == 0x49 && bytes[2] == 0x46 && bytes[3] == 0x38 { return "gif" }
if bytes[0] == 0x42 && bytes[1] == 0x4D { return "bmp" }
package main
import (
"bufio"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"fmt"
@yangsibai
yangsibai / auth.go
Created February 1, 2016 14:48 — forked from tristanwietsma/auth.go
Golang web server example
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
@yangsibai
yangsibai / GoMgoSample-1.go
Created February 2, 2016 01:19 — forked from ardan-bkennedy/GoMgoSample-1.go
Sample Go and MGO example
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {
@yangsibai
yangsibai / pre-push.sh
Created March 22, 2016 10:45 — forked from pixelhandler/pre-push.sh
Git pre-push hook to prevent force pushing master branch
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
@yangsibai
yangsibai / 1) Install
Created May 7, 2016 05:46 — forked from nghuuphuoc/1) Install
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@yangsibai
yangsibai / introrx.md
Created February 2, 2018 08:32 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: