Skip to content

Instantly share code, notes, and snippets.

Avatar

Robin Malhotra codeOfRobin

View GitHub Profile
View memoizedFibonacci.swift
func fibonacci(_ number: Int, memoizingDict: inout [Int: Int]) -> Int {
switch number {
case 0:
return 0
case 1:
return 1
default:
let numberMinus1: Int
let numberMinus2: Int
if memoizingDict[number - 1] == nil {
View Palindrome Permutation.swift
import Foundation
import XCTest
func isPermutationOfPalindrome(_ string: String) -> Bool {
let characterCounts: [Character: Int] = string.reduce(into: [:], { (dict, character) in
dict[character] = (dict[character] == nil) ? 1 : (dict[character] ?? 0) + 1
})
// Do I really need to do this? 🤔
let keys = Array(characterCounts.keys)
View towerover.fish
function towerover --description 'Opens the current folder in Tower.app'
open -a /Applications/Tower.app/ .
end
@codeOfRobin
codeOfRobin / MarketingName.py
Created Sep 11, 2018
Tiny script to get the "marketing name" of your 🖥/💻
View MarketingName.py
#!/usr/bin/python
import sys
import plistlib
import subprocess
from Cocoa import NSBundle
if (len(sys.argv) == 2):
model = sys.argv[1]
else:
View DummyAtomic.swift
//: [Previous](@previous)
import Foundation
class DummyAtomic<Value> {
var value: Value
init(_ value: Value) {
self.value = value
View clapify.fish
function clapify --description 'Replaces words with claps a la https://handclaps.io'
set temp (string join ' 👏 ' $argv)
echo $temp | pbcopy
printf "successfully copied handclapped message $temp"
end
View whyWontThisWork.js
<div id="root"></div>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<script src="https://unpkg.com/prop-types@15.6/prop-types.min.js"></script>
<script type="text/babel">
let rootElement = document.getElementById("root")
function SayHello(props) {
View TagNode.swift
//
// TagNode.swift
// ChannelExample
//
// Created by Robin Malhotra on 24/04/18.
// Copyright © 2018 Robin Malhotra. All rights reserved.
//
import AsyncDisplayKit
View TagCell.swift
//
// TagCell.swift
// ChannelExample
//
// Created by Robin Malhotra on 24/04/18.
// Copyright © 2018 Robin Malhotra. All rights reserved.
//
import AsyncDisplayKit
View ChannelCell.swift
//
// ChannelCell.swift
// ChannelExample
//
// Created by Robin Malhotra on 23/04/18.
// Copyright © 2018 Robin Malhotra. All rights reserved.
//
import AsyncDisplayKit
You can’t perform that action at this time.