Skip to content

Instantly share code, notes, and snippets.

View mayoralito's full-sized avatar
:octocat:
This is the way!

amayoral mayoralito

:octocat:
This is the way!
View GitHub Profile
@mayoralito
mayoralito / fuckingblocksyntax.swift
Last active September 2, 2015 15:16
fuckingblocksyntax.com using Swift
// As a local variable:
// Objective C - http://fuckingblocksyntax.com/
returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};
As a property:
// Swift -
@mayoralito
mayoralito / squid.conf
Last active October 17, 2016 14:26
squid configuration file.
acl localnet src 192.168.0.0/16 # RFC 1918 local private network (LAN)
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
@mayoralito
mayoralito / gist:ab40fc81e1b90eef563e8b62192ee2b2
Created April 23, 2016 20:49 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@mayoralito
mayoralito / aws-sns-example.js
Created July 24, 2016 14:30 — forked from tmarshall/aws-sns-example.js
aws-sdk sns example, in Node.js
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: '{AWS_KEY}',
secretAccessKey: '{AWS_SECRET}',
region: '{SNS_REGION}'
});
var sns = new AWS.SNS();
@mayoralito
mayoralito / ssid-osx.sh
Created October 17, 2016 14:21
Getting SSID via command line
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'
class ViewController: UIViewController {
var animator: UIDynamicAnimator!
var gravity: UIGravityBehavior!
var collision: UICollisionBehavior!
override func viewDidLoad() {
super.viewDidLoad()
// --------------------------------------
//
@mayoralito
mayoralito / NetworkHandler.swift
Created November 16, 2017 00:57
Basic usage of Router for Network calls
// Swift 3
// Alamofire 4
enum Router: URLRequestConvertible {
case updateUser(userId: Int, body:[String:Any])
var method: HTTPMethod {
switch self {
case . updateUser(_,_):
return .put
/**
* MIT License
*
* Copyright (c) 2017-present, Adrian Mayoral.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
import UIKit
// MARK: - UIColor
extension UIColor {
static func rbg(r: CGFloat, g: CGFloat, b: CGFloat) -> UIColor {
return UIColor(red: r/255, green: g/255, blue: b/288, alpha: 1)
}
convenience init?(hex: String, alpha: CGFloat = 1.0) {

Run nginx with docker (Basic Config)

docker run -d -p 1234:80 \
-v /Users/{username}/local/path1/:/usr/share/nginx/html/ \
-v /Users/{username}/local/path2/:/usr/share/nginx/html/subpath1 \
-v /Users/{username}/local/path3/:/usr/share/nginx/html/subpath2 \
-v /Users/{username}/local/pathN/:/usr/share/nginx/html/subpath2/subfolder \
--name webserver \
nginx