Skip to content

Instantly share code, notes, and snippets.

View fdocr's full-sized avatar
🤓

Fernando Valverde fdocr

🤓
View GitHub Profile
docker-machine create --driver amazonec2 \
--amazonec2-instance-type t2.nano \
--amazonec2-region eu-west-1 \
node-name
@fdocr
fdocr / admin.sh
Last active August 31, 2016 12:31
Misc linux/unix administrative commands
# Give ownership of directory to user/group
sudo chown -R <user>:<group> directory
sudo chown -R :<group> directory
sudo chown -R <user>: directory
# Add user to group
sudo usermod -a -G groupName userName
// LTS = v4.x, change accordingly
curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
@fdocr
fdocr / Docker - Remove dangling images
Last active August 27, 2016 21:25 — forked from anildigital/gist:862675ec1b7bccabc311
Remove dangling docker images
docker rmi $(docker images -q -f dangling=true)
@fdocr
fdocr / readme.md
Created August 27, 2016 21:26 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@fdocr
fdocr / UIView+FindSuperviewWithClass.swift
Created August 30, 2016 20:05
Extension for a UIView to find the first superview matching a certain class (or nil)
import UIKit
extension UIView {
func findSuperviewWithClass<T>(superViewClass : T.Type) -> UIView? {
var xsuperView : UIView! = self.superview!
var foundSuperView : UIView!
while (xsuperView != nil && foundSuperView == nil) {
if xsuperView.self is T {
foundSuperView = xsuperView
@fdocr
fdocr / network.sh
Last active December 13, 2018 01:58
Misc network related terminal commands
# Resolve DNS
nslookup
# List of open internet connections established
# lsof is much more general purpose
lsof -i | grep -E "(LISTEN|ESTABLISHED)"
# Monitor network traffic & connections
nettop
@fdocr
fdocr / delay.swift
Created September 3, 2016 01:10
Delay function in ms
// Delay function expressed in ms
func delay(delay:Double, closure:()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * 1000000.0)
),
dispatch_get_main_queue(), closure)
}
@fdocr
fdocr / print-fonts.swift
Created September 8, 2016 15:17
Useful for looking up font names added to a project
for family: String in UIFont.familyNames() {
print("\(family)")
for names: String in UIFont.fontNamesForFamilyName(family) {
print("== \(names)")
}
}
@fdocr
fdocr / git.sh
Created September 8, 2016 21:43
Useful git commands to remember
#Remove staged file
git reset HEAD -- path/to/file
#Remove all staged files
git reset HEAD -- .
#Delete local branch
git branch -d branch_name
#Delete remote branch