Skip to content

Instantly share code, notes, and snippets.

View gavinengel's full-sized avatar

Gavin Engel gavinengel

View GitHub Profile
@gavinengel
gavinengel / intro.md
Created February 25, 2016 22:57 — forked from gschema/intro.md
Basic JavaScript MVC Implementation

Basic JavaScript MVC Implementation

Despite being derived from classical MVC pattern JavaScript and the environment it runs in makes Javascript MVC implementation have its own twists. Lets see how typical web MVC functions and then dive into simple, concrete JavaScript MVC implementation.

How Web MVC typically works

Typical server-side MVC implementation has one MVC stack layered behind the singe point of entry. This single point of entry means that all HTTP requests, e.g. http://www.example.com or http://www.example.com/whichever-page/ etc., are routed, by a server configuration, through one point or, to be bold, one file, e.g. index.php.

At that point, there would be an implementation of Front Controller pattern which analyzes HTTP request (URI at first place) and based on it decides which class (Controller) and its method (Action) are to be invoked as a response to the request (method is name for function and member is name for a variable when part of the class/object).

@gavinengel
gavinengel / node-and-npm-in-30-seconds.sh
Created December 8, 2015 18:49 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@gavinengel
gavinengel / tsv2csv.py
Last active January 27, 2017 17:10 — forked from nsonnad/tsv2csv.py
#!/usr/bin/env python
import sys
import csv
tabin = csv.reader(sys.stdin, dialect=csv.excel_tab)
commaout = csv.writer(sys.stdout, dialect=csv.excel)
for row in tabin:
commaout.writerow(row)
@gavinengel
gavinengel / dabblet.css
Created November 14, 2013 20:58 — forked from chriscoyier/dabblet.css
Checkbox Hack
/* Checkbox Hack */
input[type=checkbox] {
display: none;
}
label {
display: inline-block;
margin: 60px 0 10px 0;
cursor: pointer;
}
# I know it's an ugly, but it works for me. Complete installation process:
sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get update;
sudo apt-get install -y python-software-properties python g++ make;
### 'add-apt-repository' not available on my Ubuntu 12.10 by default, so the next line adds it.
### more info found here: http://stackoverflow.com/questions/13018626/add-apt-repository-not-found
sudo apt-get install software-properties-common -y;
###