Skip to content

Instantly share code, notes, and snippets.

Slack? Is that you?

amayoral mayoralito

Slack? Is that you?
Block or report user

Report or block mayoralito

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SwiftUI+HexColors.swift
//Trying out a prefix operator
//I thought vertical elipses made sense, representative of rbg
prefix operator
prefix func (hex:UInt32) -> Color {
return Color(hex)
extension Color {
init(_ hex: UInt32, opacity:Double = 1.0) {
let red = Double((hex & 0xff0000) >> 16) / 255.0
# Get all packages and save it to ENV variable
PACKAGES_TO_UPDATE=`npm outdated | awk '{print "npm install", $1"@latest", "--save; \n\r" }'`
# Save output to a location
echo $PACKAGES_TO_UPDATE > /tmp/npm-update-packages.log
# Open the file and remove the first line
# TODO: use awk to remove the first line of the file
vim /tmp/npm-update-packages.log
# Copy the content of the file and paste it on the terminal
# TODO: Create an script to get the output from npm outdated command and run the update against the latest version.
mayoralito / fb-ads-removal.js
Last active Jun 3, 2018
Facebook Scripting Tools
View fb-ads-removal.js
function removeAds() {
var allItems = document.querySelectorAll('._2b2e ._2b2p');
for (var item of allItems) {
var isAdEnabled = (item.getAttribute('data-tooltip-content').toLowerCase() == "remove");
if (isAdEnabled) {;
console.log("Starting removing ads from facebook prefences!");

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 \
View Extensions.swift
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) {
View Delayer.swift
* 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
mayoralito / NetworkHandler.swift
Created Nov 16, 2017
Basic usage of Router for Network calls
View NetworkHandler.swift
// Swift 3
// Alamofire 4
enum Router: URLRequestConvertible {
case updateUser(userId: Int, body:[String:Any])
var method: HTTPMethod {
switch self {
case . updateUser(_,_):
return .put
View ViewController-UICollisionBehaviorDelegate.swift
class ViewController: UIViewController {
var animator: UIDynamicAnimator!
var gravity: UIGravityBehavior!
var collision: UICollisionBehavior!
override func viewDidLoad() {
// --------------------------------------
mayoralito /
Created Oct 17, 2016
Getting SSID via command line
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'
mayoralito / aws-sns-example.js
Created Jul 24, 2016 — forked from tmarshall/aws-sns-example.js
aws-sdk sns example, in Node.js
View aws-sns-example.js
var AWS = require('aws-sdk');
accessKeyId: '{AWS_KEY}',
secretAccessKey: '{AWS_SECRET}',
region: '{SNS_REGION}'
var sns = new AWS.SNS();
You can’t perform that action at this time.