Skip to content

Instantly share code, notes, and snippets.

Avatar

Chéyo Jiménez masters3d

View GitHub Profile
@masters3d
masters3d / default.swift
Created Jun 20, 2019
Default Init for Swift 5.0
View default.swift
protocol Initializable {
init()
}
extension String:Initializable {}
struct Default<T> where T:Initializable {
typealias SomeType = T
static func some() -> SomeType {
return SomeType()
}
@masters3d
masters3d / std::optional.md
Last active Jul 29, 2018
Write up on the C++11 optional feature.
View std::optional.md

std::optional

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
masters3d / swift.bash
Created Jun 23, 2018
switch macos default swift
View swift.bash
sudo xcode-select --switch /Applications/Xcode-10bA.app/
export TOOLCHAINS=swift
@masters3d
masters3d / size_of_folders.sh
Created Jun 13, 2018
Get the size of subfolders in the current dir
View size_of_folders.sh
du -h --max-depth=1 --block-size=G . | sort -n
View capslock-dual.ahk
; Author: fwompner gmail com
#InstallKeybdHook
SetCapsLockState, alwaysoff
Capslock::
Send {LAlt Down}
KeyWait, CapsLock, T9 ; added timeout
Send {LAlt Up}
if ( instr(A_PriorKey, "Capslock") )
{
Send {Alt}
View bashSwitch.sh
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
masters3d / DataController.js
Created Jul 30, 2017
This code saves a loads data from the localStorage object on the browser.
View DataController.js
'use strict';
class DataController {
}
DataController.load = loadLocalStorage
DataController.save = 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
else
swiftlint lint
swiftlint autocorrect --format
fi
@masters3d
masters3d / json_storage.js
Created Jun 21, 2017 — 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:
* http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage
*