This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Apply = function(){ | |
Function.apply.apply(arguments[0], [arguments[1], arguments[2]]); | |
} | |
var func = function(){ | |
console.log(this); | |
console.log(arguments); | |
} | |
Apply(func, window, [1,2,3]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toFunc(){ | |
try{ | |
var func = "temp=function("; | |
var args = this.match(/^\[(.+)\]/); | |
var body = this; | |
if(args){ | |
func += args[1]; | |
body = body.replace(/^\[(.+)\]/,""); | |
} | |
func += "){"+body+"}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <initializer_list> | |
class test{ | |
public: | |
test(std::initializer_list<int> list){ | |
for(auto it = list.begin();it != list.end();++it){ | |
sum += *it; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function startThread(thread_callback, args, result_callback){ | |
var script = new Blob(['onmessage = function(e){postMessage(('+thread_callback.toString()+').apply(null, e.data));}']); | |
var worker = new Worker(URL.createObjectURL(script)); | |
worker.onmessage = function(e){ | |
result_callback(e.data); | |
URL.revokeObjectURL(script); | |
} | |
worker.postMessage(args); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uint8array = new Uint8Array(arrayBuffer); //arrayBufferにはデータが入っているとする | |
var value = (uint8array[0] << 8) + uint8array[1]; | |
if(value & 0x8000){ | |
value = -((value - 1) ^ 0xffff); //2の補数計算 | |
} | |
alert(value); //valueに変換された値 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function download(url, name){ | |
var a = document.createElement('a'); | |
a.href = url; | |
a.setAttribute('download', name || 'noname'); | |
a.dispatchEvent(new CustomEvent('click')); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.target{ | |
width:/*ImageWidth*/; | |
height:/*ImageHeight*/; | |
background-image: url(Octcat.png); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input ng-model="hoge" type="text"> | |
<h1>{{hoge}}</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').on('dragover', function(e){ | |
e.stopPropagation(); | |
e.preventDefault(); | |
$('#overlay').fadeIn(300); | |
}); | |
$('body').on('dragleave', function(e){ | |
e.stopPropagation(); | |
e.preventDefault(); | |
$('#overlay').fadeOut(300); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app="myApp"> | |
<div ng-controller="testCtrl"> | |
{{hoge}} | |
</div> | |
</div> |
OlderNewer