Skip to content

Instantly share code, notes, and snippets.

//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');
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本身不具重用性,除非自己包成函式
@sj82516
sj82516 / 12-IntegertoRoman.js
Last active November 13, 2016 06:22
LeetCode
/**
* @param {number} num
* @return {string}
*/
var intToRoman = function(num) {
var romanNums = ['I','V','X','L','C','D','M'];
var ans = "";
var nums = [];
for(var v=(num%10); num>0; i++,v=(num%10)){
nums.push(v);
<html lang="en">
<head>
<meta charset="UTF-8">
<title>WebRTC Offer</title>
<script src="https://webrtc.github.io/adapter/adapter-latest.js" type="application/javascript"></script>
<script src="/socket.io/socket.io.js" type="application/javascript"></script>
</head>
<body>
<h1> Self View </h1>
<video id="selfView" width="320" height="240" autoplay muted></video>
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import tensorflow as tf
import matplotlib
matplotlib.use('TKAgg')
from matplotlib import pyplot as plt
import numpy as np
import tensorflow as tf
from matplotlib import pyplot as plt
# 產生100筆資料 , 此為簡單的線性關係 (加點noise)
x_data = np.linspace(-10.0, 10.0, num=100)
y_data = 3.21 * x_data + 2 + np.random.uniform(-10.0,10.0,100)
# 產生tf的graph
const jwt = require('jsonwebtoken');
// 剛才下載的檔案
const googleServerKey = require("./test-f9099.json")
const token = jwt.sign({
"iss": googleServerKey.client_email,
scope,
"aud": "https://www.googleapis.com/oauth2/v4/token",
"exp": Math.floor(Date.now() / 1000) + (60 * 60),
"iat": Math.floor(Date.now() / 1000)
}, googleServerKey.private_key, {
return axios.post(
encodeURI(
`https://sheets.googleapis.com/v4/spreadsheets/${local.spreadsheet_id}:batchUpdate`
), {
"requests": [{
"insertRange": {
"range": {
"sheetId": local.sheet,
"startRowIndex": 3,
"endRowIndex": 4
// hello / world 依序執行
async function hello(){ await new Promise((res)=> setTimeout(()=>{console.log("hello"); res();}, 2000) ) }
async function world(){ await new Promise((res)=> setTimeout(()=>{console.log("world"); res();}, 2000) ) }
console.log("start")
await hello()
await world()
console.log("end")
// hello / world 同時執行
// 代表非同步操作
let timePromise = (time)=>{return new Promise(res => setTimeout(()=> res(), time))}
let taskA = timePromise(1000)
await taskA
console.log("TaskA done")
// 此處B,C會並行
let taskB = timePromise(2000)
let taskC = timePromise(500)
await taskB