Skip to content

Instantly share code, notes, and snippets.

@nifl
nifl / js-conditionals.md
Last active August 29, 2015 13:58
JS Conditionals

Conditionals

Conditionals execute certain code that meet specific conditions

Conditional Statements

If, Else

if (someColor == blue) {
@nifl
nifl / js-loops.md
Created April 3, 2014 17:57
JS Loops

Loops

While loops are initialized outside of the loop, eg in a var

var number = 0;
while (number < 10) {
    console.log(number);
    number++; // incrementer inside loop
}
@nifl
nifl / js-arrays.md
Created April 3, 2014 17:56
JS Arrays

Arrays

Arrays are data structures with automatically indexed positions. Array indices are zero–based.

Creating arrays

Literal notation

JSLint suggests literal notation for creating arrays and objects. Allows for initializing values.

@nifl
nifl / js-primitives.md
Created April 3, 2014 17:55
JS Primitives, Variables, and Operators

Primitives

  • String
  • Number
  • Boolean
  • Undefined
  • Null

Variables

@nifl
nifl / responsive.md
Last active August 29, 2015 13:57
Responsive notes

Viewport

Without viewport META tag the mobile browser will render desktop site.

Basic viewport declaration

<meta name="viewport">

<meta name="viewport" content="width=device-width">
@nifl
nifl / ghostinstall.md
Last active January 2, 2016 15:39
INSTALLING GHOST ON UBUNTU AND EC2 adapted from http://aexmachina.info/installing-ghost-on-ubuntu-and-aws-ec2/

PREREQUISITES

  • Node.js
  • Ruby
  • Bundler

GET GHOST

This one's pretty simple, just change directory to somewhere sensible and run the following commands:

dirName="my-blog"
@nifl
nifl / apache-tomcat-railo-multiweb.md
Last active December 27, 2015 14:59
Updated instructions on setting up multiple web instances of Railo 4 with Tomcat 7.0.42 and Apache on Mac OS 10.9. The original instructions appeared on Sean Corfields blog http://corfield.org/entry/Railo_on_Tomcat__multiweb and http://corfield.org/entry/Railo_for_Dummies_Part_IV_Appendix. Also credit to Jamie Krug for his updated post on proxyi…

Tomcat

In the Tomcat folder create a railo/ folder and copy in the contents of the unzipped Railo JARs ZIP file (or from the WEB-INF/lib/ folder of the unzipped Railo WAR file). In the Tomcat conf/ folder, edit catalina.properties and find the common.loader class path. We're going to add the Railo JARs to the common class path so that every web application can have Railo CFML pages. The new common.loader definition should look like this (all on one line, no spaces): common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/railo,${catalina.home}/railo/*.jar

Note: embedding Railo directly in Tomcat like this means that you will end up with a generated WEB-INF/ folder in each webroot, containing some Railo files (about 2MB).

Unless you're going to use the default web applications that come with Tomcat, this is a good time to empty the Tomcat webapps/ folder. You could create a default/ folder in the Tomcat folder and move everything from webapps/ to default/

@nifl
nifl / check_object_instance.md
Created November 26, 2012 20:17
It is NOT 'bad' to use the new keyword. But if you forget it, you will be calling the object constructor as a regular function. If your constructor doesn't check its execution context then it won't notice that 'this' points to different object (ordinarily

And yes, new has one crucial disadvantage, ably described by other answers: if you forget to use it, your code will break without warning. Fortunately, that disadvantage is easily mitigated - simply add a bit of code to the function itself:

function foo()
{
   // if user accidentally omits the new keyword, this will 
   // silently correct the problem...
   if ( !(this instanceof foo) )
      return new foo();

// constructor logic follows...

<!---
Name: intake_xml.cfm
Author: Gernot Bartels
Description: Intake Application cfsavecontent object
Returns new record or update data.
History: Created
Usage: Surveys, Intake,
Created: 2012-09-05
Updated: 2012-10-15
--->
@nifl
nifl / record.cfm
Created November 19, 2012 18:35
Queries QB for record object. If record ID exists, update; Otherwise create new record.
<!---
Name: record.cfm
Author: Gernot Bartels
Description: Queries QB for record object.
If record ID exists, update;
Otherwise create new record.
History: Created
Added logic
Usage: Surveys, Intake,
Created: 2011-08-05