Skip to content

Instantly share code, notes, and snippets.

View andrekandore's full-sized avatar

アンドレカンドレ andrekandore

View GitHub Profile
@emkay
emkay / build-grub-osx.sh
Last active November 16, 2024 14:10
Build Grub on OSX
#!/bin/sh
set -e
# First we are going to make sure that you understand this is sort of experimental and we will be compiling stuff.
# by default CONTINUE will be false
CONTINUE=false
echo ""
echo "You are about to download, compile, and install stuff on your computer."
@acrookston
acrookston / README.md
Last active January 26, 2022 11:05
Xcode pre-action to build custom Info.plist

Automatic build versions from git in Xcode (and other goodies)

Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.

1. Xcode Scheme pre-action

Edit Xcode Scheme and add a pre-action script. Copy the contents of preaction.sh into the pre-action script box.

@kharrison
kharrison / Country.swift
Last active February 16, 2021 15:35
Swift Hash Functions
import Foundation
struct Country {
let name: String
let capital: String
var visited: Bool
}
extension Country: Equatable {
static func == (lhs: Country, rhs: Country) -> Bool {
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active April 9, 2025 14:04
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dylanmckay
dylanmckay / facebook-contact-info-summary.rb
Last active December 3, 2024 21:48
A Ruby script for collecting phone record statistics from a Facebook user data dump
#! /usr/bin/env ruby
# NOTE: Requires Ruby 2.1 or greater.
# This script can be used to parse and dump the information from
# the 'html/contact_info.htm' file in a Facebook user data ZIP download.
#
# It prints all cell phone call + SMS message + MMS records, plus a summary of each.
#
# It also dumps all of the records into CSV files inside a 'CSV' folder, that is created
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 10, 2025 19:06
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@desugaring
desugaring / keypaths.playground
Created June 8, 2018 15:28
Two-way binding in iOS using KVO
//: Playground - noun: a place where people can play
import UIKit
/* Scroll to the bottom for examples */
typealias WritableObjectKeyPath<O: NSObject, V: Equatable> = (object: O, keyPath: WritableKeyPath<O, V>)
typealias ReadOnlyObjectKeyPath<O: NSObject, V: Equatable> = (object: O, keyPath: KeyPath<O, V>)
func bind<O: NSObject, O2: NSObject, V: Equatable>(source: ReadOnlyObjectKeyPath<O, V>, to target: WritableObjectKeyPath<O2, V>) -> NSKeyValueObservation?
@andrekandore
andrekandore / keypaths.playground
Created June 9, 2018 00:12 — forked from desugaring/keypaths.playground
Two-way binding in iOS using KVO
//: Playground - noun: a place where people can play
import UIKit
/* Scroll to the bottom for examples */
typealias WritableObjectKeyPath<O: NSObject, V: Equatable> = (object: O, keyPath: WritableKeyPath<O, V>)
typealias ReadOnlyObjectKeyPath<O: NSObject, V: Equatable> = (object: O, keyPath: KeyPath<O, V>)
func bind<O: NSObject, O2: NSObject, V: Equatable>(source: ReadOnlyObjectKeyPath<O, V>, to target: WritableObjectKeyPath<O2, V>) -> NSKeyValueObservation?
(declaim (ftype (function (fixnum function) ) triples))
(time
(defun triples (n func)
(declare (optimize (speed 3) (debug 0) (safety 0)))
(declare (type function func)
(type fixnum n))
(let ((count 0))
(declare (type fixnum count))
(loop for z fixnum from 1 do
(loop for x fixnum from 1 to z do
@sinclairtarget
sinclairtarget / fish.sim
Last active December 29, 2024 03:36
Simula Demonstration
Simulation Begin
! We will use this as input to Normal() below ;
Integer seed;
! Utility method for logging messages along with the current simulation
time ;
Procedure log(message); Text message; Begin
OutFix(Time, 2, 0);
OutText(": " & message);
OutImage;