Skip to content

Instantly share code, notes, and snippets.

View tiagobbraga's full-sized avatar

Tiago Braga tiagobbraga

View GitHub Profile
@tomysmile
tomysmile / mac-php-composer-setup.md
Created July 11, 2016 10:45
Setup PHP Composer using Brew
extension String {
var isCPF: Bool {
let cpf = self.stringByReplacingOccurrencesOfString(".", withString: "").stringByReplacingOccurrencesOfString("-", withString: "")
if cpf.characters.count == 11 {
let d1 = Int(cpf.substringWithRange(Range(cpf.startIndex.advancedBy(9) ..< cpf.startIndex.advancedBy(10))))
let d2 = Int(cpf.substringWithRange(Range(cpf.startIndex.advancedBy(10) ..< cpf.startIndex.advancedBy(11))))
@Godoy
Godoy / Steps.md
Last active June 20, 2017 21:38
deploy ruby on rails 4 with capistrano nginx unicorn - ubuntu 14.04

Steps

These steps were made with Ubuntu 14.04 e ruby 2.3.1. To enjoy the ease of step-by-step, I suggest not change folders and application name - just change the server ip and git

Create user to deploy

# Server console
sudo adduser deployer
sudo gpasswd -a deployer sudo
@NatashaTheRobot
NatashaTheRobot / WatchConnectivitySingletonDemo.swift
Last active December 29, 2022 14:44
WatchConnectivity Singleton Demo
//
// WatchSessionManager.swift
// WatchConnectivityDemo
//
// Created by Natasha Murashev on 9/3/15.
// Copyright © 2015 NatashaTheRobot. All rights reserved.
//
import WatchConnectivity
@ainsofs
ainsofs / gist:2b80771a5582b7528d9e
Created April 16, 2015 01:50
Clear .gitignore cache
# remove specific file from git cache
git rm --cached filename
# remove all files from git cache
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
@AliSoftware
AliSoftware / struct_vs_inheritance.swift
Last active March 27, 2024 11:57
Swift, Struct & Inheritance: How to balance the will of using Struct & Value Types and the need for Inheritance?
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/
@qmchenry
qmchenry / QButton.swift
Last active November 23, 2021 18:18
Swift UIButton subclass that implements toggle and backgroundColor for states
import UIKit
class QButton: UIButton {
var isToggle: Bool = false {
didSet {
if isToggle {
self.addTarget(self, action: Selector("touchUpInside:"), forControlEvents: .TouchUpInside)
} else {
self.removeTarget(self, action: Selector("touchUpInside:"), forControlEvents: .TouchUpInside)
}
@adamgibbons
adamgibbons / install-mongodb.md
Last active January 17, 2023 15:17
Install MongoDB on Mac OS X 10.9

Install MongoDB with Homebrew

brew install mongodb
mkdir -p /data/db

Set permissions for the data directory

Ensure that user account running mongod has correct permissions for the directory:

@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@steveliles
steveliles / Foreground.java
Last active January 22, 2024 18:06
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;