This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
http = require('http'), | |
port = 8080; | |
http.createServer(function (req, res) { | |
fs.readFile(__dirname + '/../public' + req.url, function (err,data) { | |
if (err) { | |
res.writeHead(404); | |
res.end(JSON.stringify(err)); | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Numerically Indexed Arrays | |
*/ | |
// 1. create an array of the following words (each word being it's own element): Array is a useful data structure | |
// 2. loop through your array using a for loop and add each word to $sentence (seperated by a space) | |
$sentence = ""; | |
// loop here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CRUD(name){ | |
this.table = name; | |
var dsn = "postgres://username:password@localhost/database"; | |
this.db = new pg.Client(dsn); | |
} | |
CRUD.prototype = { | |
query: function(query){ | |
return this.db.query(query); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.addEventListener('fetch', function(event) { | |
event.respondWith( | |
new Response({ | |
body: 'This came from the service worker!' | |
}) | |
); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$upper_limit = 100; | |
$sum = 0; | |
// loop from 1 to 100 | |
// syntax: for ( initialize loop variable(s); condition to continue looping; code to run on each loop iteration ) | |
for($num = 1; $num <= $upper_limit; $num++){ | |
// if the remainder of number / 3 or number / 5 is 0, add to sum | |
if($num % 3 == 0 || $num % 5 == 0){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/ab/:id', function(req, res){ | |
res.json({ | |
routes: { | |
// add new route (page) at #page/about | |
'page/about': [{ | |
// from the shared components (app/shared/views) use Header and HTML in the page | |
shared: [{ | |
name: 'Header', | |
slot: 'page-header', | |
config: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['Module', 'models/Comment', 'jsx!app/comments/views'], function(Module, CommentCollection, Components){ | |
"use strict"; | |
var mountNode = $('#main-content'); | |
var routes = { | |
// this is our base view #comments/ | |
'': function(){ | |
this.views.push(new Components.CommentList({ | |
el: mountNode, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var html = '<div id="yelp-reviews" style="position:fixed;top:120px;right: 0px;border-left: 1px solid #ccc;padding-left: 0px;width: 200px;background-color: #fff;z-index: 9999;min-height: 180px;margin-left: 0px;border-bottom: 1px solid #ccc;border-radius: 5px;">\ | |
<h3 style=";margin-bottom: 5px;font-weight: bold;background: url(http://s3-media3.ak.yelpcdn.com/assets/2/www/img/a3283cdf84a4/developers/header_sprite.png);height: 75px;"></h3>\ | |
<div style="padding-left: 10px;">\ | |
<input type="search" placeholder="search term" id="yelp-search"><button style="margin-bottom:10px;" id="yelp-search-go">Go</button>\ | |
<ul id="yelp-search-results" style="list-style:none;max-height: 200px;overflow-y: scroll;border-top:1px solid #ccc"></ul>\ | |
</div>\ | |
</div>'; | |
$('body').append(html); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// attach a keyup event to our text field | |
$('#dev-table').on('keyup', function(e){ | |
// make sure the "no results" message isn't showing from a previous search | |
$('.filterTable_no_results').remove(); | |
// cache our reference to the search element | |
var $this = $(this), | |
// get the value typed and convert to lower case | |
search = $this.val().toLowerCase(), | |
// get the selector of the table we will be filtering, (the data="#selector" attribute of our text input) | |
target = $this.data('filters'), |