Skip to content

Instantly share code, notes, and snippets.

View jmwhittaker's full-sized avatar

James Whittaker jmwhittaker

View GitHub Profile
@jmwhittaker
jmwhittaker / app.js
Created November 26, 2012 12:47
Something every Angular.js app should have
//mimic if statement for angular
//Schema: if(expression, 'foo', 'bar')
$scope['if'] = function(condition, a, b) {
return condition ? a : b;
};
//mimic switch case for angular
//Schema: switch(colorid, [[1,'red'], [2,'green'], [3, 'blue']], 'black')
$scope['switch'] = function (expression, cases, thedefault) {
for(var i = 0; i < cases.length; i++) {
@jmwhittaker
jmwhittaker / dabblet.css
Created September 6, 2012 09:44
The Media Object
/**
* The Media Object
*/
.media {margin:10px;}
.media, .bd {overflow:hidden; _overflow:visible; zoom:1;}
.media .img {float:left; margin-right: 10px;}
.media .img img{display:block;}
/* for element positioned on the right */
.media .imgExt{float:right; margin-left: 10px;}
@jmwhittaker
jmwhittaker / Globalgram_Arduino_Code.ino
Created August 25, 2012 15:09 — forked from andrewhaskin/Globalgram_Arduino_Code.ino
Arduino Code for a Rotary Switch and a Button used for Globalgram
// RotarySwitch.pde -- test out a rotary switch (not a rotary encoder)
// Tod E. Kurt, http://todbot.com/blog/
////4-position rotary switch
const int firstRotaryPin = 3;
const int lastRotaryPin = 7;
int button = 9; ////button input
int input1 = LOW;
@jmwhittaker
jmwhittaker / markup
Created July 18, 2012 12:09
Vertical CSS3 centering with inline-block
<div class="block">
<div class="centered">Hello world</div>
</div>
@jmwhittaker
jmwhittaker / crunchy_pubsub.js
Created May 9, 2012 17:28 — forked from plukevdh/crunchy_pubsub.js
Faux pubsub. Could also use jQuery event binding if you rather.
crunch.pubsub = _.extend({}, Backbone.Events);
// Hide backbone implementation by aliasing
crunch.pubsub.publish = crunch.pubsub.trigger;
crunch.pubsub.subscribe = crunch.pubsub.bind;
crunch.pubsub.unsubscribe = crunch.pubsub.unbind;
@jmwhittaker
jmwhittaker / gist:2107703
Created March 19, 2012 11:05
Center input placeholder text
::-webkit-input-placeholder,
input:-moz-placeholder {
text-align:center;
}
@jmwhittaker
jmwhittaker / Rubberband scroll
Created January 9, 2012 17:29
Prevent 'rubber band' scrolling in Lion
/* To prevent rubber band scrolling in Lion */
body {
overflow:hidden;
height:100%;
}
/* Also look to add in -webkit-overflow-scrolling for touch iOS 5 < devices */

A pure CSS bendy shadow:

I suspect that some trig calculations could make this very general.

bendy_shadow

@jmwhittaker
jmwhittaker / Repair OSX Disk
Created March 31, 2011 10:27
If you ever get invalid node structure problem with disk
Boot up with OSX Disk.
Firstly try Disk Utility repair
Then if that does not work try (with the drive unmounted)
Open terminal and type:
/sbin/fsck_hfs -ypr /dev/disk0s2
@jmwhittaker
jmwhittaker / Localhost in VMWare VM
Created March 14, 2011 15:22
Get localhost working in VMWare
Connect to your Mac's localhost from within a VMWare virtual machine.
- Boot up VMware and fire up your VM (i'm using Windows 7)
- Make sure that the VM is using NAT
- Fire up the command prompt in Windows and type "ipconfig". IN the resulting text look for your IPv4 address. It will be something like 192.168.xxx.xxx
- Now go to your browser in your VM and type that ip address into the url bar but change the last set of digits to be 2 (or 1).
- so as an example if your ip was found to be 192.168.213.200 change it to be 192.168.213.2
- Assuming that your localhost is running on your mac you should get your localhost in your VM browser.
- If you need to add a non standard port number on the end like 8090 go ahead and do so.