Skip to content

Instantly share code, notes, and snippets.

💭
🦀 ⌨️ ➡️ 🚀

Davy Duperron yamafaktory

💭
🦀 ⌨️ ➡️ 🚀
Block or report user

Report or block yamafaktory

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yamafaktory
yamafaktory / record-from-const-array.ts
Created Nov 21, 2019
🔍 Typecheck object properties from array elements in TypeScript
View record-from-const-array.ts
const MY_ARRAY = ['a', 'b', 'c'] as const
const objectWithKeysFromConstArrayElements: Record<
typeof MY_ARRAY[number],
string
> = { a: 'foo', b: 'bar', c: 'foobar' }
View after-success.sh
#!/usr/bin/env bash
# Clone the repository
REMOTE_URL="$(git config --get remote.origin.url)";
cd ${TRAVIS_BUILD_DIR}/.. && \
git clone ${REMOTE_URL} "${TRAVIS_REPO_SLUG}-bench" && \
cd "${TRAVIS_REPO_SLUG}-bench" && \
# Bench master
git checkout master && \
View .travis.yml
language: rust
rust:
- stable
- beta
- nightly
matrix:
allow_failures:
- rust: nightly
View benchmark.rs
use criterion::{criterion_group, criterion_main, Criterion};
fn minus_one_benchmark(c: &mut Criterion) {
c.bench_function("Bench the minus one function", |b| b.iter(|| minus_one(1)));
}
criterion_group!(benches, minus_one_benchmark);
criterion_main!(benches);
View Cargo.toml
[dev-dependencies]
criterion = "0.2"
[[bench]]
name = "benchmark"
harness = false
View gist:38c2f54b0b94faebfd790783150c3d1a
#![feature(test)]
extern crate test;
pub fn minus_one(number: i32) -> i32 {
number - 1
}
#[cfg(test)]
mod tests {
View gist:4dd74fa2d986043e6015fa29c7ca87b8
pub fn minus_one(number: i32) -> i32 {
number - 1
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_minus_one() {
assert_eq!(minus_one(1), 0);
View keybase.md

Keybase proof

I hereby claim:

  • I am yamafaktory on github.
  • I am yamafaktory (https://keybase.io/yamafaktory) on keybase.
  • I have a public key ASAauTPFciFl-MKAPCehIBUOdtuLTE_q6Ep9o1VB34b3QAo

To claim this, I am signing this object:

View gist:f97f1a82fd9c7e8ecbdd95d5ad57ea4b
const Guards = require('./')
const guards = new Guards()
const [
a,
b,
c,
d,
e,
f,
View Dummy angular sample for a web-mode issue
<div class="panel-body"
ng-if="resource.data.length > 7">
<div ng-include="helper.template('error')"></div>
<h2 class="category">{{topic.name[locale]}}</h2>
<div class="list-view">
<div class="card project"
ng-repeat="article in articles | orderBy:'l7dTitle'">
<a ng-href="{{helper.url('project/:topic/articles/:id', {topic: topic.key, id: article.id})}}"
ng-click="dialog()">
<h4>{{article.l7dTitle}}</h4>
You can’t perform that action at this time.