Skip to content

Instantly share code, notes, and snippets.

#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
const char month_name[12][10] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
size_t BUFSIZE = 10;
char* iso2eng(char* iso_str) {
char* result;
int num[3];
// ==UserScript==
// @name YouTube disable polymer
// @namespace https://zackguard.com/
// @version 0.0.1
// @description Disable Polymer on all YouTube pages
// @author Zack Guard
// @match https://www.youtube.com/*
// @run-at document-start
// @grant none
// ==/UserScript==
const flatten = list => {
if (!list.length) return [];
else {
const x = list[0];
if (Array.isArray(x)) return flatten([...x]).concat(flatten(list.slice(1)));
else return [x].concat(flatten(list.slice(1)));
}
};
const Z = 1.65; // z_a/2 (a = 0.95)
const Z2 = Math.pow(Z, 2);
const w = (p, n) => (p + Z2 / (2 * n) - Z * Math.sqrt((p * (1 - p) + Z2 / (4 * n)) / n)) / (1 + Z2 / n);
const isDarkMode = () => {
return window.matchMedia("(prefers-color-scheme: dark)").matches;
};
const onThemeChange = (function() {
let listeners = [];
let mm = window.matchMedia("(prefers-color-scheme: dark)");
mm.addEventListener("change", e => {
for (let listener of listeners) {
listener(e.matches);
/**
* Create an element with supplied attributes and contents and return it
* @param {string} tagName
* @param {Object} attributes
* @param {string} attributes._text
* @param {string} attributes._html
* @param {Object<string, string>} attributes.style
* @param {Node[]} attributes._children
* @param {string} attributes.*
* @returns {HTMLElement}
@z-------------
z------------- / telegram.css
Created October 1, 2019 16:34
Light custom style for Telegram Web. Wider messages list and enableable dark theme (`html.theme-dark`)
/* font */
body, body.non_osx {
font-family: "SF Pro Text", "Noto Sans CJK TC", sans-serif;
}
/* theming */
html {
--color-background: #ffffff;
[buildPlans.iosevka-custom]
family = "Iosevka Custom"
design = [
"ss09",
"cv01", "cv13", "cv24", "cv39", "cv44", "cv49",
"calt-center-ops", "calt-arrow", "calt-html-comment", "calt-trig", "calt-llgg", "calt-eqeq", "calt-ineq", "calt-plusplus", "calt-colons" # `calt' minus "exeq"
]
(defn is-prime? [n]
(reduce (fn [p x]
(if (== 0 (mod n x))
(reduced false)
p))
true
(range (int (/ n 2)) 1 -1)))
(println (take 100 (filter is-prime? (iterate inc 2))))
def min(nums)
min = nums[0]
min_i = 0
nums.each_with_index do |n, i|
if n < min
min = n
min_i = i
end
end
[min, min_i]