Skip to content

Instantly share code, notes, and snippets.

View andersr's full-sized avatar
😅
Focusing

Anders Ramsay andersr

😅
Focusing
View GitHub Profile
@andersr
andersr / var_check.js
Created October 7, 2016 12:58
JS check if undeclared, undefined or null
//check if undeclared
try{
undeclaredVar
}
catch(e) {
if(e.name === 'ReferenceError') {
console.log('var is undeclared')
}
}
@andersr
andersr / gulp_4_warning.sh
Created August 13, 2016 15:20
Warning displayed when ending Gulp 4 script
[10:38:59] The following tasks did not complete: default, <parallel>, watch:styles, watch:views, browser-sync
[10:38:59] Did you forget to signal async completion?
LogdTags = {
getTags : function(str) {
var tags = [];
var hashTagPattern = /#[A-Za-z0-9_]*/gi;
tags = _.map(
// 1. find all matches for '#foo' in str

Instructions for building this Meteor CRUD app, a basic app for teaching Meteor basics.

Step 0: Create app/basic dev setup

  • Run git clone [email protected]:andersr/meteor_crud from your terminal, followed by cd meteor_crud
  • Open the current directory in a text editor (eg using edit .)
  • (If you were creating this app from scratch, you would simply have typed meteor create app in this directory.)
  • Cd into the "app" directory and run meteor from the command line.
  • Open a browser window and enter the URL: http://localhost:3000
  • Leave this window open while building the app. Meteor will auto-refresh as you make changes.
  • Why have your app in an "app" sub-directory? Making your app a sub-directory of your working directory allows for making external files, such as config files, build files, etc, be part of your repo without being mixed in with actual app files.
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">My Topics App</a>
@andersr
andersr / intro_to_meteor_js.md
Last active November 5, 2015 21:12
Meteor Resources
@andersr
andersr / index.html
Last active August 29, 2015 14:27 — forked from anonymous/index.html
JS Bin // source http://jsbin.com/kagaxusuho
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
@andersr
andersr / crackle_pop.rb
Last active August 29, 2015 14:27
A program that prints out the numbers 1 to 100 (inclusive). If the number is divisible by 3, print Crackle instead of the number. If it's divisible by 5, print Pop. If it's divisible by both 3 and 5, print CracklePop.
(1..100).each do |number|
if (number % 3 == 0) && (number % 5 == 0)
puts "CracklePop"
elsif number % 3 == 0
puts "Crackle"
elsif number % 5 == 0
puts "Pop"
else
puts number
@andersr
andersr / generate_token_id.rb
Created March 22, 2015 14:31
Generate token id
before_save :generate_token_id
def to_param
token_id
end
protected
def generate_token_id
begin