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 mqtt = require('mqtt'); | |
var port = 1883; | |
var host = 'localhost'; | |
var options = { | |
username: 'my_username', | |
password: 'my_password', | |
clientId: 'my_client_id' | |
}; | |
var client = mqtt.createClient(port, host, options); |
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
mkdir -p ~/Downloads | |
cd ~/Downloads | |
sudo yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker | |
wget -O v1.8.1.2.tar.gz https://github.com/git/git/archive/v1.8.1.2.tar.gz | |
tar -xzvf ./v1.8.1.2.tar.gz | |
cd git-1.8.1.2/ |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
/** | |
* extract host name from URL string. | |
*/ | |
function getHost(url) { | |
var m = url.match(/^https?:\/\/([^\/:\d]+)/); | |
return m && m[1]; | |
} | |
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
/** | |
* Simple template function. | |
* | |
* For each pattern in argument template, it is replaced with actual property from argument data. | |
* t('{greeting} world', {greeting: 'hello'}) === 'hello world' | |
* | |
* Sequence of property in argument data doesn't matter: | |
* t('{g} {x}', {g: '{o}', o: 'x'})) === '{o} {x}' | |
* t('{g} {x}', {o: 'x', g: '{o}'})) === '{o} {x}' | |
* |
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 | |
$arr = array( | |
'Color' => array('Red', 'Blue'), | |
'Size' => array('Regular', 'Large'), | |
'Material' => array('Metalic', 'Nylon') | |
); | |
function magic_algorithm($arr){ | |
function cartesian_product($arrays) { |
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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<title>Test</title> | |
<link rel="stylesheet" type="text/css" href="/yui/assets/yui.css?v=3" > | |
<script src="http://yui.yahooapis.com/combo?2.7.0/build/yahoo-dom-event/yahoo-dom-event.js"</script> | |
<!-- Browser History Manager source file --> | |
<style type="text/css" media="screen"> |
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 escapeHTML(s) { | |
return s.replace(/&/g, '&').replace(/>/g, '>').replace(/</g,'<').replace(/"/g, '"').replace(/'/g,''').replace(/\//g,'/'); | |
} |
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> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<title>MVC Demo</title> | |
</head> | |
<body> | |
{{name}} is {{title}}. | |
</body> | |
</html> |
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 foo = obj.foo; | |
obj.foo = function() { | |
// do something | |
obj.foo = foo; | |
obj.foo(arguments); | |
}; |
OlderNewer