Some exercises from the Falsy Values workshops.
The good parts:
- HTTP server and client in same script
- Express cookies example
- Express routing example
- Express error handling
- Express middlewares example
- Simple HTTP proxy
| # In general, there are many places in the file where you can leave off the parens in function calls, if you like. | |
| unless typeof exports is "undefined" # `unless ... else` reads poorly in English. Better to stick to `if ... else`. | |
| Spine = exports | |
| else | |
| Spine = @Spine = {} | |
| Spine.version = "0.0.4" | |
| $ = Spine.$ = @jQuery || @Zepto || -> arguments[0] # In Coffee, `or` is preferred over `||`. |
Some exercises from the Falsy Values workshops.
The good parts:
| #!/bin/sh | |
| # | |
| # Script to prepare and restore full and incremental backups created with innobackupex-runner. | |
| # | |
| # This script is provided as-is; no liability can be accepted for use. | |
| # | |
| INNOBACKUPEX=innobackupex-1.5.1 | |
| INNOBACKUPEXFULL=/usr/bin/$INNOBACKUPEX | |
| TMPFILE="/tmp/innobackupex-restore.$$.tmp" |
| # vmc update is great for test and development, however it stops your old app and stages and starts the new one, | |
| # resulting in dropped requests. | |
| # If you want to update an application without dropping user requests, see below. | |
| # NOTE: This change assumes your application can share services, etc with the new version. | |
| # Assume my app is named foo | |
| vmc push foo-v2 --url foov2.cloudfoundry.com |
| JSpec.describe 'ShoppingCart', -> | |
| before_each -> | |
| cart = new ShoppingCart | |
| describe 'addProducts', -> | |
| it 'should add several products', -> | |
| cart.addProducts('cookie') | |
| cart.addProducts('icecream') | |
| expect(cart).to(have, 2, 'products') |
| sudo apt-get install lvm2 | |
| sudo apt-get install mylvmbackup | |
| jhannah@li202-203:~/src$ sudo mylvmbackup --socket=/home/cm_satin/mysql-repl/mysql.sock | |
| 20110304 23:19:14 Info: Connecting to database... | |
| 20110304 23:19:14 Info: Running hook 'preflush' as perl module. | |
| 20110304 23:19:14 Info: Flushing tables with read lock... | |
| 20110304 23:19:14 Info: Taking position record into /tmp/mylvmbackup-backup-20110304_231914_mysql-hfUKiZ.pos... | |
| 20110304 23:19:14 Info: Running: lvcreate -s --size=5G --name=data_snapshot /dev/mysql/data | |
| File descriptor 4 (socket:[113294]) leaked on lvcreate invocation. Parent PID 1669: /usr/bin/perl |
| #amazon ec2 image | |
| #ubuntu 10.10, 64bit | |
| #east-coast : ami-cef405a7 | |
| #west-coast : ami-af7e2eea | |
| #ssh to ec2 | |
| ssh -i <key-file>.pem ubuntu@<ip-address-to-ec2> | |
| #change ssh timeouts | |
| sudo vi /etc/ssh/sshd_config |
| // | |
| // Regular Expression for URL validation | |
| // | |
| // Author: Diego Perini | |
| // Created: 2010/12/05 | |
| // Updated: 2018/09/12 | |
| // License: MIT | |
| // | |
| // Copyright (c) 2010-2018 Diego Perini (http://www.iport.it) | |
| // |
| # RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
| # defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
| module Player | |
| describe MovieList, "with optional description" do | |
| it "is pending example, so that you can write ones quickly" | |
| it "is already working example that we want to suspend from failing temporarily" do | |
| pending("working on another feature that temporarily breaks this one") |
| 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 |