Skip to content

Instantly share code, notes, and snippets.

View greggnakamura's full-sized avatar

Gregg Nakamura greggnakamura

View GitHub Profile
@greggnakamura
greggnakamura / gist:d806336d8c0cebdc5f7e
Created February 1, 2015 20:02
Javascript: DOM level 0; Event Listeners (IE Legacy)
(function () {
// HTML items
// <button>Normal</button>
// <button>Changed</button>
// <a href="http://www.google.com">Google</a>
// <a href="http://www.google.com">Google</a>
var buttons = document.getElementByTagName('button');
@greggnakamura
greggnakamura / setInterval.js
Last active August 29, 2015 14:14
Javascript: setInterval example
(function () {
var speed = 500,
i = 0,
doSomething = function () {
console.log('doSomething() executed ' + (i + 1) + ' times');
i++;
if (i > 4) {
// stop when condition is met
@greggnakamura
greggnakamura / gist:f8eaf88411c7dd9e0b4a
Created January 3, 2015 22:14
Javascript: function example
/* functions */
/* passing a function as a parameter */
var calculate = function (number, paramTwo, fn) {
number = number + 3;
number = number + 1;
number = number * 8;
return fn(number, paramTwo);
};
@greggnakamura
greggnakamura / README.md
Last active November 14, 2015 00:27 — forked from hofmannsven/README.md
Git: Using Git
@greggnakamura
greggnakamura / gist:1e4ce72cbe5c5b402fb7
Last active August 29, 2015 14:07
Javascript: Namespacing with the Module Pattern
// http://javascriptweblog.wordpress.com/2010/12/07/namespacing-in-javascript/
/* Namespacing - The Module Pattern */
var myApp = (function () {
var id = 0;
return {
next: function () {
return id++;
},
@greggnakamura
greggnakamura / gist:fa3c88bbf1f311fb5cc2
Created September 9, 2014 04:52
Javascript: Self-invoking anonymous function example
// Immediately invoked function
// Code treated as local variables and functions
// Anonymous function, wrapped by a set of parenthesis, allows execution of anonymous function
(function () {
var foo = 'hello, window';
var bar = function () {
var foo = 'hello, function';
@greggnakamura
greggnakamura / codeeval.js
Last active August 29, 2015 14:05
CodeEval: FizzBuzz (Solved)
// user input
var input = '3 5 10\n2 7 15\n5 10 50';
// split on newline
var inputSplitOnNewLine = input.split('\n');
// get and set 'A', 'B', and 'N' values
// call fizzBuzz function
for (var i = 0; i < inputSplitOnNewLine.length; i++) {
var inputString = inputSplitOnNewLine[i]; // current 3 numbers
@greggnakamura
greggnakamura / gist:dc1500102a5020cd4a60
Last active August 29, 2015 14:05
jQuery: Bullet Proof
<script>
(function($) {
$(function() {
// place scripts here...
});
})(jQuery);
</script>
/*
(function($) {
@greggnakamura
greggnakamura / gist:1c7bbf56a431f8045466
Created July 22, 2014 03:51
CSS: Making Your Site Printable: CSS Summit 2014 - by Adrian Roselli, Founder, Web Developer at Algonquin Studios
/* Print Styles - http://www.slideshare.net/aardrian/css-summit-2014-making-your-site-printable */
/*
Resize type sizes to points, set text to black
- Points provide more consistent text size across browsers and devices
- Not all users have color printers.
Clear whitespace around content
- User's print settings will handle page margins
@greggnakamura
greggnakamura / gist:817caeda46d2c7ad1660
Last active April 6, 2021 20:41
Kentico: Misc examples
/* Transformation Examples */
// Ternary example
<%# !string.IsNullOrEmpty((string)Eval("ItemToTest")) ? "True" : "False" %>
<%# !String.IsNullOrEmpty(Eval("ItemToTest").ToString()) ? "True" : "False" %>
<%# !string.IsNullOrEmpty((string)Eval("CatalogLink")) ? "<p>For detailed curriculum and more, please visit the <a href=\"" + Eval("CatalogLink") + "\" target=\"_blank\">Course Catalog entry</a> for this program.</p>" : Eval("CatalogDescription") + "<br /><br /><strong>For detailed curriculum and more please visit the <a onclick=\"_gaq.push(['_trackEvent', 'Link', 'Click' 'Course Catalog Adult Education'])\" target=\"_blank\" href=\"" + Eval("CatalogLink") + "\">Course Catalog entry</a> for this program.</strong><br />" %>
<%# !String.IsNullOrEmpty(Eval("ScheduleOfBenefitsDownload").ToString()) || !String.IsNullOrEmpty(Eval("ProviderNetwork").ToString()) ? "<strong>Resources</strong><br>" : "" %>
/* ********** */