Skip to content

Instantly share code, notes, and snippets.

@moodysalem
moodysalem / leaderboard.csv
Last active April 21, 2024 14:29
Leaderboard STRK allocations
Address Starknet ID STRK allocation
0x49fb4281d13e1f5f488540cd051e1507149e99cc2e22635101041ec5e4e4557 realmsworld.stark 0
0x44c0d80799aca566a792c5ef2491ba5e36391dd7fceffd9afe2824335ab55e1 mimesis.stark 1200
0x680afd6b0843e7851390521d87e849f010babbc608ba53dcff02b1c0fcd6fa 1800
0x3f60afe30844f556ac1c674678ac4447840b1c6c26854a2df6a8a3d2c015610 sendmoodz.stark 91800
0x79b6f2012e8fc8b94b79d81e24fcf41d5cc3b84cd98e3ba6fd715ba0d2037fa computerbleu.stark 0
0x3c22c9daf71cc2c9cdb6018bccd3903b94ca0ce74ba048a4f8ee4ccd7451e83 chenzs.stark 1200
0x2c36503c8ed3a54daed4b7d1870593329aa144c6fb389d3afd86659384773a0 0
0x7266c8d2cf45ecba9221e7691f80fb3e6c4ff30b09f6a3a1097341a2f3f14de e.stark 0
0x6e14b28449c412a336e7a5a3473da083b9159e6845be4d02ee50f6095a5b3ce 1200
@moodysalem
moodysalem / example.sol
Last active April 1, 2022 22:05
Transient Storage Example
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
/// @notice The canonical ERC20 interface
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function transferFrom(
@moodysalem
moodysalem / TransientStorage.sol
Last active September 14, 2023 10:12
proxy yul code for using transient storage
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.8.12;
type TransientStorageProxy is address;
library TransientStorage {
function init() internal returns (TransientStorageProxy proxy) {
// initCode == bytecode from `yarn compile-tsp`
bytes
memory initCode = hex'602980600d600039806000f3fe366020811460135760408114602057600080fd5b600035b360005260206000f35b602035600035b450';
@moodysalem
moodysalem / prevent-duplicate-async.test.ts
Created December 22, 2018 04:57
TypeScript: Higher order function to prevent duplicate calls to an async function, i.e. memoize
import { expect } from 'chai';
import preventDuplicateAsync from '../src/util/prevent-duplicate-async';
function testPromise<T>(): { promise: Promise<T>; resolve: (T) => void; reject: (Error) => void; } {
let rslv, rjct;
const promise = new Promise<T>((resolve, reject) => {
rslv = resolve;
rjct = reject;
@moodysalem
moodysalem / swagger-definitions.ts
Created February 8, 2018 19:51
TypeScript type interfaces for Swagger Models
interface IDataType {
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
readOnly?: true;
writeOnly?: true;
}
interface IStringType extends IDataType {
type: 'string';
format?: 'date' | 'date-time' | 'password' | 'byte' | 'binary' | 'uuid' | 'email' | 'uri' | 'hostname' | 'ipv4' | 'ipv6';
@moodysalem
moodysalem / SearchBuilder.java
Last active March 15, 2017 20:41
Used for building ElasticSearch query objects
package com.fastmodelsports.social.lambda.util.es;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
public abstract class SearchBuilder {
public static JsonArray sortOn(final String attribute, final boolean desc) {
final JsonObject sort = new JsonObject(),
attr = new JsonObject();
@moodysalem
moodysalem / app.jsx
Created January 22, 2017 19:48
Help with rendering reddit comment
import React, { Component } from "react";
const Entry = ({ entry: { name, game } }) => (
<div>
<h3>{name}</h3>
<p>{game}</p>
</div>
);
const CHANNELS = [
@moodysalem
moodysalem / PreventLeaveRoute.jsx
Created January 22, 2017 18:52
React HOC to prevent leaving a page
import React, { Component, PropTypes } from 'react';
/**
* Only ever render one of these per page
*
* TODO: improve with react-side-effect to better handle multiple instances of this being rendered at once so we can
* nest the component in forms
*/
export default class PreventLeaveRoute extends Component {
static contextTypes = {
@moodysalem
moodysalem / render-component-to-print-html.jsx
Created November 22, 2016 16:09
Render a react component to an html document that shares all the links and styles for printing, and convert it to a data URI for window.open
import React, { PureComponent, PropTypes } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Base64 } from 'js-base64';
import Promise from 'bluebird';
const htmlDocTemplate = ({ links, pageStyles, body, title = 'Print' }) => (`
<html>
<head>
<title>${title}</title>
${links}
@moodysalem
moodysalem / render-text.jsx
Created November 11, 2016 19:18
Render React component to text
import { render, unmountComponentAtNode } from 'react-dom';
export function renderText(component) {
const _el = document.createElement('div');
document.body.appendChild(_el);
render(component, _el);
const text = _el.innerText;
unmountComponentAtNode(_el);
document.body.removeChild(_el);
return text;