Skip to content

Instantly share code, notes, and snippets.

let person = {name: 'John Smith'};
let tpl = `My name is ${person.name}.`;
console.log(tpl);
let x = 5;
let y =3;
let tpl2 = `${x} + ${y} = ${x+y}`;
console.log(tpl2);
// template literal本身不具重用性,除非自己包成函式
//Right One
item.attr("data-title", error);
item.attr("data-placement","bottom");
item.attr("data-toggle","toggle");
item.closest("div").addClass("has-error");
item.closest("div").addClass("has-feedback");
item.closest("div").find(".glyphicon-ok").remove();
item.after('<span class="glyphicon glyphicon-remove form-control-feedback"></span>');
item.tooltip('show');
@sj82516
sj82516 / form.jade
Last active January 18, 2016 00:09
NodeJs-form/Ajax/Handle request
form#formArticle(role="form")
div.form-group
label(for="createArticleTitle") Article Title
textarea.form-control(row="1" name="title")
label(for="createArticleBody") Article Body
textarea.form-control(row="6" name="description")
button(type="submit")
//使用jquery的serialize()-直接將form各個欄位值轉為POST/GET傳遞的格式
//Use Jquery serialize() function - turn the values of cloumns in form into POST/GET format
//*項目必須要有 name
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
var chartData = [];
for (var i = 0; i < 7; i++)
chartData.push(Math.random() * 50);
res.render('index', { title: 'Express', chartData: JSON.stringify(chartData) });
Doctype
html
head
meta(charset='utf-8')
title #{title}
script(src='/javascripts/Chart.min.js')
body
canvas#myChart
script(type="text/javascript").
var data = {
@sj82516
sj82516 / gist:7ec10ff907b9e1a3db82
Last active August 29, 2015 14:17
NCTU_Embedded system_Arduino_Lab02
//NCTU_Embedded system_Arduino_Lab02
//Read and compare sensor
//then display on 5*7 LED matrix
//show the "HelloWorld" and shift left or right by the comparison
//display like this project:http://musicdiver.com/wordpress/2013/01/arduino-scrolling-text-on-5x7-led/
int scan=0;
int matrix[7][50];
//transform letter to 5*7 LED matrixs
// Lab01
// LM35 + 4*7 segment Display
// 七段顯示器 reference: Cooper Maa
// define the LED digit patterns, from 0 - 9
// 1 = LED on, 0 = LED off, in this order:
// Arduino pin: 2,3,4,5,6,7,8 (Mapping a,b,c,d,e,f,g of Seven-Segment LED)
byte seven_seg_digits[10][7] = { { 1,1,1,1,1,1,0 }, // = 0
{ 0,1,1,0,0,0,0 }, // = 1
{ 1,1,0,1,1,0,1 }, // = 2
@sj82516
sj82516 / gist:63753da1808c839253eb
Last active August 29, 2015 14:07
Arduino_digitalPiano
//set up pin
const int buttonPin = 2;
const int hornPin = 3;
const int ohm=5;
//data
int music[5]={0,0,0,0,0};
int point=0;
int sensor=0;
boolean buttonState=LOW;
long lastDebounceTime = 0;
@sj82516
sj82516 / gist:9c8d0530e1407b62e1f6
Created September 14, 2014 00:04
Arduino_robotFaceDIY
#include <Servo.h>
#include <IRremote.h>
//IR
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
const unsigned long IRmove1 = 0XFF30CF;
const unsigned long IRmove2 = 0XFF18E7;
const unsigned long IRmove3 = 0XFF7A85;
@sj82516
sj82516 / gist:efd30e89d3056c7ecd40
Created August 20, 2014 07:02
Arduino_personal work_alarm_v1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <virtuabotixRTC.h>
//use interrupt 0 -> pin 2 (button0)
#define lock 0
//button1
#define add_sec 4
//button2
#define add_min 3