Skip to content

Instantly share code, notes, and snippets.

View colynb's full-sized avatar
🎯
Focusing

C Brown colynb

🎯
Focusing
View GitHub Profile
@colynb
colynb / dabblet.css
Created December 22, 2011 03:24
Radio Button Hack - CSS Only
input[type=radio] {
position: absolute;
top: -9999px;
left: -9999px;
}
label {
cursor: pointer;
text-align: center;
font-family: sans-serif;
@colynb
colynb / dabblet.css
Created December 22, 2011 03:30 — forked from chriscoyier/dabblet.css
Checkbox Hack
/* Checkbox Hack */
input[type=checkbox] {
position: absolute;
top: -9999px;
left: -9999px;
}
label {
-webkit-appearance: push-button;
-moz-appearance: button;
@colynb
colynb / gist:3290105
Created August 7, 2012 22:36
Native Array foreach implementation
Array.prototype.foreach = function(action) {
for (var i = 0; i < this.length; i++) {
action(i, this[i]);
}
};
​var arr = [1,2,3,4];
arr.foreach(function(i,item){
$('#log').append('<p>'+item+'</p>');
@colynb
colynb / gist:3290235
Created August 7, 2012 22:48
Array prototypes
/*
* Foreach
* Example:
* var arr = [1,2,3,4];
* arr.foreach(function(i,item) {
* console.log(i, item);
* });
*
*/
Array.prototype.foreach = function(action) {
@colynb
colynb / gist:3383209
Created August 17, 2012 22:14
TIPS: Clear Chrome DNS Cache
chrome://net-internals/#dns
Just a quick tip for those who need to clear Chrome's DNS cache only. The method for "Empty the cache" under "Clear Browsing Data" clear both files caches and DNS caches.
To just clear the DNS cache, type this into the browser: chrome://net-internals/#dns
@colynb
colynb / gist:3390791
Created August 19, 2012 01:27
JS: Wrap Terms With...
/*
* Take a string and wrap any terms with some container (like <span>)
* Nothing complicated. It splits a string on ',' (comma) and 'and', and adds the desired wrapper around the resulting terms.
*/
​var str = 'Web Developer and Front-End Engineer and All around cool guy';
String.prototype.wrapTermsWith = function(wrap) {
var delimiters = [',', ' and '],
wrapper = wrap.split('><'),
@colynb
colynb / gist:3430759
Created August 23, 2012 00:07
JavaScript: Namespacing Native Object Prototypes
/*
* Where I work, I thought it would come in handy to have a
* collection of methods that I could apply to native JS
* objects, like strings.
*
* While it would be useful to do this:
*/
String.prototype.touch = function() {
return this + ' has been touched';
@colynb
colynb / dabblet.css
Created August 28, 2012 22:28
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@colynb
colynb / gist:3890068
Created October 14, 2012 22:55
PHP / PHPUnit / Tests / CalculatorTest
<?php
class CalculatorTest extends PHPUnit_Framework_TestCase {
public function testAdd() {
$c = new Calculator;
$result = $c->add(5, 10);
$this->assertEquals(15, $result);
}
}
@colynb
colynb / autotest_watchr.rb
Created October 15, 2012 00:55
Ruby / Watchr / PHPUnit Notifier
#watchr script
# $ watchr ./autotest_watchr.rb
# depends on Growl and growlnotify
watch("Classes/(.*).php") do |match|
run_test %{Tests/#{match[1]}Test.php}
end
watch("Tests/.*Test.php") do |match|
run_test match[0]