Skip to content

Instantly share code, notes, and snippets.

View OscarGodson's full-sized avatar
:shipit:
Workin'

Oscar Godson OscarGodson

:shipit:
Workin'
  • CTO
  • Portland, OR
  • 02:57 (UTC -08:00)
View GitHub Profile
@OscarGodson
OscarGodson / checkHTML5FormSupport.js
Created December 20, 2011 22:33
Checks for HTML5 Form support in both the supported attributes and possible values of the "type" attribute
/**
* Checks for HTML5 Form support in both the supported attributes and possible values of the "type" attribute
* @returns {object} Returns an object containing a boolean for each check.
*/
function checkHTML5FormSupport(){
var tester = document.createElement('input');
var results = {attr:{},type:{}};
//Check for supported form attributes
var attrs = [
@OscarGodson
OscarGodson / addNumSuffix.js
Created December 21, 2011 19:52
Will append the right suffix to a number (ex: 122 becomes 122nd)
/**
* Will append the right suffix to a number (ex: 122 becomes 122nd)
* @param {String|Number} Any number given as a string or an int
* @returns {String} The given number with a suffix
*/
function addNumSuffix(number){
if(typeof number === 'number'){
number = number.toString();
}
var lastNum = number.charAt(number.length-1) //Gets the last number in the string (ex: 112 will 2)
@OscarGodson
OscarGodson / raveGen.js
Created January 12, 2012 20:00
creates a rave on a website
setInterval(function(){document.body.style.background="#"+Math.random().toString(16).slice(2,8)},50);

#You're Doing it Wrong

On G+ a couple days ago I read a post by João Saleiro which basically slams JavaScript and HTML5 and claims Flex is far superior, and you know what? It very well could be because I've never used Flex. I constantly hear and experience bad things about Flash, but I don't know what it's like to develop on the platform. However, I do know my language, JavaScript which he makes incredibly outrageous and false claims about it for whatever reason.

When I pointed a portion of these out and explain the falsehood of them he asks me why I'm making this a "religious war". Well, I'll tell you why. JavaScript has been a plaything of a language for over a decade. It's taken us JavaScript engineers a very long time to be taken seriously. To this day it's still rare to have a job title like mine which is "JavaScript Engineer". It's usually "front-end engineer" or somethin

Step 1:
User would have to want to download a web page. I can't imagine any user downloading a web page, but even if they did, it'd have to be important/cool enough to download the .html file which not a lot of malicious web pages are, but lets say they did...

Step 2:
The user would have to have downloaded other web pages that make use of localStorage

Step 3:
User would have to put "important" information into pages from Step 2.

I can't think of any instance ever where some developer would have a user download a web page and fill out important information into the localStorage object. That'd be a pain to send back (yes, you can use hacks with ``s) and worthless. It'd be more beneficial to have a offline web app or have a form or something like that in an iframe why would a developer make it hard for himself to get information from a user?

#Thoughts on Raven.io

My friend on Twitter Sam Howat tagged me and Sebastian Nitu in a post of him sharing http://raven.io which looked pretty cool so I checked it out. After getting past the fact they ripped Twitter's native Mac app design I tried it out first by installing the Google+ app. Here are my thoughts...

First, I did like the idea that each app had a native navigation on the sidebar. This could be great for some apps, like say, the Twitter web app where you have it just like the native one, timeline, @mentions, PMs, etc.

I also liked that as a developer and a user you could get push notifications and iCloud sync on web apps that supported those with Raven.io

But, the fact of the matter is, it's just a browser with big bookmarks. Unlike Chrome, you can't even really install apps. For example, TweetDeck, Awesome Screenshot, and others on Chrome's Web App Store are actually installed. There's no URL. If I want a native app, I don't wan

function genproj {
mkdir $1
cd $1
mkdir js
mkdir css
mkdir images
touch index.html
echo -e "<!DOCTYPE html>\n<html>\n <head>\n <title>$2</title>\n </head>\n <body>\n \n </body>\n</html>" >> index.html
subl .
}
@OscarGodson
OscarGodson / demo.html
Created February 25, 2012 02:03
Send mail via JS and JSONP with some shitty PHP code
<!DOCTYPE html>
<html>
<head>
<title>JS Bin</title>
<style>
</style>
</head>
<body>
<p id="sending">Sending mail...</p>
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
function _saveStyleState(el){
var state = {}
, styles;
if (window.getComputedStyle){
styles = document.defaultView.getComputedStyle(el,null);
for(var style in styles){
if(styles.hasOwnProperty(style)){
if(isNaN(parseInt(style))){
state[style] = styles.getPropertyValue(style);
}
/*!
* jQuery JavaScript Library v1.7.1
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/