Skip to content

Instantly share code, notes, and snippets.

// Basic idea from https://swiftui-lab.com/communicating-with-the-view-tree-part-1/
import SwiftUI
// --- Provides support for a child to propogate its frame
struct ChildPreferenceData: Equatable {
let idx: Int
let bounds: CGRect
}
@raheelahmad
raheelahmad / custom-presentation.swift
Created May 14, 2019 22:16
Custom Presentation basics with UIPresentationController and friends
/// The ring leader
final class ModalTransitioningDelegate: NSObject, UIViewControllerTransitioningDelegate {
func presentationController(
forPresented presented: UIViewController,
presenting: UIViewController?,
source: UIViewController
) -> UIPresentationController? {
return PresentationController(presentedViewController: presented, presenting: presenting)
}
@raheelahmad
raheelahmad / Instructions.md
Last active September 28, 2017 05:47
Clojurescript setup

Set up a directory with project.clj below.

Create namespaces in src/clj/server/core.clj and src/cljs/client/core.cljs

Create an index.html as below in resource/public/.

Start two REPLs with ' " (jack-in-cljs)

Then in CLJS repl:

@raheelahmad
raheelahmad / .spacemacs
Created May 3, 2017 14:37
Spacemacs config May 3, 17
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@raheelahmad
raheelahmad / .spacemacs
Last active May 3, 2017 14:37
Spacemacs config
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@raheelahmad
raheelahmad / .block
Last active February 9, 2017 06:04
[Tufte] Train times on a spine
border: no
license: mit
height: 650
@raheelahmad
raheelahmad / .block
Last active February 9, 2017 03:52
[Tufte] Train times on a spine
border: no
license: mit
height: 640
@raheelahmad
raheelahmad / .block
Last active January 19, 2017 18:59
Transitioning a scatterplot
border: no
license: gpl-3.0
@raheelahmad
raheelahmad / Hangman.hs
Created July 15, 2016 19:32
Hangman in Haskell (expanded from Haskell Book)
module Main where
import Control.Monad
import Data.Char (toLower)
import Data.Maybe (isJust, isNothing, fromMaybe)
import Data.List (intersperse)
import System.Exit (exitSuccess)
import System.Random (randomRIO)
data Puzzle = Puzzle String [Maybe Char] String
@raheelahmad
raheelahmad / Swift2_2_ARCBug.swift
Last active June 20, 2016 17:13
Swift 2.2 bug with optimization on
// This shows a bug in Swift 2.2 (and 2.3) where `self` gets released in a recursive call
extension Dictionary {
mutating func append(_ other: [String: AnyObject]) {
// 2. After the call 1. below, `other` would have been dealloced in the recursive call :(
for (key, value) in other {
if let otherSubDict = value as? [String: AnyObject],
var selfSubDict = self[key] as? AnyObject as? [String: AnyObject]
{
// 1. Make a recursive call