Skip to content

Instantly share code, notes, and snippets.

View jasonrhodes's full-sized avatar

Jason Rhodes jasonrhodes

View GitHub Profile
@jasonrhodes
jasonrhodes / notifications-chrome.js
Last active August 29, 2015 14:00
Web Notifications API in Chrome, example
document.getElementsByTagName("body")[0].onclick = function () {
Notification.requestPermission(function (p) {
var n = new Notification("WHAO!", {
icon: "http://www.yuppiepunk.org/images/brotherly_love.jpg",
body: "Joey Lawrence is totes cool"
});
console.log(n);

CSS is so hard and so painful but why? And what can we do about it?

Entanglement occurs when two particles are so deeply linked that they share the same existence.

Entangled particles can become widely separated in space. But even so, the mathematics implies that a measurement on one immediately influences the other, regardless of the distance between them.

@jasonrhodes
jasonrhodes / SassMeister-input.scss
Created May 29, 2014 20:49
Generated by SassMeister.com.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
@mixin thing($ratio) {
// want to be able to split $ratio and get 1 and 3
// back as numbers to use
}
@jasonrhodes
jasonrhodes / nestify.php
Created May 30, 2014 18:06
Take a list of strings and turn it into a nested associative array
<?php
function nestify($list, &$master) {
if (empty($list)) {
return $master;
}
$key = array_shift($list);
@jasonrhodes
jasonrhodes / psu_more-js.notes.md
Last active August 29, 2015 14:02
Notes and resources from my "Let's Use More JavaScript, OK?" talk at PSU Web Conference 2014
@jasonrhodes
jasonrhodes / nodeschool-01-wrapup.md
Last active August 29, 2015 14:02
Baltimore nodeschool #1 (May 2014) wrap up

baltimore nodeschool wrap-up

May 2014

Things!

<?php
session_start();
if (!isset($_SESSION['incr'])) {
$_SESSION['incr'] = 0;
} else {
$_SESSION['incr']++;
}
@jasonrhodes
jasonrhodes / times.js
Last active August 29, 2015 14:03
Creates a new function that will only run {{max}} number of times and then the function becomes a no-op pass-through
/**
* Creates a new function that will only run
* max number of times and then the function
* will become a no-op pass-through
*
* This could probably become its own little lib
*
* @param function func The main function
* @param int max
* @param int count optional starting point
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
@jasonrhodes
jasonrhodes / psr-autoloading.md
Last active August 29, 2015 14:04
Why PSR-0/4 are confusing, from my perspective

PSR-0 and PSR-4 are both PSR-Confusing

Phil Sturgeon asked everyone's opinion about deprecating PSR-0 and I was an ass and said they were both awful. I don't think that, but I think they're both about equally confusing from userland so it doesn't really matter to me. Phil had a great question https://twitter.com/philsturgeon/status/490659076096131072 about how they're confusing, and I needed more than a few tweets to explain.

I use PSR-0 and now some PSR-4 all the time for autoloading, although my experience is generally filling out composer.json "autoload" keys. Every single time I go to fill out "autoload": { "psr-0": I have to spend 5-10 minutes going back through docs trying to figure out how to designate the right path -> namespace match so that my files will load. In other words, neither is very intuitive. "What folders do I need to nest inside src? What do I have to repeat? What if I want to just include some util classes in my lib folder?"

I always assume I can just declare

{