Skip to content

Instantly share code, notes, and snippets.

View ryankinal's full-sized avatar

Ryan Kinal ryankinal

View GitHub Profile
private void AddAccordionScript()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(" <script type='text/javascript'>");
sb.AppendLine(" var stop = false;");
sb.AppendLine(" $(\"#accordion h3\").click(function (event) {");
sb.AppendLine(" if (stop) {");
sb.AppendLine(" event.stopImmediatePropagation();");
sb.AppendLine(" event.preventDefault();");
sb.AppendLine(" stop = false;");
@ryankinal
ryankinal / lightbox.js
Created July 11, 2012 16:35
Really friggin' simple jQuery lightbox
$(function() {
var $blanket = $('#blanket'),
$close = $('#lightboxClose');
if ($blanket.size() === 0)
{
$blanket = $('<div />', {id: 'blanket'}).css({
'position': 'fixed',
'left': '0',
'top': '0',
@ryankinal
ryankinal / lightbox.js
Created July 11, 2012 16:39
POJS lightbox
/**
These two functions (addEvent and removeEvent) should be added to common.js
- they are generally useful functions that could be used across the entire site
when custom javascript is needed. The lightbox requires them for use.
**/
function addEvent( obj, type, fn )
{
if (obj.addEventListener)
{
obj.addEventListener( type, fn, false );
@ryankinal
ryankinal / chat.js
Created August 7, 2012 13:35
My chat script (client side)
/**
Chat: A factory for multi-room chat clients.
methods:
create(container, rooms)
- container is the ID of the element in which to build the chat interface
- rooms is either an encrypted enrollment ID or an array of room definitions
- returns a ChatClient (described below)
**/
@ryankinal
ryankinal / jquery-second-click.js
Created August 21, 2012 17:04
jQuery "second click" plugin
// Untested, off-the-cuff
$.fn.secondClick = function(handler)
{
var flag = false;
$(this).click(function(e) {
if (flag)
{
return handler(e);
flag = false;
@ryankinal
ryankinal / ideal-search-results.aspx.vb
Created September 10, 2012 18:46
current vs. ideal search results
' This is the ideal situation, where getting search results is abstracted
' The stored-proc code is instead moved to the Market class, and thus written only once
' no matter how many pages want this data
Dim searchMarket as New Market(licenseType, state) ' maybe with more arguments
Me.datalistCourses.DataSource = searchMarket.OnlineCourses() ' maybe with more arguments
@ryankinal
ryankinal / actual-event-data.txt
Created November 6, 2012 19:10
Differences between Stripe docs
Actual "Event" webhook return (partial, decoded to PHP stdClass)
stdClass Object
(
[type] => invoice.payment_succeeded
[livemode] => 1
[pending_webhooks] => 1
[object] => event
[created] => 1352226885
[id] => evt_0geUCmQmZaf2OD
@ryankinal
ryankinal / patterns.js
Created December 3, 2012 16:11
Some basic OO patterns for JS
// factory
var createObject = function(stuff) {
var obj = {};
obj.stuff = stuff;
obj.func = function()
{
return this.stuff + ' concatentation';
};
return obj;
@ryankinal
ryankinal / feedly.css
Last active October 14, 2015 00:08
My User Styles (for the Stylish Chrome plugin)
/*
Applies to: http://feedly.com/home*, http://www.feedly.com/home*
*/
body, #feedlyCenter
{
background-image: url(https://raw.github.com/ryankinal/mysubtlepatterns/master/debut_dark/debut_dark.png);
}
.area
{
@ryankinal
ryankinal / petals.js
Created December 18, 2012 20:06
Petals Around the Rose Game, played in the JavaScript console. `PetalsAroundtheRose.start()` to start. `PetalsAroundTheRose.answer()` to answer.
var PetalsAroundTheRose = (function() {
var sides = 6,
dice = 5,
currentRolls;
function getPetals(rolls)
{
var score = 0;
rolls.forEach(function(item) {
if (item === 3 || item === 5)