Skip to content

Instantly share code, notes, and snippets.

Sailing the seas of Swift

Nicholas Maccharoli Nirma

Sailing the seas of Swift
View GitHub Profile
Nirma / FTPUpload.swift
Last active September 28, 2022 09:02
Upload a file via FTP on iOS or macOS
View FTPUpload.swift
import Foundation
import CFNetwork
public class FTPUpload {
fileprivate let ftpBaseUrl: String
fileprivate let directoryPath: String
fileprivate let username: String
fileprivate let password: String
Nirma / Decorators.go
Created December 28, 2015 12:22
Using Decorators in Golang to profile performance
View Decorators.go
package main
import (
func main() {
Nirma / SoundListViewController.swift
Last active October 11, 2020 11:57
Display all available System Sounds for iOS, plays sound when tapped.
View SoundListViewController.swift
// SoundListViewController.swift
// SoundSampler
// Created by Nicholas Maccharoli on 2016/12/06.
// Copyright © 2016年 Nicholas Maccharoli. All rights reserved.
import UIKit
import AudioToolbox
View hole_head.pjunoxl
<?xml version="1.0" encoding="UTF-8"?>
<tal curprogram="0" version="1.1">
<program path="" programname="hole_head" modulation="0.0" dcolfovalue="0.4233498573303223"
dcopwmvalue="0.1031103730201721" dcopwmmode="1.0" dcopulseenabled="1.0"
dcosawenabled="1.0" dcosuboscenabled="1.0" dcosuboscvolume="1.0"
dconoisevolume="0.0" hpfvalue="0.0" filtercutoff="0.473753035068512"
filterresonance="0.4271174967288971" filterenvelopemode="1.0"
filterenvelopevalue="0.09792116284370422" filtermodulationvalue="0.5374104976654053"
Nirma / Inefficient-Rod-Cut.swift
Created January 4, 2020 13:03
Top Down Rod Cutting DP Example in Swift (Inefficient Version)
View Inefficient-Rod-Cut.swift
func maxProfitRodCut(prices: [Int], length: Int) -> Int {
if length <= 0 {
return 0
var currentMax = Int.min
for index in (1...length) {
currentMax = max(currentMax, prices[index - 1] + maxProfitRodCut(prices: prices, length: length - index))
return currentMax
Nirma / NaiveGraphs.swift
Created November 3, 2019 09:40
Naive Graphs Practice using Adjacency Matrix instead of normal linked lists
View NaiveGraphs.swift
import Cocoa
class Graph {
let size: Int
private var nodes: [[Int]]
init(size: Int) {
Nirma / .gitignore
Created October 23, 2019 02:23
Xcode .gitignore
View .gitignore
## ---------- File system related ----------
## ---------- Build Related ----------
View Raw-String-Interpolation.swift
let example: Int = 42
"This is a conventional string with interpolation: \(example)"
#"This is a raw string with interpolation: \#(example)"#
##"This is a string with raw pound signs with interpolation \##(example)"##
Nirma / CardboardBox.swift
Last active April 27, 2019 08:58
Supporting code examples for blog post "Learning to love Result"
View CardboardBox.swift
struct CardboardBox: Codable {
let brand: String
let width: Double
let height: Double
let depth: Double
let flavor: String?
git clone --depth 1 # a shallow clone will do
mkdir -p ~/.vim # make a vim folder if its not available already
cp -a ./swift/utils/vim/ ~/.vim # just copy over the contents of utils/vim as they are
rm -rf # this is just for cleanup