Skip to content

Instantly share code, notes, and snippets.

View jeden's full-sized avatar

Antonio Bello jeden

  • Elapsus
  • Home - where I work from.
View GitHub Profile
@jeden
jeden / LoadNibView.swift
Created October 25, 2016 07:53
Method to load a view from its nib
// Note: this should be converted into an extension of a new protocol,
// such that the return type is the actual type and not a static `UIView`
extension UIView {
static func nibInstance() -> UIView? {
if let view = Bundle.mainBundle.loadNibNamed(String.className(self), owner: nil, options: nil)?.first as? UIView {
return loginView
}
return nil
}
@jeden
jeden / gist:e51ca85320638927cd87
Last active August 29, 2015 14:16
Convert an array of Int to an array of their respective string representations
private static let digitNames =
[0: "Zero", 1: "One", 2: "Two", 3: "Three", 4: "Four",
5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine"]
extension Array {
func translateToDigitalNames()-> [String]? {
let numbers: [Int] = self.filter { $0 is Int }.map { $0 as Int }
if numbers.count != self.count {
@jeden
jeden / gist:f7f36fd49cf17bb0e6ab
Created January 24, 2015 12:23
Creating a multi dimensional array in swift
var matrix = [[[0, 1], [2, 3]], [[4, 5], [5, 6]]]
matrix[1][1][1]
var r = [Int](count: 3, repeatedValue: 0)
var c = [[Int]](count: 3, repeatedValue: r)
var m = [[[Int]]](count: 3, repeatedValue: c)
m[0][0][0]
class SomeClass {
var _optionalVar: String?
var nonoptionalVar: String? {
get { return _optionalVar }
set { _optionalVar = newValue == nil ? "123" : newValue }
}
init() {
self.nonoptionalVar = nil
### Keybase proof
I hereby claim:
* I am jeden on github.
* I am antbello (https://keybase.io/antbello) on keybase.
* I have a public key whose fingerprint is C2C0 BBFC 0AA8 2A32 1B82 839E 7CDB 6990 87B5 398B
To claim this, I am signing this object:
var fs = require('fs');
function isPlayerBanned(name,isbanned) {
fs.readFile('bans.json', 'utf8', function (err,data) {
if (err) {
console.log(err);
}
var retorna;