Skip to content

Instantly share code, notes, and snippets.

View rhyolight's full-sized avatar

Matthew Taylor rhyolight

View GitHub Profile
@rhyolight
rhyolight / testscript.js
Last active August 29, 2015 14:19
Example usage of github-data
var gdata = new GitData("username", "password", "organization", "repository");
/**
* Changing a file by committing directly to the master branch.
*/
gdata.getBranch("master", function(error, master) {
master.getFile("path/to/file", function(error, file) {
// Update something within the file.
file.contents = file.contents.replace("foo", "bar");
@rhyolight
rhyolight / NCLv1.0.txt
Last active August 29, 2015 14:21
NYAN CAT LICENSE V1.0
The Nyan Cat License (NCL) Version 1.0
Copyright (c) <year>, <copyright holders>
Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
@rhyolight
rhyolight / comma-first.js
Last active August 29, 2015 14:25
Comma-first vs not
// Comma-first
if (WHITELIST.indexOf(githubUser) > -1) {
return callback(null, {
state: 'success'
, description: githubUser + ' is whitelisted as a contributor.'
, target_url: 'https://github.com/' + githubUser
, whenComplete: function(foo, bar, cb) {
cb({
foois: foo
, baris: bar
@rhyolight
rhyolight / gist:51792
Created January 25, 2009 14:13
How Grails-UI turns groovy data structures into JavaScript data structures.
/**
* Turns map into a javascript config object string for YUI. This is what allows configurations passed into the
* grailsUI tag to be passed along to the YUI widget.
*/
def mapToConfig(attrs) {
attrs.collect { key, val ->
// if this is a handler, the val will be a javascript function, so don't quote it
if (key == 'handler') return "$key: $val"
"'$key': ${valueToConfig(val)}"
}.join(",\n")
@rhyolight
rhyolight / gist:52882
Created January 26, 2009 17:45
Making Grails-UI dataTable parent-child relationship
YAHOO.util.Event.onDOMReady(function() {
var childTableRenderCallback = {
success: function(o) {
if (o.responseText !== undefined) {
// kill off any existing data tables to manage memory
if (GRAILSUI.childTable != undefined) {
GRAILSUI.childTable.destroy();
}
var resultsDiv = document.getElementById('childPanel');
var renderChildTable = function(parentId) {
GRAILSUI.childTable.customQueryString = 'id=' + myParentId;
var newState = {
startIndex: 0,
sorting: { // Sort values
key: 'id', // or whatever you want the default sort on
dir: YAHOO.widget.DataTable.CLASS_ASC
},
@rhyolight
rhyolight / gist:54078
Created January 28, 2009 17:22
Grails-UI menubar example markup for version 1.1
<gui:menubar>
<gui:menuitem url='http://example.com'>Example</gui:menuitem>
<gui:submenu label='Foodstuffs'>
<gui:menuitem url='http://campbells.com'>Campbell's Soup</gui:menuitem>
<gui:menuitem url='http://cheetos.com'>Cheetos</gui:menuitem>
<gui:menuitem url='http://guiness.com'>Guiness</gui:menuitem>
</gui:submenu>
<gui:submenu label='Shoes'>
<gui:menuitem url='http://nike.com'>Nike</gui:menuitem>
<gui:menuitem url='http://reebok.com'>Reebok</gui:menuitem>
@rhyolight
rhyolight / gist:54094
Created January 28, 2009 17:27
Grails-UI example of a menu component
<gui:menu id='myMenu'>
<gui:menuitem url='http://example.com'>Example</gui:menuitem>
<!-- Grouped and titled -->
<gui:menugroup title='Foodstuffs'>
<gui:menuitem url='http://campbells.com'>Campbell's Soup</gui:menuitem>
<gui:menuitem url='http://cheetos.com'>Cheetos</gui:menuitem>
<gui:menuitem url='http://guiness.com'>Guiness</gui:menuitem>
</gui:menugroup>
<!-- Grouped, no title -->
<gui:menugroup>
@rhyolight
rhyolight / gist:54943
Created January 30, 2009 04:30
Grails-UI Pie Chart Example
<div id='pieChart' style="width:600px; height: 400px"></div>
<gui:pieChart
renderTo="pieChart"
data="[
[ response: 'Summer', count: 564815 ],
[ response: 'Fall', count: 664182 ],
[ response: 'Spring', count: 248124 ],
[ response: 'Winter', count: 271214 ],
[ response: 'Undecided', count: 81845 ]
@rhyolight
rhyolight / gist:54917
Created January 30, 2009 03:20
Grails-UI DataTable with inline cell editing
<gui:dataTable
draggableColumns="true"
id="dt_3"
columnDefs="[
[id:'ID', formatter:'text', sortable:true, resizeable: true],
[name:'Name', formatter:'text',
editor:[controller:'demo', action:'tableChange', config:[disableBtns:true]],
sortable:true, resizeable: true],
[birthDate:'Birth Date', formatter:'date',
editor:[controller:'demo', action:'tableChange', config:[disableBtns:true]],