Skip to content

Instantly share code, notes, and snippets.

@tyage
tyage / default.9936e7f072.js
Created June 12, 2014 08:44
tweetdeck before xss fixed
This file has been truncated, but you can view the full file.
function ScribeTransport(e) {
this.SESSION_BUFFER_KEY = "ScribeTransport", this.SCRIBE_API_ENDPOINT = "/i/jot", this.options = {}, e && (this.updateOptions(e), this.registerEventHandlers(e))
}
function ClientEvent(e) {
this.scribeContext = {}, this.scribeData = {}, this.scribe = function (t, i) {
var n = e || window.scribeTransport;
if (!n) throw new Error("You must create a global scribeTransport variable or pass one into this constructor.");
if (!t || "object" != typeof t || i && "object" != typeof i) throw new Error("Invalid terms or data hash argument when calling ClientEvent.scribe().");
if (this.scribeContext) {
var a = {prime: 1};
var b = {nonprime: 2, prime: 3};
var c = {nonprime: 4, prime: 5, hoge: 6};
var d = Object.assign(a, b, c);
console.log(a);
console.log(b);
console.log(c);
console.log(d);
let cats = {
'@@iterator': function () {
let names = Object.keys(this), i = 0
return {
next: () => i < names.length ? { value: names[i++] } : { done: true }
}
},
a: 1,
b: 2,
c: 3,
var table = document.querySelectorAll('table')[0];
var links = Array.prototype.map.call(table.querySelectorAll('a'), function(a) {return a.href});
var timer = window.setInterval(function() {
document.body.innerHTML = "<img src='"+links[parseInt(Math.random()*links.length)]+"'>";
}, 10000);
create table 学生 (学生番号, 学生名, 都市, 年齢);
insert into 学生 values
('S1', '山田', '京都', 19),
('S2', '鈴木', '大阪', 20),
('S3', '小島', '奈良', 22),
('S4', '武田', '京都', 18),
('S5', '高木', '神戸', 21);
create table 科目 (科目番号, 科目名, 先生, 単位数);
insert into 科目 values
('J1', 'データベース', '田中', 4),
@tyage
tyage / gist:49ef207b35f7dc31532c
Last active August 29, 2015 14:04
画像を表示する
Array.prototype.forEach.call(document.getElementsByTagName('a'), function(i) {i.innerHTML = '<img src="'+i.href+'">'})
// executed by traceur 0.0.59
// basic
[this.a, b] = [1, 2]
console.log(this.a, b) // => 1 2
var {a, b: [c], d: d} = {a: 1, b: [2], d: 3}
console.log(a, c, d) // => 1 2 3
var [a, , {b: c}, d] = [1, 3, {b: 2}]
console.log(a, c, d) // => 1 2 undefined
// parameter
@tyage
tyage / string.js
Last active August 29, 2015 14:06
// String.raw
console.log(`foo\n`) // foo
console.log(String.raw`foo\n`) // foo\n
console.log(`foo\n`.length) // 4
console.log(String.raw`foo\n`.length) // 5
console.log(String.raw`foo${1+2}`) // foo3
console.log(`\x31`) // 1
console.log(String.raw`\x31`) // \x31
console.log(String.raw({ raw: ["a", "b", "c"] }, 0, 1, 2, 3)) // => a0b1c
// n秒経ったらresolve
var delay = function(second) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(second)
}, 1000 * second)
})
}
delay(2).then(function(n) {
console.log(n)
@tyage
tyage / gist:4d8146d768d9fda09777
Created October 17, 2014 04:39
github上でファイル内容のみ表示する
var file = $('.file').css({ margin: 0 })
$('body').empty()
file.appendTo('body')
$('.meta').remove()