Skip to content

Instantly share code, notes, and snippets.

View sgreenfield's full-sized avatar

Scott Greenfield sgreenfield

  • Omaha, NE
View GitHub Profile
$(this).bind('mouseover focusin mouseleave blur', function(e){
e.stopImmediatePropagation();
})
.attr('title','')
.tooltip({
content: function(){ return IG.Tmpl.partials["schedules_quick_add"]; },
position: {
my: 'left bottom',
at: 'left top',
of: $(this),
@sgreenfield
sgreenfield / gist:1557278
Created January 3, 2012 22:26
Compass font-face mixin
@mixin font-face(
$name,
$font-files,
$eot: false,
$weight: false,
$style: false
) {
$iefont: unquote("#{$eot}?iefix");
@font-face {
font-family: quote($name);
@sgreenfield
sgreenfield / gist:1660133
Created January 23, 2012 02:41
Need this from the server...
//This is JavaScript object is an example of what I need returned from the server.
{
events: [
{
id: 1, userid: 1
},
{
id: 2, userid: 1
},
@sgreenfield
sgreenfield / pull-it.js
Last active September 29, 2015 22:38
Quick and Dirty Bookmarklet for Github Pull Requests *** FF 20 Security prevents bookmarklets. about:config => security.csp.enable: false
javascript:(function(){var%20$commits=$('.commits-condensed%20td.message'),title=$.trim($commits.last().text())+'...',pullBody='';$commits.each(function(){pullBody+=$.trim($(this).text())+'%20%20';});$('.title.required').val(title);$('#pull_body').val(pullBody);$('.form-actions .button.primary').removeAttr('disabled');})();
@sgreenfield
sgreenfield / gist:2362751
Created April 11, 2012 21:24
ASCII Looks of Disapproval
ಠ_ಠ
ಠ~ಠ
ಠoಠ
ಠxಠ
ಠ.ಠ
@sgreenfield
sgreenfield / gist:2720910
Created May 17, 2012 18:58
Future bookmarklet to help with SASS color adjustments
var jsColor = {};
(function(self){
self.hexToRgb = function(hex) {
if (hex[0]=="#") hex=hex.substr(1);
if (hex.length==3) {
var temp=hex; hex='';
temp = /^([a-f0-9])([a-f0-9])([a-f0-9])$/i.exec(temp).slice(1);
for (var i=0;i<3;i++) hex+=temp[i]+temp[i];
}
@sgreenfield
sgreenfield / gist:2802070
Created May 27, 2012 03:35
JavaScript updateQueryStringParameter
function updateQueryStringParameter(a, k, v) {
var re = new RegExp("([?|&])" + k + "=.*?(&|$)", "i"),
separator = a.indexOf('?') !== -1 ? "&" : "?";
if (a.match(re)) return a.replace(re, '$1' + k + "=" + v + '$2');
else return a + separator + k + "=" + v;
}
@sgreenfield
sgreenfield / gist:2871423
Created June 4, 2012 23:18
jQuery keypress with intent to type a value
$(document).keypress(function(e) {
var code = (e.keyCode) ? e.keyCode : e.which, character;
if(e.charCode && code !== 32 && code !== 13 && !e.altKey && !e.ctrlKey && !e.metaKey){
character = String.fromCharCode(e.charCode);
console.log('value: ', character);
}
});
@sgreenfield
sgreenfield / gist:4043009
Created November 9, 2012 00:49
Geordi La Forge dialog generator
//requires sugar.js (because I spent like 30 seconds on it)
//dialog source: http://stuff.mit.edu/afs/athena/activity/h/humor/Incoming/laforge.dialogue.generator
descriptor = 'electro-magnetic disruptive destructive'.words();
verbs = 'reconfigure assemble bypass amplify re-route polarize'.words();
nouns = 'field transducer coil dispersion phase-disruptor anus resonance sub-space tachyon induction pulse matrix baryon conduit wave-guide lepton discriminator polarization electro-magnetic frequency bandwidth antimatter diagnostic mode plasma spectral emitter'.words();
enemies = 'klingons romulans herpes'.words();
var laforge = "Captain, we're going to have to {verb1} the {descriptor1} {nouns1}, and {verb2} the {descriptor2} {nouns2} in order to prevent the {enemy} from penetrating our shields".assign({
verb1: verbs.sample(),
//meta validation
//idea for dynamic validation to enable model validation to change its own validation on the fly
//example syntax below
var validation = {
rules: [ //model attribute rules
'recipient_type': {
//on: true, //always on by default
when: [