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 redis = require('redis'), | |
| client = redis.createClient(); | |
| var arr = ["some val","some val2","some val3"]; | |
| //Use multi() to pipeline multiple commands at once | |
| var multi = client.multi(); | |
| for (var i=0; i<arr.length; i++) { | |
| //console.log(arr[i]); | |
| //將一個或多個值value插入到列表key的表尾。 |
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 Penguin(name) { | |
| this.name = name; | |
| this.numLegs = 2; | |
| } | |
| // create your Emperor class here and make it inherit from Penguin | |
| function Emperor (name){ | |
| this.name = name; | |
| } |
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 kue = require('kue') | |
| , jobs = kue.createQueue() | |
| ; | |
| function newJob (name){ | |
| name = name || 'Default_Name'; | |
| var job = jobs.create('video conversion', { | |
| title: name + '\'s to avi', user: 1, frames: 200 | |
| }); |
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 async = require('async'); | |
| module.exports = function(app) { | |
| app.get('/get', function (req, res){ | |
| res.send('Got a GET request'); | |
| console.log(req.query); | |
| }); | |
| app.post('/post', function (req, res) { | |
| res.send('Got a POST request'); |
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 express = require('express'); | |
| var app = express(); | |
| app.get('/', function (req, res) { | |
| var q = req.query.q; | |
| res.send(q); | |
| }); |
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
| // Our Person constructor | |
| function Person (name, age) { | |
| this.name = name; | |
| this.age = age; | |
| } | |
| // Now we can make an array of people | |
| var family = new Array(); | |
| family[0] = new Person("alice", 40); | |
| family[1] = new Person("bob", 42); |
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
| //note: http://www.html-js.com/article/1961 | |
| // Function to download file using wget | |
| var download_file_wget = function(file_url) { | |
| // extract the file name | |
| var file_name = url.parse(file_url).pathname.split('/').pop(); | |
| // compose the wget command | |
| var wget = 'wget -P ' + DOWNLOAD_DIR + ' ' + file_url; | |
| // excute wget using child_process' exec function |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| var friends = {}; |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| var phonebookEntry = {}; |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <link type="text/css" rel="stylesheet" href="stylesheet.css"/> | |
| <title>Result</title> | |
| </head> | |
| <body> | |
| <h3>The Box Model</h3> | |
| <img src="http://s3.amazonaws.com/codecademy-blog/assets/ae09140c.png"/> | |
| <p>Image courtesy of www.w3.org!</p> |