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 "v8/libplatform/libplatform.h" | |
#include "v8/v8.h" | |
#include <iostream> | |
#pragma comment(lib, "v8_monolith") | |
int main() { | |
auto platform = v8::platform::NewDefaultPlatform(); | |
v8::V8::InitializePlatform(platform.get()); | |
v8::V8::Initialize(); |
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
// Only applied for "image-based timed text" (i.e. SVG-based, like Chinese, Japanese, ...) | |
// For DFXP-based subtitles (e.g., English), try the hidden settings: https://www.netflix.com/SubtitlePreferences | |
(() => { | |
const installScaler = () => { | |
const subRectElem = document.querySelector('rect.image-based-subtitles-rect'); | |
if (subRectElem) { | |
const subWrapperElem = subRectElem.parentNode; | |
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver; | |
const config = {attributes: true, childList: true, characterData: true, }; |
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
#!/usr/bin/env python3 | |
import math | |
# >> Discrete Fourier transform for sampled signals | |
# x [in]: sampled signals, a list of magnitudes (real numbers) | |
# yr [out]: real parts of the sinusoids | |
# yi [out]: imaginary parts of the sinusoids | |
def dft(x): | |
N, yr, yi = len(x), [], [] |
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 <boost\lockfree\queue.hpp> | |
#include <iostream> | |
#include <thread> | |
#include <atomic> | |
#include <vector> | |
#include <memory> | |
#include <condition_variable> | |
#include <functional> | |
template<typename ItemType, unsigned long ulQueueCapacity> |
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
/* | |
* c99-heap.c | |
* - Description: Simple std::priority_queue-like container implemented in C99, without error handling and thread-safety | |
* - Author: Shao-Chung Chen | |
* - License: CC0 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdbool.h> |
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
/* | |
* c99-vector.c | |
* - Description: Simple std::vector-like container implemented in C99, without error handling and thread-safety | |
* - Author: Shao-Chung Chen | |
* - License: CC0 | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> |
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
/* | |
* Pack below script via http://jscompress.com/ to generate bookmarklet | |
*/ | |
(function(rootNode, fontFamily) { | |
var hasChildTextNode = function(parentNode) { | |
return [].some.call(parentNode.childNodes, function(node) { | |
if (node.nodeType == Node.TEXT_NODE) { | |
console.log(node.nodeValue); | |
} | |
return node.nodeType == Node.TEXT_NODE; |
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 <vector> | |
int main(int n) { | |
static int(*f[])(int) = {main, [](int)->int{exit(0);}}; | |
std::cout << n << std::endl; | |
return f[n/1000](n+1); | |
} |
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
// Python-like template string in ECMAScript 6 "tagged template" | |
// inspired from http://stackoverflow.com/a/22619256 | |
function formatter(literals, ...substitutions) { | |
return { | |
format: function() { | |
let out = [], i = 0, k = 0; | |
for (i,k; i < literals.length; i++) { | |
out[k++] = literals[i]; | |
out[k++] = Number.isInteger(substitutions[i]) ? | |
arguments[substitutions[i]] : |
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
/*rainbowEverything=*/(function(window) { | |
var parseRgbColorStrToHsl = function(rgbColorStr) { | |
// input: "rgb(12, 34, 56)"; | |
var rgbValues = rgbColorStr.substring(4).replace(/\s/g, "").split(","), | |
r = parseFloat(rgbValues[0])/255, | |
g = parseFloat(rgbValues[1])/255, | |
b = parseFloat(rgbValues[2])/255; | |
var max = Math.max(r, g, b), min = Math.min(r, g, b); | |
var h = 0, s = 0, l = (max + min) / 2; | |
if (max == min) { |
NewerOlder