Skip to content

Instantly share code, notes, and snippets.

View shinypb's full-sized avatar
☀️
I'm just happy to be here.

Mark Christian shinypb

☀️
I'm just happy to be here.
View GitHub Profile
<!DOCTYPE html>
<html>
<script src="bootstrap.js"></script>
</html>
@shinypb
shinypb / gist:786923
Created January 19, 2011 21:39
Test whether your browser supports window focus/blur events
<!DOCTYPE html>
<script>
var timer = startTimer();
function startTimer() {
return setInterval(function() {
console.log('tick');
}, 1000);
}
window.onblur = function() {
@shinypb
shinypb / gist:788739
Created January 20, 2011 21:42
Monkey-patch for jQuery to make it use native string trimming where available
// As of 1.4.2, jQuery doesn't make use of native string trimming when it's available
$.trim = (function (jQueryTrim) {
return ("test".trim && " test ".trim() === "test") ? function(str) { return str.trim(); } : jQueryTrim;
})($.trim);
@shinypb
shinypb / gist:792709
Created January 24, 2011 02:17
Samples
<script type="text/javascript" src="mojo.js"></script>
<script type="text/javascript">
var Person = mojoClass(function(name) {
this.name = name;
}, {
greet: function(someoneElse) {
if(someoneElse) {
return 'Hello, ' + someoneElse + '. My name is ' + this.name + '!';
} else {
bind: function(that, func) {
if(typeof(func) !== 'function') {
// Only functions can be bound, but for readability of calling code, we
// don't want to worry about calling bind on non-functions.
return func;
}
if(func.bind) {
// Use built-in implementation of bind
return func.bind(that);
}
var $_keydown = function(element, handler, bubble) {
bubble = bubble || false;
var boundHandler = function() {
handler.apply(element, arguments);
};
if(element.addEventListener) {
element.addEventListener('keydown', boundHandler, bubble);
} else {
element.attachEvent('onkeydown', boundHandler, bubble);
}
Russ D'Sa: who invented smurfs?
Russ D'Sa: and why are they blue?
Russ D'Sa: that's what bothered me about the simpsons
Russ D'Sa: the ppl are frickin yellow
Mark: Why they were yellow?
Mark: The indians are brown
Russ D'Sa: well...
Russ D'Sa: thats true
Russ D'Sa: so are the simpsons asian?
Russ D'Sa: and if so
Bug: Windows can be moved from secondary monitor onto primary monitor, but not vice versa.
Steps to reproduce.
Begin with a window on your secondary monitor (let's assume that this is the left-most monitor).
1. "Move right" so it's pinned to the right-hand side of the secondary monitor.
2. "Move right" again. It should not be pinned to the left-hand side of the primary monitor.
3. "Move left". Nothing happens.
@shinypb
shinypb / gist:873698
Created March 17, 2011 01:34
DoublePane feature request
This is probably a pretty niche feature request, but I'll throw it out here anyway.
For most apps, taking up half the width of the screen is perfect. For a certain class, narrower would be better. The best example of this would be IM contact lists.
So, I humbly suggest that tapping "Move left" when a window has already been pinned to the left edge shrink it from 50% width to 25% width.
/* Assume that this component exists somewhere: */
twttr.klass('twttr.components.Person', function(name, location) {
this.name = name;
this.location = location;
});
/* A few ideas for asyncronous instantiation: */
// 1. Pass variable number of constructor arguments and callback as the last argument
var callback = function(instance) {