Skip to content

Instantly share code, notes, and snippets.

@pigoz
pigoz / network.ts
Created Jan 31, 2020
useApi, react, fp-ts
View network.ts
import * as React from 'react';
import * as t from 'io-ts';
import { pipe } from 'fp-ts/lib/pipeable';
import * as E from 'fp-ts/lib/Either';
import * as TE from 'fp-ts/lib/TaskEither';
import * as RD from '@devexperts/remote-data-ts';
interface ApiOptions<T> {
token?: string;
method?: string;
View 000.txt
rspec test.rb 1 ↵
.......*
Pending: (Failures listed here are expected and do not affect your suite's status)
1) test find cool test cases
# Temporarily skipped with xit
# ./test.rb:52
View contramap.ts
type FunctionComponent<A> = (a: A) => string
function contramap<A, B>(fc: FunctionComponent<A>, f: (b: B) => A): FunctionComponent<B> {
return b => fc(f(b))
}
// --- esempio ---
interface _Props {
a: string
View mpv.js
const net = require("net");
const crypto = require("crypto");
const process = require("process");
function random() {
return crypto.randomBytes(4).readUInt32LE(0);
}
function connect() {
const socket = process.env.SOCKET || "/tmp/mpv.sock";
View setrefresh.swift
#!/usr/bin/swift
import CoreGraphics
func display() -> CGDirectDisplayID? {
let max: UInt32 = 32;
let displays = UnsafeMutablePointer<CGDirectDisplayID>.allocate(capacity: Int(max));
let size = UnsafeMutablePointer<UInt32>.allocate(capacity: 1);
CGGetActiveDisplayList(max, displays, size);
@pigoz
pigoz / useMedia.tsx
Last active Feb 26, 2019
useMedia implementation with React Hooks and TypeScript
View useMedia.tsx
import React, { useState, useEffect, useContext } from "react";
type MediaQueries = { [s: string]: MediaQueryList };
type MediaT<T> = { [X in keyof T]: boolean };
function mapValues<T extends object, R>(
object: T,
mapper: (x: T[keyof T], key: keyof T, object: T) => R
): { [K in keyof T]: R } {
const result = {};
View react.rb
# frozen_string_literal: true
require 'ostruct'
class Component
attr_reader :props
def initialize(**props, &children)
@props = OpenStruct.new(default_props.merge(props))
@children = children
View test.re
type a = { x: string };
type b = { x: int };
type c = { y: string };
type d = A | B(int);
type some_union =
| A(a)
| B(b)
| C(c)
| D(d);
@pigoz
pigoz / ps4.md
Last active Aug 8, 2017
PS4 list
View ps4.md

Completed

  • NieR: Automata (1080p60) | 5/5

    • story: 5+ very good and though provoking
    • art direction & design: 5 character design is super good, world is ok
    • gameplay: 5 combat is fun and satisfying, side quests are not bad, jrpg / customization components are nice
    • ost: 5 it's amazing, every piece has 3 variations and they are meshed together seamlessly as you walk through the map, I listen to it while working
    • replayability: 4 not much, no NG/NG+, difficulty scaling is crap as well
@pigoz
pigoz / ciaone.js
Last active Mar 1, 2017
fix link color in github (tapermonkey/greasemonkey)
View ciaone.js
// ==UserScript==
// @name Github Links
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://github.com/
// @grant none
// ==/UserScript==