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 / 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 / raccoon_ast.yml
Created April 18, 2020 22:34
Raccoon AST
AST: []
Null: []
Newline:
- index
Indent:
- index
@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 / 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 / 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 / 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 / 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 / draft.md
Created December 2, 2021 10:18
Solving HTTP Request / Response Streaming NATS

REQUEST RESPONSE STREAMING VIA NATS

TODO

  • Check error for no subscriber connected
  • code /Users/appcypher/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.15/src/body/to_bytes.rs

Subjects

  1. worspaces - v1.run_surl.workspaces.9ccec027-68a3-47a2-bd3d-85a9c6faebfb
  2. directives - ovsJHJmrsxbs6GaQw1JtRe
@appcypher
appcypher / server.rs
Last active December 18, 2021 13:49
Response Recv Issue In Http [Server Returns Empty Response]
use std::{cell::RefCell, convert::Infallible, net::SocketAddr, rc::Rc, thread};
use tokio::{
net::{TcpListener, TcpStream},
runtime::Builder,
sync::mpsc::{self, Receiver, Sender},
task::LocalSet,
};
use utilities::hyper::{
rt::Executor, server::conn::Http, service::service_fn, Body, Request, Response,
};
@appcypher
appcypher / auth.js
Last active December 21, 2021 08:52
Accessing the Global Scope
function main() {
const { log } = Tera;
log.info(">>> authenticating ...");
return true;
})() // Close the parens prematurely.
// Do globally things.
var leak = 5;