This file contains hidden or 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 tokenize(input: string) { | |
const regexes = { | |
KEYWORD: | |
/^(?:and|assert|as|break|class|continue|def|elif|else|false|for|if|import|in|is|lambda|null|not|or|pass|return|try|while|with)/, | |
IDENTIFIER: /^[a-zA-Z_][a-zA-Z_0-9]*/, | |
LITERAL: /^(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/, | |
SPECIALNUMBER: /^0[xXbB][0-9a-zA-Z_]+/, | |
NUMBER: /^-?[0-9][0-9_]*(\.[0-9_]+)?/, | |
COMMENT: /^#.+(?=\n)/, |
This file contains hidden or 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 2 only because they removed lambda argument unpacking in 3.0 | |
import math, sys | |
from functools import reduce | |
from itertools import izip_longest | |
# AOC Day 1 part 1 | |
print(len((lambda nums: [1 for x, y in zip(nums[:], nums[1:]) if y > x]) | |
([int(x) for x in open("input1.txt").read().split()]))) | |
# AOC Day 1 part 2 |
This file contains hidden or 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
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. |
This file contains hidden or 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
# https://github.com/uBlockOrigin/uAssets/pull/3517 | |
twitch-videoad.js application/javascript | |
(function() { | |
if ( /(^|\.)twitch\.tv$/.test(document.location.hostname) === false ) { return; } | |
var realFetch = window.fetch; | |
window.fetch = function(input, init) { | |
if ( arguments.length >= 2 && typeof input === 'string' && input.includes('/access_token') ) { | |
var url = new URL(arguments[0]); | |
url.searchParams.forEach(function(value, key) { | |
url.searchParams.delete(key); |
This file contains hidden or 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
#!/bin/bash | |
# forked from https://github.com/andreyvit/bulk-rename/blob/master/bulk-rename | |
usage() { | |
echo "Rename/move/copy files by editing in your editor" | |
echo | |
echo "Example - rename all md files" | |
echo " /path/to/bulk-rename *.md" | |
echo |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<link rel='stylesheet' href="styles.css"/> | |
</head> | |
<body> | |
<script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script> |
This file contains hidden or 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
let username = document.querySelector('meta[name="user-login"]').getAttribute('content'); | |
document.querySelectorAll('.js-issue-row').forEach(row => { | |
let userLink = row.querySelector('a[data-hovercard-url="/users/' + username + '/hovercard"]') | |
if (!userLink) return; | |
Object.assign(userLink.style, { | |
background: '#3940c3', | |
borderRadius: '5px', |
This file contains hidden or 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
import asyncio | |
from greenlet import greenlet | |
from dataclasses import dataclass | |
class Effect: | |
pass | |
def run_effect(eff): |
This file contains hidden or 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
import { useRef, useCallback, useEffect } from 'react'; | |
// A callback that always closes over the latest data but keeps the same | |
// identity and will not be called after component unmounts | |
const useStableCallback = callback => { | |
const callbackRef = useRef(); | |
const memoCallback = useCallback( | |
(...args) => callbackRef.current && callbackRef.current(...args), | |
[], |
This file contains hidden or 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 MyScreen({}) { | |
const [numSelected setNumSelected] = useState(false); | |
useHeaderTitle(numSelected > 0 ? `${numSelected} tasks selected` : 'Task selection'); | |
return ... | |
} |
NewerOlder