Skip to content

Instantly share code, notes, and snippets.

View ermik's full-sized avatar
🍫
Where no one has gone before

Ermolay Romanov ermik

🍫
Where no one has gone before
View GitHub Profile
@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 = () -> ()
@mnylen
mnylen / _.md
Last active April 23, 2021 21:17
Debounced fetching to reduce number of requests when doing API proxying through GraphQL

Simple implementation of debounced fetching in GraphQL to allow merging of multiple rest / database requests into one. Although this example uses GraphQL, the debouncedFetch / fetchProgramPlaycount implementations could probably be used in any context to achieve the same result.

This approach was first described by @leebyron at graphql/graphql-js#19 (comment)

For example this allows turning ten requests for playcounts from this GraphQL query into just one:

{
  latestPrograms(first: 10) {
    name,

playcount

@remy
remy / _README.md
Last active January 12, 2024 11:57
requestAnimationFrame helper

raf.js

A simple script with a few niceties that allows for multiple requestAnimationFrame calls, and FPS pinning.

How it works

The script polyfills rAF if required, then overloads requestAnimationFrame and cancelAnimationFrame with a process that allows multiple frames to be queued up for rAF to run.

This is useful if there are multiple animations running on the page, you want all the callbacks to happen at once, and not on multiple rAF calls. This script is meant as a drop-in solution to that problem.

@JeOam
JeOam / Animation.md
Last active February 18, 2024 21:18
iOS Core Animation: Advanced Techniques, Part 1: The Layer Beneath

Author: https://www.cyanhall.com/

1. The Layer Tree

Core Animation's original name is Layer Kit

Core Animation is a compositing engine; its job is to compose different pieces of visual content on the screen, and to do so as fast as possible. The content in question is divided into individual layers stored in a hierarchy known as the layer tree. This tree forms the underpinning for all of UIKit, and for everything that you see on the screen in an iOS application.

In UIView, tasks such as rendering, layout and animation are all managed by a Core Animation class called CALayer. The only major feature of UIView that isn’t handled by CALayer is user interaction.

There are four hierarchies, each performing a different role:

@lstroud
lstroud / scrub_opml.groovy
Created April 25, 2014 19:29
This script will convert an opml feed list between file formats (XML, JSON, and CSV), scrub the list for feeds that are still active, filter the list by expression, and de-duplicate the feeds in the list. I built it because I needed to reorganize my feeds. Moving the feeds to a csv file, where the tag column is the folder(s), made it very quick …
/*
Copyright 2014 Les Stroud
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software