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
#include <stdio.h> | |
typedef double (*MathOperation)(double, double); | |
double add(double a, double b) { | |
return a + b; | |
} | |
double subtract(double a, double b) { | |
return a - b; |
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
fn call_once<F: FnOnce(i32) -> i32>(f: F, x: i32) -> i32 { | |
f(x) | |
} | |
fn main() { | |
let outer = 10; | |
let add_outer = |x| x + outer; | |
let result = call_once(&add_outer, 66); |
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 std::fmt::Display; | |
enum Storage { | |
Number(u32), | |
Text(String), | |
} | |
struct Data { | |
storage: Storage |
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
// ----- | |
struct Wrapper<A: Copy> { | |
value: A | |
} | |
impl<A: Copy> Wrapper<A> { | |
fn new(value: A) -> 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
extern crate alloc; | |
use alloc::boxed::Box; | |
struct Profunctor<'a,A,B> { | |
f: Box<dyn FnMut(A) -> B + 'a> | |
} | |
impl<'a,A, B> Profunctor<'a, A, B> { | |
fn new(f: impl FnMut(A) -> B + 'a) -> 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
// author: @FlavioVilante | |
// MIT License - Copyright 2022 | |
use ruduino::prelude::without_interrupts; | |
use crate::microcontroler::register:: { | |
write_register, | |
read_register, | |
}; |
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
// to be used with deno run-time | |
// the first argument must be the repo name | |
// example: deno run --allow-net .\github_repolines.js microsoft/typescript | |
async function countGithub(repo) { | |
const repoAddress = `https://github.com/${repo}`; | |
const repoApi = `https://api.github.com/repos/${repo}` + `/stats/contributors`; | |
const response = await fetch(repoApi); | |
const contributors = await response.json(); | |
const lineCounts = contributors.map(contributor => ( |
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
#Get help | |
Get-Help Sort-Object | |
#Old dir | |
dir | |
Get-ChildItem | |
Get-ChildItem *.txt | |
Get-ChildItem -Directory | |
Get-ChildItem -File |
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
// You need to import `h` factory function as Deno Deploy | |
// uses it instead of `React.createElement` | |
import { h } from "https://x.lcas.dev/preact@10.5.12/mod.js"; | |
import { renderToString } from "https://x.lcas.dev/preact@10.5.12/ssr.js"; | |
let elapsedTime = 0 | |
setInterval( () => { elapsedTime = elapsedTime + 1; }, 1000) | |
function App() { |
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
// ======================================================================================== | |
// Utilities types | |
// ======================================================================================== | |
type TU11 = '(T extends U) and (U extends T)' | |
type TU10 = '(T extends U) and (U NOT extends T)' | |
type TU01 = '(T NOT extends U) and (U extends T)' | |
type TU00 = '(T NOT extends U) and (U NOT extends T)' | |
type Ext<T,U,A,B> = T extends U ? A : B // In type system jargon we can say that "T is assignable to U". |
NewerOlder