Skip to content

Instantly share code, notes, and snippets.

View AndySze's full-sized avatar
🥇
Working hard

Andy Si AndySze

🥇
Working hard
  • Earth
View GitHub Profile
@AndySze
AndySze / .block
Created December 30, 2017 04:42 — forked from mbostock/.block
Epicyclic Gearing
license: gpl-3.0
@AndySze
AndySze / kin.js
Created September 26, 2016 21:13 — forked from kastner/kin.js
forward and reverse kinematics for a linear delta bot
DELTA_DIAGONAL_ROD = 288.5
// Horizontal offset from middle of printer to smooth rod center.
DELTA_SMOOTH_ROD_OFFSET = 206.0 // mm
// Horizontal offset of the universal joints on the end effector.
// DELTA_EFFECTOR_OFFSET = 32.0 // mm
DELTA_EFFECTOR_OFFSET = 32.0 // mm
// Horizontal offset of the universal joints on the carriages.
@AndySze
AndySze / dwt_timer.h
Created September 6, 2016 05:33 — forked from RickKimball/dwt_timer.h
delay_cycles via DWT cortex-m3 registers
/*
* dwt_timer.h
*
* Created on: Jun 15, 2015
* Author: kimballr
*/
#ifndef DWT_TIMER_H_
#define DWT_TIMER_H_
#!/usr/bin/env python
import sys
import math
import json
steps = 6
if len(sys.argv) > 1:
steps = int(sys.argv[1])
radius = 80.0
/*
* ChibiOS/RT - Copyright (C) 2013 Alan Barr
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
//
// This server will start a bash shell and expose it
// over socket.io to a browser. See ./term.html for the
// client side.
//
// You should probably:
//
// npm install socket.io
// curl -O https://github.com/LearnBoost/Socket.IO/raw/master/socket.io.min.js
//
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh

Routes

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

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

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

# routes.rb
# install and make run basic bootstrap date-picker functionality described here http://www.eyecon.ro/bootstrap-datepicker/
# app/assets/javascript/datepicker.js.coffee
$(document).on 'pageChanged', ->
# datepicker for simple_form & Ransack
$(".custom_datepicker_selector").datepicker().on 'changeDate', (en) ->
correct_format = en.date.getFullYear() + '-' + ('0' + (en.date.getMonth() + 1)).slice(-2) + '-' + ('0' + en.date.getDate()).slice(-2) # date format yyyy-mm-dd
$(this).parent().find("input[type=hidden]").val(correct_format)
#!/usr/bin/env bash
ssh linode 'cd local_clone; cd happynewsdb; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot authlove_development>authlove_development.sql; \
git commit -a -m"i"; \
git push;\
cd ../happyecdb/ ; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot ec_development>ec_development.sql; \
git commit -a -m"i"; \
git push;\