Skip to content

Instantly share code, notes, and snippets.

View luics's full-sized avatar
🎯
Focusing

luics luics

🎯
Focusing
View GitHub Profile
@frzi
frzi / useForceUpdate.js
Last active October 31, 2022 18:43
useForceUpdate in React with hooks.
// Put me somewhere accessible.
const useForceUpdate = () => {
const [_, setState] = useState(0)
return () => setState(val => val + 1)
}
// Example.
const Component = () => {
const forceUpdate = useForceUpdate()
@iby
iby / Playground.swift
Last active June 29, 2020 20:45
Block / method / function comparison in Swift
import Foundation
// Some interesting observations on block comparing. Apparently swift nor objective c don't allow comparing closures
// due to the complexity of the process and because of compiler optimisations… bla bla. But it seems to be possible
// to do this using conventions blocks, aka the objective c ones that can be cast as objects. The interesting part
// is how swift freely casts SwfBlock to ObjBlock, yet in reality two casted SwfBlock blocks will always be different
// values, while ObjBlocks won't. When we cast ObjBlock to SwfBlock, the same thing happens to them, they become two
// different values. So, in order to preserve the reference, this sort of casting should be avoided.
typealias SwfBlock = () -> ()
@domenic
domenic / 0-github-actions.md
Last active May 26, 2024 07:43
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
@stramit
stramit / CustomEvents.cs
Created September 4, 2014 06:16
Sending Custom Events via the EvenSystem
using System;
using System.Collections.Generic;
using UnityEngine.Events;
// interface you implement in your MB to receive events
public interface ICustomHandler : IEventSystemHandler
{
void OnCustomCode(CustomEventData eventData);
}