Skip to content

Instantly share code, notes, and snippets.

masters3d / default.swift
Created June 20, 2019 17:09
Default Init for Swift 5.0
View default.swift
protocol Initializable {
extension String:Initializable {}
struct Default<T> where T:Initializable {
typealias SomeType = T
static func some() -> SomeType {
return SomeType()
masters3d /
Last active July 29, 2018 03:42
Write up on the C++11 optional feature.


I chose the new C++17 feature called [std::optional]. I am attracted to this feature because I am a big fan of the [optional type in Swift] and others languages like TypeScript and C#. The main idea behind optional is that is meant to address the fact that not all types are meant to be null. Languages like [Rust and Swift] (which market themselves as the next C++ killer) emerged around 2010-2015 already with the idea of optionals from the get-go.

#include "stdafx.h"
#include <optional>
#include <string>
#include <iostream>
View n-queens.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace n_queen
class Program
static int gridSize = 4;
masters3d / swift.bash
Created June 23, 2018 05:53
switch macos default swift
View swift.bash
sudo xcode-select --switch /Applications/
export TOOLCHAINS=swift
masters3d /
Created June 13, 2018 22:24
Get the size of subfolders in the current dir
du -h --max-depth=1 --block-size=G . | sort -n
View capslock-dual.ahk
; Author: fwompner gmail com
SetCapsLockState, alwaysoff
Send {LAlt Down}
KeyWait, CapsLock, T9 ; added timeout
Send {LAlt Up}
if ( instr(A_PriorKey, "Capslock") )
Send {Alt}
export SQL_BACKUP_JOB_ID="${SQL_BACKUP_JOB_ID:-$SQL_BACKUP_JOB_ID_CI}" # Check if we set the Job ID variable if not use the default
masters3d / DataController.js
Created July 30, 2017 01:58
This code saves a loads data from the localStorage object on the browser.
View DataController.js
'use strict';
class DataController {
DataController.load = loadLocalStorage = saveLocalStorage
function loadLocalStorage() {
let rawData = localStorage.getItem('masters3d');
View swiftLintXcode.bash
if which swiftlint >/dev/null; then
cd ..
echo "Local Linting Dir"
echo $PWD
if [ "$CI" = true ]; then
swiftlint lint
swiftlint autocorrect --format
masters3d / json_storage.js
Created June 21, 2017 21:08 — forked from emanb29/json_storage.js
Getters and setters for localStorage allowing it to transparently store objects using es6's Proxy
View json_storage.js
/* json_storage.js
* @danott
* 26 APR 2011
* Building on a thread from Stack Overflow, override localStorage and sessionStorage's
* getter and setter functions to allow for storing objects and arrays.
* Original thread: