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
/** | |
* Usage: | |
* let a = Option.of(someNullableValue); | |
* | |
* for (let value of a) { // access value safely only if it exists | |
* console.log('a not null/undefined value: ', value); | |
* } | |
* | |
*/ | |
class Option<T> { |
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
#[derive(Debug)] | |
pub struct Idx<T> { | |
idx: usize, | |
_ty: PhantomData<T> | |
} | |
impl<T> Clone for Idx<T> { | |
fn clone(&self) -> Self { | |
*self | |
} |
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
use rand::prelude::{SliceRandom, ThreadRng}; | |
use std::{ | |
fmt, | |
io::{stdin, stdout, Write}, | |
time::Duration, | |
}; | |
use strum::IntoEnumIterator; | |
use strum_macros::EnumIter; | |
pub fn blackjack() -> Result<(), Box<dyn std::error::Error>> { |
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
/** | |
* By using JS Proxy, we can emulate how Scala uses _ | |
* in function arguments, like: | |
* val names = people_list.map(_.name) | |
*/ | |
let _ = new Proxy({}, { | |
get(_target, prop, _receiver) { | |
return m => typeof m[prop] === 'function' | |
? m[prop]() |
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
target | |
.direnv | |
helix-term/rustfmt.toml | |
helix-syntax/languages/ | |
result | |
runtime/grammars/** | |
.github | |
.vscode | |
*.png | |
*.md |
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
public class Main { | |
public static void main(String[] args) { | |
try { | |
Parser.parse("yo"); | |
} catch (StringType s) { | |
System.out.println(s.value); | |
} catch (IntegerType i) { | |
System.out.println(i.asString()); | |
} catch (Type _t) { | |
System.out.println("unknown type"); |
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
# GitHubPrivateRepositoryDownloadStrategy downloads contents from GitHub | |
# Private Repository. To use it, add | |
# `using: GitHubPrivateRepositoryDownloadStrategy` to the URL section of | |
# your formula. This download strategy uses GitHub access tokens (in the | |
# environment variables `HOMEBREW_GITHUB_API_TOKEN`) to sign the request. This | |
# strategy is suitable for corporate use just like S3DownloadStrategy, because | |
# it lets you use a private GitHub repository for internal distribution. It | |
# works with public one, but in that case simply use CurlDownloadStrategy. | |
# | |
# Example Formula: |
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
type Query<T extends string, Prev extends string> = `${Prev}\n${T}`; | |
class QueryBuilder<T extends string, Prev extends string> { | |
constructor(private part: T, private prev: Prev) { } | |
with<NT extends string>(part: NT) { | |
return new QueryBuilder(part, this.get()); | |
} | |
get(): Query<T, Prev> { |
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
import Axios from 'axios'; | |
import { inject } from './container'; | |
export class Api { | |
constructor(baseURL) { | |
this._axios = Axios.create({ baseURL }); | |
this._baseURL = baseURL; | |
} | |
toString() { return this._baseURL; } | |
} |
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 Events { | |
static Container = class Container { | |
static get ContainerCreated() { return Events.Container + ':created' }; | |
static toString() { | |
return Events + ':container'; | |
} | |
} | |
static toString() { | |
return 'events'; |
NewerOlder