Skip to content

Instantly share code, notes, and snippets.

View ZPVIP's full-sized avatar

Peng Zhang ZPVIP

  • Boise, ID, USA
  • 07:46 (UTC -06:00)
View GitHub Profile
@ZPVIP
ZPVIP / marching_squares.rb
Created September 6, 2019 17:38 — forked from mieko/marching_squares.rb
Marching Squares in Ruby (with Inline C implementation)
class MarchingSquares
STATE = { "0000" => :r, "1100" => :r, "0011" => :l, "1110" => :r,
"0100" => :r, "1000" => :u, "1011" => :u, "1001" => :u,
"0101" => :d, "1010" => :u, "0111" => :l, "0110" => :l,
"0001" => :d, "0010" => :l, "1101" => :d, "1111" => :r }
def self.find_shape(grid, w, h)
edge_pos = grid.index('1')
return nil if edge_pos.nil?
@ZPVIP
ZPVIP / marching_squares.cc
Created September 6, 2019 17:38 — forked from mieko/marching_squares.cc
Marching Squares in C++
#include "marching-squares.hh"
#include "point.hh"
#include "polygon.hh"
#include "douglas-peucker.hh"
#include <ps/canvas/canvas.hh>
#include <cstring>
#include <vector>
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep mongo
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl remove homebrew.mxcl.mongodb
pkill -f mongod
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
# Update, upgrade and install development tools:
apt-get update
#apt-get -y upgrade
apt-get -y install git-core autoconf bison build-essential libssl-dev libyaml-dev libreadline6 libreadline6-dev zlib1g zlib1g-dev
PREFIX="/usr/local"
RBENV_PREFIX="$PREFIX/rbenv"
BIN_PATH="$PREFIX/bin"
RBENV_GROUP="rbenv"

Bash Shell启动方式与rc脚本

Shell的不同分类

根据启动Bash Shell的方式不同,对Shell有两种分类方式

登录Shell与非登录Shell

根据Shell的启动方式不同,可以将Shell分为

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb