Skip to content

Instantly share code, notes, and snippets.

View designablebits's full-sized avatar
🎯
Focusing

Designable Bits designablebits

🎯
Focusing
View GitHub Profile
@kirang89
kirang89 / playingWithDS.m
Created May 29, 2013 10:26
Playing with Array and Dictionary in Objective-C
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
//Mutable Array
NSMutableArray *array;
array = [NSMutableArray arrayWithCapacity:4];
@Arahnoid
Arahnoid / RGB-Hex.js
Last active December 27, 2022 21:32
[Convert color format] Bunch of RGB to Hex and Hex to RGB convert javascript functions what works well in Photoshop #Photoshop
///////////////////////////////////////////////////////////////////////////////////
/// Colection of RGB to HSB, HSB to RGB convert functions
/// Source: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
///////////////////////////////////////////////////////////////////////////////////
/**
* componentToHex convert two digit htx value to R, G or B chanel value
* @param number c value from 0 to 225
* @return string value of R, G or B chanel
* @usage //alert (componentToHex(255)); //ff
@gonzalezreal
gonzalezreal / Singleton.swift
Last active February 1, 2018 09:23
A naive? attempt to create a Singleton in Swift
class FileManager {
struct StaticInstance {
static var instance = FileManager()
}
class var defaultManager : FileManager {
return StaticInstance.instance
}
}
@staltz
staltz / introrx.md
Last active September 6, 2024 10:25
The introduction to Reactive Programming you've been missing
@Xordal
Xordal / invertRGB.js
Created July 7, 2014 12:26
Invert RGB color js
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function invert(rgb) {
@Tricertops
Tricertops / VDM Architecture.md
Last active August 30, 2019 05:28
How we used MVVM architecture and a reactive framework to build our latest iOS app, from theory to actual code examples.

View → Design → Model

iOS applications are usually built with MVC (Model – View – Controller) architecture, which introduces very important concept of separating actual data (Model Layer) and their presentation (View Layer), while the application logic (Controller Layer) stands between them.

View ← Controller → Model

With MVC you typically write most of the code in UIViewController, which usually represents the Controller Layer. View Layer can be easily done in Interface Builder and Model Layer usually doesn’t need a lot of code. The UIViewControleler then holds strong references to both View and Model objects and is responsible for setting them up, handling actions and listening to events.

The problem is, that this middle layer tends to hold too much code and this situation is then jokingly called Massive View Controller. When a single class sets up views, formats data values, handles user input and actions, listens for a bunch of notif

@alanthai
alanthai / colorConvert.js
Last active August 26, 2019 07:46
Converts color hex to decimal
function toHex(n: number) {
return ('0' + n.toString(16)).slice(-2);
}
// ES6
function hexToRGB(code) {
const [r, g, b] = code.replace('#', '')
.match(/../g).map((hex) => parseInt(hex, 16));
return {r, g, b};
@tkon99
tkon99 / name.js
Last active April 19, 2024 14:38
Random Name Generator for Javascript
/*
(c) by Thomas Konings
Random Name Generator for Javascript
*/
function capFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getRandomInt(min, max) {
internal let DEFAULT_MIME_TYPE = "application/octet-stream"
internal let mimeTypes = [
"html": "text/html",
"htm": "text/html",
"shtml": "text/html",
"css": "text/css",
"xml": "text/xml",
"gif": "image/gif",
"jpeg": "image/jpeg",
@gonzalezreal
gonzalezreal / ios-cell-registration-swift.md
Last active March 13, 2024 15:18
iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

iOS Cell Registration & Reusing with Swift Protocol Extensions and Generics

A common task when developing iOS apps is to register custom cell subclasses for both UITableView and UICollectionView. Well, that is if you don’t use Storyboards, of course.

Both UITableView and UICollectionView offer a similar API to register custom cell classes:

public func registerClass(cellClass: AnyClass?, forCellWithReuseIdentifier identifier: String)
public func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)