Skip to content

Instantly share code, notes, and snippets.

View ef2k's full-sized avatar
💭
recalibrating

Eddie Flores ef2k

💭
recalibrating
View GitHub Profile
@ef2k
ef2k / ctags.setup
Created April 18, 2016 05:37 — forked from nazgob/ctags.setup
ctags setup on mac
# you have ctags but it does not work...
$ ctags -R --exclude=.git --exclude=log *
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
#you need to get new ctags, i recommend homebrew but anything will work
$ brew install ctags
#alias ctags if you used homebrew
$ alias ctags="`brew --prefix`/bin/ctags"
@ef2k
ef2k / gist:9334d563a550f23d9aaa
Created March 25, 2016 19:14
Updated way to launch chrome in insecure mode
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security --allow-running-insecure-content
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%an <%ae>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@ef2k
ef2k / pf_and_dns.markdown
Last active January 14, 2025 22:44
Port Forwarding and Domain Tricks (macOS High Sierra)

This guide enables port forwarding for foo.com to localhost:3000. Tested on macOS High Sierra.

Add the domain to /etc/hosts

$ sudo nvim /etc/hosts

Add the following:

@ef2k
ef2k / gist:697fb0df62532fc049bd
Created January 25, 2015 05:48
DOM Ready Pre IE8 Support (Vanilla JS)
document.attachEvent("onreadystatechange", function(){
if (document.readyState === "complete"){
document.detachEvent( "onreadystatechange", arguments.callee );
// code ...
}
});
For instance, to copy a file called rental_agreement.doc from our remote machine to a new file called agreement.doc on our local machine, we’d execute:
scp [email protected]:/Users/tandorra/Desktop/rental_agreement.doc agreement.doc
Obviously, the burden in this situation is knowing the exact location and name of the file before transferring it. Copying a file from your local machine to a remote one is a little easier. In that situation, we’d execute this command instead:
scp file-to-copy user@remote-address:path-to-new-saved-file
@ef2k
ef2k / sublime_3_link
Created January 24, 2015 09:27
Launch Sublime 3 from Terminal
@ef2k
ef2k / using_promises_in_your_asynchronous_code.md
Last active August 29, 2015 14:13
Using Promises in your Asynchoronous Code

Using Promises in your Asynchoronous Code

If you've written your share of JavaScript, you've likely encountered scenarios where independent asynchronous requests need to complete before execution can continue. In many cases, you're forced to impose an order to the requests and nest some callbacks to be notified of their completion. Another common, albeit dirty approach, is to pollute the parent scope of the events with flags of some sort and poll them on a particular time interval until completion.

In either case, maintainability becomes a nightmare and will likely cause future readers of your code to do an enormous amount of desk flipping.

Fortunately enough, we can dig into our bag of constructs and make use of what's commonly referred to as a promise, an abstract concept thats made its way into jQuery and has recently gained native support in modern browsers.

##Promises - A Brief Introduction ##

@ef2k
ef2k / gist:186ba26785a94ff26aba
Created December 7, 2014 08:46
Generate an SSL certificate
openssl genrsa -des3 -out fooboo.key 2048
openssl req -new -key fooboo.key -out fooboo.csr
openssl x509 -req -days 365 -in fooboo.csr -signkey fooboo.key -out fooboo.crt
@ef2k
ef2k / gist:0e567a1811a7dff8a893
Created November 3, 2014 03:22
Check DB Size
SELECT table_schema "DB Name", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" FROM information_schema.tables GROUP BY table_schema;