Skip to content

Instantly share code, notes, and snippets.

View hatched's full-sized avatar

Jeff Pihach hatched

View GitHub Profile
var http = require('http'),
util= require('util');
var req = http.get('http://www.reddit.com/r/golang.json', function(res) {
var body = "";
if (!/^2[0-9]{2}$/.exec(res.statusCode)) {
console.log(res.statusCode);
}
package main
import (
"io"
"log"
"net/http"
"os"
)
func main() {
MyClass = {
makeIOCall: function(url) {
Y.io(url, {
on: {
success: this.successHandler
}
}
}
@hatched
hatched / plugin.js
Last active December 16, 2015 15:59
YUI.add('testplugin', function(Y) {
var MyPlugin = Y.Base.create('testplugin', Y.Plugin.Base, [], {
initializer : function() {
this.objectProperty = {
def1: "foo",
def2: "bar"
}
initializer: function(cfg) {
// service model promise
cfg.service.then(
Y.bind(this.serviceDataReceived, this),
Y.bind(this.noServiceAvailable, this));
this.after('modelChange', function() {
this.render();
}, this);
},
// Modules included onto the page here
var yui;
YUI().use('/*module names*/', function(Y) {
yui = Y;
});
@hatched
hatched / index.js
Last active December 12, 2015 06:48
IE10 Conditional
<!--[if !IE]><!--><script> // If It's not IE (or <IE10)
if (/*@cc_on!@*/false) { // If cc_on exists then if (!false)
document.documentElement.className+=' ie10'; // Add classname to element
}
</script><!--<![endif]-->
// http://msdn.microsoft.com/en-us/library/8ka90k2e%28v=vs.94%29.aspx
// Taken from http://www.impressivewebs.com/ie10-css-hacks/
@hatched
hatched / main.js
Created January 23, 2013 05:05
Requiring a non js file for a module with YUI Loader
YUI({
modules: {
'mytext': {
fullpath: 'mytext.txt'
},
'mymodule': {
fullpath: 'mymodule.js',
requires: 'mytext'
}
}
YUI({
modules: {
'module1': {
path: 'path/to/module1.js',
requires: ['modules', 'this', 'requires']
}
}
}).use('node', function(Y) {
//module1 is not loaded
npm install lactate