Skip to content

Instantly share code, notes, and snippets.

View Amosel's full-sized avatar

Amos Elmaliah Amosel

View GitHub Profile
@jmatsushita
jmatsushita / README
Last active July 16, 2024 10:30
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
@hasparus
hasparus / match.ts
Last active August 15, 2022 01:30
lightweight sum type matching in typescript
interface A { type: 'A', a: 10 };
interface B { type: 'B', b: [11] };
type AB = A | B;
type TypeOf<T extends { type: any }> = T extends { type: infer Type } ? Type : never;
type Cases<T extends { type: any }, R> = {
[P in TypeOf<T>]: (val: Extract<T, { type: P }>) => R
}
@Yimiprod
Yimiprod / difference.js
Last active July 13, 2024 15:07
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
@mackuba
mackuba / wwdc15.md
Last active August 6, 2022 17:28
New stuff from WWDC 2015

Here's my own list of the interesting stuff announced during this year's WWDC, collected from the keynotes, various Apple docs, blog posts and tweets.

If you're planning to watch the videos, I really recommend this Mac app that helps you download and watch them: https://github.com/insidegui/WWDC.

OS X El Capitan

http://www.apple.com/osx/elcapitan-preview/

  • split view - two apps side by side on full screen
- (id)init
{
self = [super init];
if (self) {
NSSet *properties = [self.class propertyKeys];
[properties enumerateObjectsUsingBlock:^(NSString *obj, BOOL *stop) {
Class class = [self classForPropertyName:obj];
if (class) {
if ([class isSubclassOfClass:[ABModel class]] || class == [NSURL class]) {
SEL selector = MTLSelectorWithKeyPattern(obj, "JSONTransformer");
@hofmannsven
hofmannsven / README.md
Last active July 16, 2024 01:30
Git CLI Cheatsheet
@romaonthego
romaonthego / NSDateFormatter cheat sheet
Last active July 19, 2024 10:39
Date Formats for NSDateFormatter
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)
@mikelikespie
mikelikespie / NSData+PIOAdditions.h
Created February 14, 2013 06:35
Zero-Copy bridging between dispatch_data_t and NSData
//
// NSData+PIOAdditions.h
// PonyExpress
//
// Created by Michael Lewis on 2/13/13.
//
//
#import <Foundation/Foundation.h>
@jamiehodge
jamiehodge / libav.rb
Created December 20, 2012 08:56
Homebrew Libav formula
require 'formula'
class Libav < Formula
homepage 'http://libav.org/'
url 'http://libav.org/releases/libav-9_beta2.tar.xz'
sha1 'acb7ffbcded06e5f04e8fd0f7dbcc923fd95df3f'
head 'git://git.libav.org/libav.git'
option "without-x264", "Disable H264 encoder"
@steipete
steipete / gist:4233987
Created December 7, 2012 15:32
Print a CGPath
extern void CGPathPrint(CGPathRef path, FILE* file);
CGPathPrint(path.CGPath, NULL);
Path 0xb44e380:
moveto (-12, 295)
lineto (115, 295)
lineto (108, -12)
lineto (235, -12)