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
<!doctype html> | |
<html ng-app="Demo"> | |
<head> | |
<meta charset="utf-8" /> | |
<title> | |
Creating A RequireJS Service For AngularJS | |
</title> | |
<style type="text/css"> |
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
## Configure eth0 | |
# | |
# vi /etc/sysconfig/network-scripts/ifcfg-eth0 | |
DEVICE="eth0" | |
NM_CONTROLLED="yes" | |
ONBOOT=yes | |
HWADDR=A4:BA:DB:37:F1:04 | |
TYPE=Ethernet | |
BOOTPROTO=static |
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
/** | |
* Encodes multi-byte Unicode string into utf-8 multiple single-byte characters | |
* (BMP / basic multilingual plane only). | |
* | |
* Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars. | |
* | |
* Can be achieved in JavaScript by unescape(encodeURIComponent(str)), | |
* but this approach may be useful in other languages. | |
* | |
* @param {string} strUni Unicode string to be encoded as UTF-8. |
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
# Change YOUR_TOKEN to your prerender token | |
# Change http://example.com (server_name) to your website url | |
frontend my-frontend | |
mode http | |
bind :80 | |
# prerender.io | |
acl user-agent-bot hdr_sub(User-Agent) -i baiduspider twitterbot facebookexternalhit rogerbot linkedinbot embedly showyoubot outbrain pinterest slackbot vkShare W3C_Validator | |
acl url-asset path_end js css xml less png jpg jpeg gif pdf doc txt ico rss zip mp3 rar exe wmv doc avi ppt mpg mpeg tif wav mov psd ai xls mp4 m4a swf dat dmg iso flv m4v torrent ttf woff |
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
module.exports = { | |
/** | |
* | |
* Using raw socket.io functionality from a Sails.js controller | |
* | |
*/ | |
index: function (req,res) { |
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
// dual-module.js | |
var Q = require('q'); | |
module.exports = { | |
getFullName: function (firstName, lastName, callback) { | |
var deferred = Q.defer(); | |
if (firstName && lastName) { | |
var fullName = firstName + " " + lastName; | |
deferred.resolve(fullName); |
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
// Pattern | |
//Usually, you call a callback as the last thing you do inside a function. | |
//You might consider it synonymous with return, only JavaScript does | |
//not halt function execution when it hits it. It can be easy to accidentally | |
//let execution continue after calling a callback, when you really expected it to end. | |
//In order to make this easy to spot, and make sure execution stops in the way you expect, | |
//I recommend returning the callback function call. | |
// wrong! |
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 async = require('async'); | |
async.waterfall( | |
[ | |
function(callback) { | |
callback(null, 'Yes', 'it'); | |
}, | |
function(arg1, arg2, callback) { | |
var caption = arg1 +' and '+ arg2; | |
callback(null, caption); |
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
//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 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
module.exports = { | |
get: function (req, res) { | |
res.sendfile(req.path.substr(1)); | |
}, | |
_config: { | |
rest: false, | |
shortcuts: false | |
} | |
}; |
OlderNewer