Skip to content

Instantly share code, notes, and snippets.

View BenziAhamed's full-sized avatar
🏠
Working from home

Benzi BenziAhamed

🏠
Working from home
  • Meta
  • London, UK
View GitHub Profile
@BenziAhamed
BenziAhamed / getfact.js
Created March 10, 2013 19:37
MentalFloss.com has a great amazing facts section online. Here is a NodeJS version of it for command line happiness. To use, run as "node getfact.js"
var http = require('http');
var options = {
host: 'mentalfloss.com',
path: '/api/1.0/views/amazing_facts.json?limit=1&display_id=xhr&bypass=1'
}
var request = http.request(options, function (res) {
var data = [];
res.on('data', function (chunk) {
data = JSON.parse(chunk.toString());
@BenziAhamed
BenziAhamed / one.js
Created March 15, 2013 16:25
Couple of test files in here
File 1 for testing GitFred
@BenziAhamed
BenziAhamed / CGCreatePattern.swift
Last active May 24, 2022 22:24
Demonstration of using CGCreatePattern in Swift
//: Playground - noun: a place where people can play
//: Copy this to one!
import UIKit
// With helpful insights from
// https://forums.developer.apple.com/message/15725#15725 via http://oleb.net/blog/2015/06/c-callbacks-in-swift/
// This is essential the standalone basic definition of a pattern
// that CGCreatePattern requires
@BenziAhamed
BenziAhamed / XML.swift
Created October 15, 2015 19:42
Example XML processing
//: Playground - noun: a place where people can play
import UIKit
let xml = "<coord2 count=\"3\">"
+ "<markers>"
+ "<marker>"
+ "<item>marker1</item>"
+ "</marker>"
@BenziAhamed
BenziAhamed / Templater.swift
Created January 18, 2017 23:33
My lame little templating engine in Swift
import Cocoa
// more of a POC
// not production ready
protocol PropertyReflectable { }
extension PropertyReflectable {
subscript(property key: String) -> Any? {
let mirror = Mirror(reflecting: self)
@BenziAhamed
BenziAhamed / DynamicTree.swift
Created January 28, 2017 17:32
Swift port of Box2D's dynamic AABB tree
//
// DynamicTree.swift
// Mojumbo
//
// Created by Benzi on 10/12/16.
//
// Swift port of the Box2D implemention of a dynamic balancing AABB tree
// https://github.com/erincatto/Box2D/blob/master/Box2D/Box2D/Collision/b2DynamicTree.h
@BenziAhamed
BenziAhamed / CIFilterChain.swift
Last active May 27, 2022 15:00
CIFilterChain - Chain together CI filters with a fluent API
//: Playground - noun: a place where people can play
import UIKit
public protocol CIFilterChainable {
var cifilter: CIFilter? { get }
}
extension String : CIFilterChainable {
public var cifilter: CIFilter? {
@BenziAhamed
BenziAhamed / Memcache.swift
Created May 17, 2017 13:27
In-process, single thread safe memcache in Swift
import Foundation
public struct Memcache {
enum Expiration {
case never
case at(Double)
var expired: Bool {
switch self {
case .never: return false
import Cocoa
// what is a 'type'?
// it has a domain, a name
// it can have 'properties'
protocol TypeBuilder : class {
func setType(type: String)
func setTypeName(name: String)
func addProperty(type: String, label: String)
@BenziAhamed
BenziAhamed / Obfuscator.swift
Created November 15, 2018 16:00 — forked from DejanEnspyra/Obfuscator.swift
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {