Skip to content

Instantly share code, notes, and snippets.

View ef2k's full-sized avatar
🏀

Eddie Flores ef2k

🏀
  • Brooklyn, NY
View GitHub Profile
@ef2k
ef2k / rowFilter
Created February 3, 2014 17:37
Row filtering
$('input.filter').live('keyup', function() {
var rex = new RegExp($(this).val(), 'i');
$('.searchable tr').hide();
$('.searchable tr').filter(function() {
return rex.test($(this).text());
}).show();
});
@ef2k
ef2k / favicon.ico
Created February 16, 2014 21:48
Favicon boom!
<link href="data:image/x-icon;base64,AAABAAEAEBAAAAAAAABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAD9/f0F/Pz8DP///wD///8P////Dv///xL///8P////A////wD///8A/v7+Cf///wX///8A////APv7+wr9/f0D+/v7Dv///wb///81+vv8i/v7/Iv3+PqL4+nxi+ru9JHy9Piu5+zzru3w9ZD+/v5x/v7+H////wr///8A9/f3H/7+/g7///8J////HNDX5Pyaq8j/m6zJ/5esy/+QpcX/larK/5uwzv+MoMH/mqrG/5qlv+7Q0Nty/f3+Af///wD///8A/v7+A////wz+/v6b2d/q/4abvf+Emr7/jKHD/5Gnyf+Uqsz/fpW5/4mXuP/U1OL/e3ui+MPE0l7///8A////AP///wD///8P////Xa680/9/lrr/kafJ/5yy0/+WrM7/nbPT/52uyv+ktM7/1NTi/8LC1f+lpr3n////AP///wD///8A////AP7+/mDo7PL/ytPi/5yv0fehsuXuuMvl0Kq81drS2uf8+/z9bff3+SG5uM1r8vL1ff///wD///8A////AP///wr+/v4H/v7+jufq8umIg/Sut7L9YKul/W7PzvlMnZn03Ozq/x/+/v4H////AP///wD///8A////AP///wD///8A5OH/IpuS/pF3cfPploz/hH5y/6F/dP+gl47/gkw++e7Hwv9Fta//XPj4/gf///8A////AP///wD///8A+vn/BoyB/pGlnf5vfHfxy4mA/JlIOf/lmZD+f1lK/89kWPrPmZD+f9zY/yu3sP5ar6j/ZP///wD///8A6uj/GbSt/l6imv9yVkf/1HBm+MJ5eOrlhX/1s2JY+dRpYPfPv7/zb4+F/41WR//Uloz/hI6E/47///8A////AOro/xmnn/9teW3/qH5y/6HKxf9B9/n7Fc3N9VfMyvlQraj
@ef2k
ef2k / gist:f8f9b5a1d689ac55e721
Last active August 29, 2015 14:01
Detect a Mobile Device (Taken from the interwebs)
// ORIGINAL:
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// some code..
}
// My helper property:
window._IS_MOBILE_DEVICE = (function () {
@ef2k
ef2k / stress.sh
Created September 24, 2014 15:16
Stress Test Script for Golang
#!/usr/bin/env bash -e
# Cool stuff from http://dave.cheney.net/2013/06/19/stress-test-your-go-packages
go test -c
# comment above and uncomment below to enable the race builder
# go test -c -race
PKG=$(basename $(pwd))
while true ; do

For Nick

Sample Data

I tried to copy your data model as I understood it. I created two User nodes each with five View nodes. User 1’s sequence of views touches a distinct set of Page nodes; User 2’s sequence of views is not a distinct set; User 2 visits the analytics page twice.

@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;
@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 / 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 / sublime_3_link
Created January 24, 2015 09:27
Launch Sublime 3 from Terminal
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 tandorra@10.0.1.5:/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