Skip to content

Instantly share code, notes, and snippets.

@0xorial
0xorial / uae.tsx
Created February 23, 2021 17:23
useAsyncEffect
import {useEffect, useRef, useState} from 'react';
export type AsyncEffectFuncContext = {
wrap: <T>(p: Promise<T>) => Promise<T>;
};
export type AsyncEffectFunc = (p: AsyncEffectFuncContext) => Promise<void>;
export function useAsyncEffect(
createGenerator: AsyncEffectFunc,
const { spawn, fork } = require("child_process");
const readline = require("readline");
async function* c(x) {
for await (const line of x) {
yield line;
}
}
async function readLine(g) {
public class S : IDisposable
{
private static void Log(string s)
{
Console.WriteLine(DateTime.Now + ": " + s);
}
private readonly string _caller;
private readonly System.Diagnostics.Stopwatch _s;
@0xorial
0xorial / ballot.sol
Created February 12, 2018 20:10 — forked from anonymous/ballot.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract Vaults {
struct Deposit {
bool isCreated;
uint amount;
uint takenInterest;
uint depositBlock;
uint releaseRequestBlock;
address releaseTo;
@0xorial
0xorial / designer.html
Last active August 29, 2015 14:19
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
public class Parallel2
{
public delegate void ParallelForBodyDelegate(int i, int progress);
public static void For(int fromInclusive, int toExclusive, ParallelForBodyDelegate body)
{
int counter = 0;
Parallel.For(
fromInclusive,
toExclusive,
@0xorial
0xorial / gist:bdd3f430e00cc3df4fd7
Created November 2, 2014 15:41
using assets from gems with karma-sprockets
fs = require('fs');
path = require('path');
glob = require('/home/ironic/.nvm/v0.11.14/lib/node_modules/glob');
util = require('util');
path.deepdir = function (_path, count) {
var result = _path;
for (var i = 0; i < count; i++)
result = path.dirname(result);
return result;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Common;
using System.Data.Entity;
using System.Linq;
using Npgsql;
namespace ConsoleApplication1
{
[Table("books", Schema = "public")]