Skip to content

Instantly share code, notes, and snippets.

View ryankinal's full-sized avatar

Ryan Kinal ryankinal

View GitHub Profile
him:
I just rick rolled javascript
it took me about 3 days
but victory is mine!
I thought you might appreciate that type of statement
me:
Er... what?
him:
@ryankinal
ryankinal / its-magic.md
Last active December 15, 2015 17:20
Magic is great. Except for when it doesn't work.

It's almost a comedy trope.

The amateur magician attempts an illusion in front of a large crowd, puts on a good show, and then fails miserably. He's boo'd off the stage, shamed and cowering from the cartoon-like rotten fruit and harsh words of his disappointed and angry audience. When magic doesn't work, it's a sad, frustrating, and disillusioning experience. Any suspension of disbelief disappears, as perhaps the original trick had intended something else to vanish.

And the same goes for "black box" solutions in development. They're fine until they don't work, at which point you have to dig into the abstraction to figure out why, and all the voluntary ignorance disappears. You suddenly find out what's inside the box, and it's nothing special.

It's not magic.

Depending on your abstraction, it might not even be good code.

@ryankinal
ryankinal / placeholders.js
Created March 27, 2013 14:39
Form placeholders
/* requires jQuery */
$(function() {
var submitting = false;
$('input').focus(function() {
var $this = $(this);
if ($this.data('placeholder') && $.trim(this.value) === $this.data('placeholder'))
{
if ($this.data('type') === 'password')
@ryankinal
ryankinal / brandon-catch.vb
Created March 21, 2013 14:48
Dammit, Brandon
Sub UserNameValidation(ByVal source As Object, ByVal args As ServerValidateEventArgs)
Try
Dim intUserID As Integer = common.getStudentIDFromUserName(Me.userNameTextBox.Text)
If intUserID <> 0 Then
args.IsValid = False
Else
args.IsValid = True
End If
Catch ex As Exception
@ryankinal
ryankinal / feedly-impressions.md
Last active December 15, 2015 04:59
Feedly first impressions

Since Google is killing Reader, I've been trying out Feedly. And on the surface, it looks slick. On top of that, it automatically syncs all my Reader stuff. Awesome feature.

However, there have been some issues.

Configuration

I like to be able to easily scan my list of feeds to see what's new. To facilitate this, I switched almost immediately to Feedly's "Titles" view. I tried this the first time from an on-feed settings menu, and I liked it, so I checked the Preferences page, and found that there was an option to set this view as the default on all feeds and categories. Great! :click:

But it didn't work. I still had the "Magazine" view on a few of my categories. I had to manually set these categories to use Titles. Bah.

@ryankinal
ryankinal / wtf-strlen.php
Created February 8, 2013 00:28
WTF strlen
<?php
// config file
define('STOP_MESSAGE', ' (txt "STOP" to cancel)');
// form handling
$length = 157 - strlen(STOP_MESSAGE) - strlen($keyword->getAttribute('word'));
$reply = isset($_POST['reply']) ? $_POST['reply'] : false;
if (strlen($reply) <= $length)
{
@ryankinal
ryankinal / being-programmers.md
Last active December 12, 2015 04:39
Being programmers

A common source of frustration in the web development community is programming done by non-programmers. There is plenty of code out there written by people who have little understanding of data structures, efficiency, and architecture, and that can be frustrating to those of us who have some training in those areas. When we're hired to work with this kind of system, we wonder how the hell it could have gotten to be like that.

Why on earth would someone store all that data in plain text? Why is the login system a flat file? Why is this web service one gigantic file? Why is everything so tightly coupled? This is miserable!

The cause is, often, that the people designing and building the system just didn't have the knowledge necessary to do it well. Maybe databases were foreign to them. Perhaps they had never heard of an event-based architecture, SOLID and DRY, or even taken a class in Object Oriented Programming (or whichever programming paradigm you prefer). And even if there is knowledge of these con

@ryankinal
ryankinal / blacklisted.md
Created February 1, 2013 14:33
From Arsenal Studios on Facebook

Well, that explains it.... (Why one of our cloud services up and stopped working out of nowhere).

"G'day Jake,

Should be fixed now- please try again. Issue was, we had blacklisted "arse" from being usable in the custom subdomain field (some time after you had chosen one, obviously, and in your case it's perfectly fine!).

Sorry for the inconvenience mate."

@ryankinal
ryankinal / illusion-of-class.html
Created January 29, 2013 17:17
Article on pseudo-classical pattern
<blockquote>This indirection was intended to make the language seem more familiar to classically trained programmers, but failed to do that, as we can see from the very low opinion Java programmers have of JavaScript. JavaScript's constructor pattern did not appeal to the classical crowd. It also obscured JavaScript's true prototypal nature. As a result, there are very few programmers who know how to use the language effectively.
~ Douglas Crockford, <a title="Douglas Crockford - Prototypal Inheritance" href="http://javascript.crockford.com/prototypal.html">"Prototypal Inheritance"</a></blockquote>
The indirection Mr. Crockford refers to here is the <em>Pseudo-Classical</em> <em>Pattern, </em>also known as the <em>Constructor Pattern</em>.<em> </em>This is a way of simulating classical inheritance in JavaScript - a prototypal language.<!--more-->
If it wasn't obvious from both the title of this post, and from the frankly negative quote above, this is not my favorite object-oriented pattern in JavaScript. I'
@ryankinal
ryankinal / useless.js
Created January 23, 2013 13:22
Recursive-descent parser to find the second occurrence of the string 'ABC' in a string.
var aPosition = -1,
position = 0,
count = 0,
desiredCount = 2,
string = 'XYZ 123 ABC 456 ABC 789 ABC',
tokens = string.split('');
var parse = function(tokens)
{
if (tokens[0] === 'A')