Skip to content

Instantly share code, notes, and snippets.

View jordaaash's full-sized avatar
🌴
Not on vacation, I just love palm trees

Jordan jordaaash

🌴
Not on vacation, I just love palm trees
View GitHub Profile
@jordaaash
jordaaash / .mocharc.json
Created October 25, 2021 01:18
Mocha + TypeScript + ESM
{
"extension": ["ts"],
"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"],
"spec": ["test/**/*.test.ts"]
}
@jordaaash
jordaaash / index.ts
Created July 19, 2021 18:05
Wallet Adapter interface
import { PublicKey, Transaction } from '@solana/web3.js';
import EventEmitter from 'eventemitter3';
export interface WalletAdapterEvents {
ready: () => void;
connect: () => void;
disconnect: () => void;
error: (error: Error) => void;
}
@jordaaash
jordaaash / serum_account.rs
Created March 29, 2021 19:08
How to use account data in a Solana program test
#![cfg(feature = "test-bpf")]
// first, grab some account data, e.g.
// ```shell
// solana account -u m SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt --output-file account.bin
// ```
mod helpers;
use helpers::*;
@jordaaash
jordaaash / README.md
Created April 23, 2019 19:59 — forked from pcan/README.md
Node.js plain TLS Client & Server, 2-way Cert Auth

Node.js TLS plain TLS sockets

This guide shows how to set up a bidirectional client/server authentication for plain TLS sockets.

Prepare certificates

Generate a Certificate Authority:

openssl req -new -x509 -days 9999 -keyout ca-key.pem -out ca-crt.pem
class Image
def initialize (data)
@data = data
end
#write a method that loops through the existing 2D array and finds the
#location of the existing ones. The location of the the existing ones
#needs to be stored into memory so they can be iterated over and the
#exiting cells around them can be altered.
@jordaaash
jordaaash / jsonb_diff.sql
Created September 11, 2017 04:31
Find the symmetric difference between two jsonb objects
CREATE OR REPLACE FUNCTION jsonb_diff(a_ jsonb, b_ jsonb)
RETURNS jsonb AS $$
SELECT jsonb_object_agg("keys"."key", "a"."value")
FROM (
SELECT jsonb_object_keys(a_) AS "key"
UNION
SELECT jsonb_object_keys(b_) AS "key"
) AS "keys"
LEFT JOIN (SELECT "key", "value" FROM jsonb_each(a_)) AS "a"
ON "a"."key" = "keys"."key"
@jordaaash
jordaaash / fiber.js
Last active August 31, 2017 18:57
Promise + Fiber
/* @flow */
'use strict';
const Promise = require('bluebird');
const Fiber = require('fibers');
const fiber = function <T: any> (callback: () => T): Promise<T> {
return new Promise(function (resolve: Function, reject: Function): void {
Fiber(function (): void {
let fiber: Fiber = Fiber.current;
@jordaaash
jordaaash / call.js
Created February 24, 2017 02:58
React Immutable virtual list
'use strict';
const call = function (fn) {
return Function.prototype.call.bind(fn);
};
export default call;
@jordaaash
jordaaash / bluebird.js
Last active February 15, 2017 21:52 — forked from lorenzodallavecchia/bluebird-zone.js
Patch for making the Bluebird library aware of Zone.js
'use strict';
import Promise from 'bluebird';
import {
zonifyCall,
zonifyCatch,
zonifyCoroutine,
zonifyFirst,
zonifyLast,
zonifyMiddle,
@jordaaash
jordaaash / DecoratorPattern.js
Created October 18, 2016 00:29
Decorator Pattern with generics in Flow (not working)
// @flow
class SuperClass {
something () {
}
}
class SubClass extends SuperClass {
}