This file contains 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 | |
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
require_once(APPPATH.'libraries/REST_Controller.php'); | |
class Wget extends REST_Controller { | |
/** | |
* 影片下載api | |
* @access public | |
*/ | |
function index_post() |
This file contains 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 | |
$fileUrl = 'https://googledrive.com/host/0B8p3dPzRohcndXRaNm1OamFXUUE'; | |
$postArr = array( | |
"fileurl"=>$fileUrl,"btype"=> '360p,720p', | |
"recipient"=>'http://php/httpreq/jsonrep.php' | |
); | |
$options = array( | |
CURLOPT_POSTFIELDS => http_build_query($postArr), |
This file contains 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 request = require('request'); | |
var options = { | |
uri: 'https://www.googleapis.com/urlshortener/v1/url', | |
method: 'POST', | |
json: { | |
"longUrl": "http://www.google.com/" | |
} | |
}; |
This file contains 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
require('./waterfallexports')(req.body, function (result) { | |
console.log('[router] '+result); | |
}); |
This file contains 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 url = require("url"); | |
exports.fun = function (postReq, my_callback){ | |
var fileName = url.parse(postReq.fileurl).pathname.split('/').pop(); | |
my_callback('fileName=' + fileName); | |
} |
This file contains 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 cashRegister = { | |
total:0, | |
add: function(itemCost){ | |
this.total += itemCost; | |
}, | |
scan: function(item, quantity) { | |
switch (item) { | |
case "eggs": this.add(0.98 * quantity); break; | |
case "milk": this.add(1.23 * quantity); break; | |
case "magazine": this.add(4.99 * quantity); break; |
This file contains 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 cashRegister = { | |
total:0, | |
add: function(itemCost){ | |
this.total += itemCost; | |
} | |
}; | |
//call the add method for our items | |
var items = [0.98, 1.23, 4.99, 0.45]; |
This file contains 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 basic( callback ){ | |
console.log( '作些事情' ); | |
var result = '我是等會要被傳送給 `do something` 的 callback 的函式結果'; | |
// 如果 callback 存在的話就執行他 | |
callback( result ); | |
} | |
basic( function( result ){ |
This file contains 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(); | |
client.on("error", function (err) { | |
console.log("Error " + err); | |
}); | |
client.set("string key", "string val", redis.print); //Reply: OK | |
client.hset("hash key", "hashtest 1", "some value", redis.print); //Reply: 0 | |
client.hset(["hash key", "hashtest 2", "some other value"], redis.print); //Reply: 0 |
This file contains 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 Person(first,last,age) { | |
this.firstname = first; | |
this.lastname = last; | |
this.age = age; | |
var bankBalance = 7500; | |
this.getBalance = function() { | |
// your code should return the bankBalance | |
return bankBalance; | |
}; |