Skip to content

Instantly share code, notes, and snippets.

View pigoz's full-sized avatar
:octocat:

Stefano Pigozzi pigoz

:octocat:
View GitHub Profile
@pigoz
pigoz / setrefresh.swift
Created January 13, 2019 17:46
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 February 26, 2019 18:51
useMedia implementation with React Hooks and TypeScript
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 = {};
# frozen_string_literal: true
require 'ostruct'
class Component
attr_reader :props
def initialize(**props, &children)
@props = OpenStruct.new(default_props.merge(props))
@children = children
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 August 8, 2017 22:01
PS4 list

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 March 1, 2017 16:15
fix link color in github (tapermonkey/greasemonkey)
// ==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==

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@pigoz
pigoz / browser.js
Last active January 17, 2017 13:59
download listing images from airbnb
const x = JSON.parse($('[data-hypernova-key=listingbundlejs]')[1].text.slice(4, -3))
console.log(x.listing.photos.map(x => x.xx_large).join("\n"))
@pigoz
pigoz / webpack.js
Created November 2, 2016 15:55
webpack/gulp integration
const gulp = require('gulp');
const gutil = require('gulp-util');
const livereload = require('gulp-livereload');
const webpack = require('webpack');
const notify = require('node-notifier');
const config = require('../config');
const manifest = require('../manifest');
const webpackConfigDefault = require('../webpack.config');
@pigoz
pigoz / server.rb
Created October 17, 2016 15:29
AWS S3 Presigned Post upload in JavaScript with FormData
post = Aws::S3:Bucket.new('XXXXX').presigned_post(
key: "uploads/tmp/#{SecureRandom.uuid}/${filename}",
success_action_status: '201',
acl: 'public-read')
{ url: post.url.to_s, fields: post.fields }.to_json