Skip to content

Instantly share code, notes, and snippets.

View appcypher's full-sized avatar
:octocat:
What's up?

Stephen Akinyemi appcypher

:octocat:
What's up?
View GitHub Profile
@appcypher
appcypher / convert_impl_to_from_dyn.rs
Last active November 16, 2021 08:01
Conversion Bewteen &impl Trait and &dyn Trait
trait Fmt {}
// This allows conversion from ?Sized like `&dyn Fmt` back to `&impl Fmt`
impl Fmt for &dyn Fmt {}
struct FmtStruct();
impl Fmt for FmtStruct {}
fn expects_dyn(fmt: &dyn Fmt) -> &dyn Fmt {
@appcypher
appcypher / server.rs
Last active October 24, 2021 08:57
Tokio Sock Custom Impl API
//! Simple Low-level API to work with first.
//! Handlers have the type:
//! H: FnOnce(req: Request) -> impl Future<Output = Result<impl AsRef<[u8]>, impl ResponseError>>
//! Handlers are run in a separate task
let server = Server::new();
server.set(handlers::hello);
@appcypher
appcypher / error.rs
Last active October 23, 2021 09:07
Tokio Doesn't Allow Awaited Result to be Mapped to Another Result with !Send Field/Variant.
use crate::handlers;
use log::info;
use std::sync::Arc;
use tokio::task;
use utilities::{
messages::error::SystemError,
nats::{self, WorkspacesAction},
result::Result,
setup::SharedSetup,
};
@appcypher
appcypher / jomi.md
Last active September 29, 2021 06:54
JOMI

(1.) Stripe supports signing requests made to your webhook with a signature set in the Stripe-Signature header.

Stripe provides multiple official libraries in different languages for verifying signatures and you also need an API key for a successful verification.

You can create new API keys at https://dashboard.stripe.com/apikeys.

const stripe = require('stripe')('sk_test_26PHem9AhJZvU623DfE1x4sd'); // Set API Key.
@appcypher
appcypher / ERC20Token.sol
Created February 20, 2021 20:55
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&runs=200&gist=
pragma solidity 0.5.1;
contract ERC20Token {
string public name;
mapping(address => uint256) public balances;
function mint() public {
balances[tx.origin] ++;
}
@appcypher
appcypher / raccoon_ast.yml
Created April 18, 2020 22:34
Raccoon AST
AST: []
Null: []
Newline:
- index
Indent:
- index
@appcypher
appcypher / generated_ast.py
Created April 5, 2020 18:12
Raccoon AST Sample
[
Class(
name=Identifier(index=1),
body=[
Function(
name=Identifier(index=5),
body=[
AssignmentStatement(
lhses=[
Field(
@appcypher
appcypher / echo.wat
Created October 9, 2019 11:30
WASI WAT EXAMPLES
(module
(import "wasi_unstable" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32)))
(import "wasi_unstable" "fd_read" (func $fd_read (param i32 i32 i32 i32) (result i32)))
(memory 10)
(export "memory" (memory 0))
;; prompt __wasi_ciovec_t struct
(data (i32.const 0) "\08\00\00\00") ;; buf: pointer to prompt string
(data (i32.const 4) "\02\00\00\00") ;; buf_len: 2 characters
@appcypher
appcypher / small.md
Last active September 16, 2019 18:31

Test

Test

Test

Test

Test

@appcypher
appcypher / unicode-math.md
Last active June 10, 2019 19:22
Unicode Math

Unicode Math Experiment