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
<?php | |
return new class extends Sophie | |
{ | |
function mount() | |
{ | |
$this->author = fn() => new Author; | |
$this->date = fn() => new DateTime; | |
$this->body = fn() => random_text(); | |
$this->tags = fn() => [random_string(), random_string()]; |
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
LIST = "⠹⠼⠶⠧⠏⠛" | |
LIGHT = "⢕⡪" | |
SPEED = 1 | |
def loader(speed=SPEED, list=LIST) | |
list[(Time.now.to_f * 10 ** speed).to_i % list.length] | |
end | |
# Add this line to your loop | |
print "Loading... #{ loader(1, LIST) }\r" |
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
LIST = "⠹⠼⠶⠧⠏⠛" | |
LIGHT = "⢕⡪" | |
SPEED = 1 | |
trap "SIGINT" do | |
exit! | |
end | |
def loader(speed=SPEED, list=LIST) | |
list[(Time.now.to_f * 10 ** speed).to_i % list.length] |
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
def fancy_loader(current, total) | |
glyph = "⠹⠼⠶⠧⠏⠛"[(Time.now.to_f * 10).to_i % 6] | |
print "\r#{glyph} #{current}/#{total}" | |
end |
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
class SomeService | |
def call(some_value, bypass_some_method4 = false) | |
pipe( | |
some_value, | |
:some_method1, | |
:some_method2, | |
-> (value) { value * 2 }, | |
bypass_some_method4 ? :noop : :some_method4, | |
:some_method5 | |
) |
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
current_dir := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) | |
.PHONY=install | |
install: | |
ln -sf $(current_dir)config ~/.test/config |
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
// Currently, the ESLint plugin used by Svelte is buggy and choke on files with Sass. | |
// This little implementation takes care of removing styling from Svelte components as | |
// as well as handle any type of files other than Svelte, with complete respect of rules | |
// from the base ESLint plugin (that is, `.eslintrc.cjs` rules are used). It has been | |
// thought to be simple to use and integrate. | |
// | |
// https://github.com/sveltejs/eslint-plugin-svelte3/issues/10 | |
// | |
// Usage example: | |
// |
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
// It converts simple XML structures to JS objects. The default value of a node is an | |
// empty string, as it should be (contrary to several libraries I tested). | |
const { DOMParser } = require('@xmldom/xmldom') | |
const loadChildNodesRecursive = node => { | |
const nodes = {} | |
Array.from(node.childNodes) | |
.filter(element => element.nodeType === element.ELEMENT_NODE) | |
.forEach(element => { |
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
<!doctype html> | |
<html> | |
<head> | |
<title>Event testing.</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha512-NhSC1YmyruXifcj/KFRWoC561YpHpc5Jtzgvbuzx5VozKpWvQ+4nXhPdFgmx8xqexRcpAglTj9sIBWINXa8x5w==" crossorigin="anonymous" /> | |
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"></script> | |
<style> | |
* { |
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
const busyCallbacks = new Set() | |
export async function busy(callback : () => any) : Promise<any> { | |
if (busyCallbacks.has(callback)) { | |
return | |
} | |
busyCallbacks.add(callback) | |
const value = await callback() | |
busyCallbacks.delete(callback) | |
return value |