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 npm-outdated-autoupdate-latest.sh
# 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
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) {
item.click();
}
}
}
console.log("Starting removing ads from facebook prefences!");
View Docker-sweets.md

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
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
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() {
super.viewDidLoad()
// --------------------------------------
//
@mayoralito
mayoralito / ssid-osx.sh
Created Oct 17, 2016
Getting SSID via command line
View ssid-osx.sh
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'
@mayoralito
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');
AWS.config.update({
accessKeyId: '{AWS_KEY}',
secretAccessKey: '{AWS_SECRET}',
region: '{SNS_REGION}'
});
var sns = new AWS.SNS();
View gist:ab40fc81e1b90eef563e8b62192ee2b2
# 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*
You can’t perform that action at this time.