Skip to content

Instantly share code, notes, and snippets.

@red-0ne
red-0ne / machine.js
Created December 30, 2020 15:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@red-0ne
red-0ne / machine.js
Created November 6, 2019 15:27
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'processTransactoin',
initial: 'idle',
context: {},
states: {
idle: {
on: {
SAVE_REQUEST: 'savingRequest'
}
},
import fetchers from './fetchers/index.js';
import dataStore from './data-store';
export const fetcher = {
dataFetchingServer: {
listeners: new Set(),
postMessage: (data) => {
fetcher.dataFetchingClient.listeners.forEach((listener) => listener({ data }));
},
onmessage(callback) {
pragma solidity 0.5.1;
import './ArrayListLib.sol';
import './ExclusionList.sol';
import './Survey.sol';
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Pausable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";
pragma solidity 0.5.1;
library ArrayListLib {
struct ListItem {
uint index;
address item;
}
struct StoredList {
declare type JsonValue = (string|number|boolean|Date|void|ParsedJson);
declare type JsonArray = Array<JsonValue>;
declare type ParsedJson = { [key: string]: JsonValue|JsonArray };
declare module "z-schema" {
type JsonSchema = ParsedJson; // I tried to build a parsed Json type. This could also be an "Object" type
type ZSchemaCallback = (err: Error, status: boolean) => void;
type CustomValidatorSync = (data: any) => boolean;
type CustomValidatorAsync = (data: any, callback: Function) => void;
type CustomValidator = CustomValidatorSync|CustomValidatorAsync;
@red-0ne
red-0ne / gist:52e3d77969bc01ddc8b6
Created February 18, 2015 17:01
values replacement using nodejs
'use strict';
var fs = require('fs');
function replaceValues(values_file, brut_file) {
var values_array = fs.reeadSync(values_file).split("\n");
//on fais exploser la chaine avec une regexp
//contrairement au cas précédent ou c'était par un simple caractère
//faudrait ajuster ta regexp
----+-----+------
# |@RID |@CLASS
----+-----+------
0 |#11:1|Member
----+-----+------
----+-----+------+--------+------+-------------------------------------------------------------------------+-----+----------+------
# |@RID |@CLASS|name |status|password |roles|_allowRead|_allow
----+-----+------+--------+------+-------------------------------------------------------------------------+-----+----------+------
0 |#11:1|Member|user_two|ACTIVE|{SHA-256}D74FF0EE8DA3B9806B18C877DBF29BBDE50B5BD8E4DAD7A3A725000FEB82E8F1|[1] |[1] |[1]
----+-----+------+--------+------+-------------------------------------------------------------------------+-----+----------+------