Skip to content

Instantly share code, notes, and snippets.

@dinh
dinh / torrent.py
Created January 28, 2023 10:19 — forked from hannes/torrent.py
Create and query a local search engine for PirateBay torrents
#!/usr/bin/env python3
import sqlite3 # yay SQLite!
import base64
import os
import sys
if sys.version_info<(3,6,0):
print("You need python 3.6 or later to run this script.")
exit(-1)
@dinh
dinh / Main.java
Created January 24, 2023 21:32 — forked from smac89/Main.java
Read a large json file, but do so lazily so as to not use too much memory. Thanks to Java 8 streams, this is quite possible
import com.google.common.io.Resources;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
@dinh
dinh / _no_code_page_.php
Created January 11, 2023 21:05 — forked from Dan-Q/_no_code_page_.php
Hacky PHP to produce a "blank" web page which somehow has content when viewed in Firefox. Sample page at https://danq.me/wp-content/no-code-webpage/, explanation at https://danq.me/nocode
<?php
// half-hearted CSS minification
$css = preg_replace(
array('/\s*(\w)\s*{\s*/','/\s*(\S*:)(\s*)([^;]*)(\s|\n)*;(\n|\s)*/','/\n/','/\s*}\s*/'),
array('$1{ ','$1$3;',"",'} '),
file_get_contents('linked.css')
);
// embed as a data: uri
$base64css = rtrim(strtr(base64_encode($css), '+/', '-_'), '=');
@dinh
dinh / index.html
Created January 8, 2023 21:28 — forked from StudioProgrammar/index.html
Voice Search with JavaScript (Web Speech API)
<div class="container">
<form action="https://www.google.com/search" method="get" target="_blank" id="search-form">
<input name="q" type="text" placeholder="Search Google..." autocomplete="off" autofocus>
<!-- <button type="button"><i class="fas fa-microphone"></i></button> -->
</form>
<p class="info"></p>
</div>
@dinh
dinh / index.html
Created January 8, 2023 21:23 — forked from praveenrambalu/index.html
Speech to Color Changer
<script src="main.js"></script>
<link rel="stylesheet" href="main.css">
<h1>Say Color:</h1>
<div class="color-cube">
<div class="circle outer">
<div class="circle inner"></div>
</div>
</div>
@dinh
dinh / greasestarter.user.js
Created December 21, 2022 22:01 — forked from bmcminn/greasestarter.user.js
JS: A simple boilerplate Grease/Tampermonkey script. This starter script aliases a custom jQuery instance on the page so you can start doing some fancy dom manipulation stuffs with absolutely no consequences.
// ==UserScript==
// @name SCRIPT_NAME_HERE
// @namespace NAMESPACE
// @version 0.1
// @description WIDGET_DESCRIPTION_HERE
// @match http*://*/*
// @include http*://*/*
// @copyright 2013+, YOURNAME
// ==/UserScript==
@dinh
dinh / userscript.js
Created December 21, 2022 21:59 — forked from dataserver/userscript.js
tampermonkey userscript boilerplate
// ==UserScript==
// @name userscript boilerplate
// @namespace userscriptnamespace
// @version 1
// @description Script description
// @author Author
// @match http://asdf.com/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-popup-overlay/2.1.1/jquery.popupoverlay.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery.serializeJSON/2.9.0/jquery.serializejson.min.js
@dinh
dinh / data-markdown.user.js
Created December 21, 2022 21:42 — forked from paulirish/data-markdown.user.js
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@dinh
dinh / include-callback.js
Created December 21, 2022 21:39 — forked from jr-codes/include-callback.js
include(): JavaScript function for dynamically including a CSS or JS file on a page
/**
* Includes the CSS or JS file into the head of the page.
*
* Examples:
* include('http://example.com/script.js')
* include('http://example.com/style.css')
* include('http://example.com/script.php', 'js')
* @param {string} url URL of the CSS or JS file
* @param {string} [type] 'css' or 'js' to specify the type of file.
* This parameter is optional, but it should be
@dinh
dinh / open-json.user.js
Created December 21, 2022 21:37 — forked from jr-codes/open-json.user.js
Userscript for opening JSON in the Chrome JSON Viewer extension
// ==UserScript==
// @name Open JSON
// @version 1.0.0
// @description Opens JSON in a json-viewer window
// @match http://*/*
// @match https://*/*
// ==/UserScript==
const exec = fn => {
const script = document.createElement('script');