Skip to content

Instantly share code, notes, and snippets.

@josephmosby
josephmosby / gist:4264437
Created December 12, 2012 02:49
Week Two of Ruby on Rails: The Incredible Power of Rails

I have now hit my first "wow" moment with Rails, where I actually understood why it has the following it does. It has raised some questions for me about the pedagogy of Rails, but that is not the language's fault; it is a question for the community.

Rails is fast. Mind-blowingly fast. From my cursory looks at the framework, it is immediately apparent that this was designed from the ground up to give me everything I'm going to inevitably want in a basic web application. And yet, for some reason, it isn't immediately sold that way. It's instead sold with stuff like...

"I'm not even joking when I say this, but I think some of the resources out there make it intentionally hard for non-technical people to start learning."

The above line was from a class on Rails - not a Ruby class, but a Rails class. The class was designed so that you could have no coding experience whatsoever and build an MVP, and it advertises itself as such. I think learning to code, even at the lowest level of difficulty, is a fantast

@josephmosby
josephmosby / gist:4297129
Created December 15, 2012 16:59
Week Two of Ruby on Rails: Layouts, Templates, Views, oh my!

One of my first projects as a Ruby/Rails programmer is simply getting static pages served on Heroku. That's it. Nothing fancy. I know that some would argue that I should be coming up with an "application," and I'm getting there. A friend had an immediate need to roll his static page over to Rails as he began to plan for more functionality, and I was happy to help to get some practice.

A few things pop into my head here. I have only been programming in Ruby/Rails for two weeks now, and that has been at night after the day job. I haven't even been fully invested in it each and every night, and yet I still feel like I'm growing in proficiency fairly quickly. Rails has its own set of frustrations - but 90% of the time, I feel like this is just how things should be DONE.

However....

Rails is an opinionated framework. It has a prescribed way of doing things, and it doesn't quite care if you don't want to do things that way. I still have no idea how I would di

Dealing with Spreadsheets in Python

A friend recently came to me with a data management problem. He has a stack of Excel spreadsheets that need to be turned into an API, which means that the data is going to have to be dumped out of those spreadsheets and inserted into a database. I haven't seen the data yet, so I can't make a recommendation on how we should tackle it - but I have some ideas.

Option 1: Export to Access

Microsoft Excel actually provides a really nice integration with Access, and Access allows you to set up data extracts that can be loaded into your data storage mechanism of choice. This is easily the most "point-and-click" method for approaching this task if you're of the GUI persuasion. The "External Data" tab of your Microsoft Access database will have everything you need to import and export your data, if you'd prefer to use this method. Given the quality of the wizards available to help you, I won't be discussing this one much.

Option 2: Work with CSVs

Teaching Code to Artists, Round 2

In our earlier lesson, we discussed the basics of the web and how pages can be modified in-line as an introduction to programming for our hypothetical student. It's now time to expose a little bit more of the underbelly of the internet.

In this lesson, we want to walk the student through the construction of an HTML document and demonstrate how these elements are represented within the browser. Our student is starting to grasp the idea that data is delivered via the Internet to their browser, so we need to show them that they can build this very same data themselves. Let's start things off slowly:

<html>

</html>

The Curious Case of the Paralyzed Man and the Password Manager

To the system engineer, "accessibility" represents a set of user stories for an end user who cannot, for reasons unrelated to intentionally-designed security, access all application functionality. An individual who cannot see will have issues reading a system screen, and must use some sort of technology to have a screen translated into an audio format. An individual who cannot hear cannot make use of training materials with a voiceover. These user stories are often not initially considered by the system engineer, who is generally restricted by deadlines and must consider only the functionality that he requires to test the application as well as the requirements of his direct customer. Though these combined requirements may ultimately satisfy 99% of the application's end users, the final 1% presents an interesting challenge for the engineer.

I came across a thread on Hacker News posted by a quad

In our most recent exercise, we explained the basic structure of a web page to our hypothetical student. By doing so, we presented static content to our student. It's now time for us to introduce the basics of dynamic content to our student by introducing some basic JavaScript.

Let's start again with our HTML document from before:

	<head>
		<title>This is our first web page!</title>
	</head>
@josephmosby
josephmosby / drupal6dbsurgery.md
Created September 9, 2013 20:41
A brief description of some database surgery on theme files in Drupal 6.

Theme Database Surgery with Drupal 6

Occasionally a Drupal 6 theme will refuse to budge, despite any attempts to force a theme update. I came across this problem while attempting to modify my theme.info file to add a few additional JS files. Saving the theme configuration did not work, nor did clearing the database cache.

The following step did work, however:

  1. Access the database through phpmyadmin. Theme information is stored in the 'system' table with a type of 'theme.'
  2. Hunt down the theme entry in question.
  3. Edit the theme's info. This JSON entry is architected in the following manner: a. Keys with the type "a:x" where x is an integer indicate the number of entries in the following hash table.
@josephmosby
josephmosby / footer_drop.js
Created November 20, 2013 21:16
Drop a footer to the bottom of the page
@josephmosby
josephmosby / checkwidth.js
Created November 21, 2013 21:08
Adjust menus to be table-cell or inline-block depending on height
function checkWidth() {
var windowSize = jQuery(window).width();
if (windowSize > 660) {
jQuery("#main-menu").css('display', 'table-row');
jQuery("#main-menu li").css('display', 'table-cell');
} else {
jQuery("#main-menu").css('display', 'inline');
jQuery("#main-menu li").css('display', 'inline-block');
}
}
@josephmosby
josephmosby / app.js
Created August 26, 2014 20:15
IE 10 and 11 targeting
jQuery(document).ready( function() {
var doc = document.documentElement;
doc.setAttribute('data-useragent', navigator.userAgent);
});