Skip to content

Instantly share code, notes, and snippets.

@pingyen
pingyen / ptt.ask18.html
Last active October 5, 2024 02:48
PTT ask/over18 dialog
<script id="template-ask18" type="text/template">
<div class="bbs-screen bbs-content">
<div class="over18-notice">
<p>本網站已依網站內容分級規定處理</p>
<p>警告︰您即將進入之看板內容需滿十八歲方可瀏覽。</p>
<p>若您尚未年滿十八歲,請點選離開。若您已滿十八歲,亦不可將本區之內容派發、傳閱、出售、出租、交給或借予年齡未滿18歲的人士瀏覽,或將本網站內容向該人士出示、播放或放映。</p>
</div>
</div>
<div class="bbs-screen bbs-content center clear">
<div class="over18-button-container">
@pingyen
pingyen / ptt.ask18.js
Last active October 4, 2024 18:42
PTT ask/over18 set cookie in JS
document.querySelector('button[name="yes"]').addEventListener('click', e => {
e.preventDefault();
document.cookie = 'over18=1; path=/';
location = document.querySelector('input[name="from"]').value;
}, false);
document.querySelector('button[name="no"]').addEventListener('click', e => {
e.preventDefault();
location = '/';
}, false);
@pingyen
pingyen / ptt.over18.js
Created October 1, 2024 18:00
PTT over 18 cookie detection
(() => {
const set = new Set(['gossiping', 'sex']);
const pathname = location.pathname;
const tokens = pathname.split('/');
if (tokens.length < 3) {
return;
}
@pingyen
pingyen / fb-sharer-vexed.js
Last active October 31, 2023 05:03
P_Vexed Sharer
// ==UserScript==
// @name P_Vexed Sharer
// @namespace https://www.facebook.com/groups/p.vexed
// @version 0.1
// @description Facebook Sharer + P_Vexed
// @author You
// @match https://www.facebook.com/sharer/sharer.php*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@pingyen
pingyen / gtranslateLanguages.json
Created March 17, 2021 09:14
Google Translate Languages
{
"af": "Afrikaans",
"am": "Amharic",
"ar": "Arabic",
"az": "Azerbaijani",
"be": "Belarusian",
"bg": "Bulgarian",
"bn": "Bengali",
"bs": "Bosnian",
"ca": "Catalan",
@pingyen
pingyen / dedupLines.php
Created September 17, 2019 07:22
Remove duplicate lines in a file
<?php
$targets = array_slice($argv, 1);
foreach ($targets as $target) {
$map = array();
foreach (explode("\n", file_get_contents($target)) as $line) {
if (isset($map[$line]) === true) {
continue;
}
@pingyen
pingyen / jsonBeautifier.php
Last active September 24, 2019 16:06
Beautify JSON files
<?php
$path = call_user_func(function() {
global $argv;
return isset($argv[1]) === true ?
$argv[1] :
'.';
});
function findJSONFiles($path) {
@pingyen
pingyen / googleNewsLangRegionList.json
Created January 9, 2019 08:44
Google News Language & Region List
[
[
"CN:zh-Hans",
"中文 | 中国",
"CN",
"zh-Hans"
],
[
"TW:zh-Hant",
"中文 | 台灣",
@pingyen
pingyen / countries.csv
Created September 18, 2018 08:29
Country Name, 2-Letter, 3-Letter Code CSV
Afghanistan AF AFG
Aland Islands AX ALA
Albania AL ALB
Algeria DZ DZA
American Samoa AS ASM
Andorra AD AND
Angola AO AGO
Anguilla AI AIA
Antarctica AQ ATA
Antigua and Barbuda AG ATG
@pingyen
pingyen / wavHeader.html
Created March 8, 2018 08:38
1 Frame WAV Header
<!DOCTYPE>
<html>
<head>
<title>WAV Header</title>
<script>
var buildWaveHeader = function(opts) {
var numFrames = opts.numFrames,
numChannels = opts.numChannels || 2,
sampleRate = opts.sampleRate || 44100,
bytesPerSample = opts.bytesPerSample || 2,