Skip to content

Instantly share code, notes, and snippets.

View gr2m's full-sized avatar
:octocat:
I'm in the upside down

Gregor Martynus gr2m

:octocat:
I'm in the upside down
View GitHub Profile
@gr2m
gr2m / gibberish.rake
Created October 21, 2009 11:12 — forked from karmi/gibberish.rake
updated karmi's gist with support for empty brackets, like "Users"[]
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
require 'fileutils'
.mad-lips label {
white-space: nowrap;
padding: 0 0 .5em;
display: -moz-inline-stack;
display: inline-block;
vertical-align: top;
zoom: 1;
*display: inline;
}
@gr2m
gr2m / jQuery_reverse.js
Created April 24, 2010 00:59
reverse function for jQuery
$.fn.reverse = [].reverse;
@gr2m
gr2m / trim.js
Created April 26, 2010 19:41
trim() function for Strings
// add trim to String Object
String.prototype.trim = function() {
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '')
}
/*
MAKE the whole block actionable with CSS only.
<div id="block" title="read more about ...">
<h3><a href="...">Some title here</a></h3>
<p>bla bla bla .... bla!</p>
</div>
*/
-- http://stackoverflow.com/questions/3585467/multiple-group-bys-sort-by-sumd-group-values
SELECT
project_name, service_name, project_minutes, minutes
FROM
(
SELECT
projects.id as project_id,
projects.name as project_name,
services.name as service_name,
javascript:void(function(){$("#user_allow_project%20optgroup").each(function(){var%20optgroup=this;$(optgroup).find('option').each(function(){$('form%20ul.remove_children_on_reset').append('<li%20class=""><input%20type="hidden"%20value="'+this.value+'"%20name="user[allowed_projects_ids][]"><strong>'+$(this).text()+'%20('+optgroup.label+')'+'</strong><a%20class="remove_project"%20href="#">x</a></li>')});$(optgroup).remove()})})();
Preconditions:
* set your timezone to Auckland, New Zealand.
Description
There is a bug with the Date Object. »new Date("2010/9/26")« returns
»Sat Sep 25 2010 23:00:00 GMT+1200 (NZST)«
@gr2m
gr2m / mite.load_billable_time_for_today.js
Created November 4, 2010 11:20
loads the time that is billable for today out of your mite.yo.lk
$.get(
'/time_entries.json?at=today&billable=true&group_by=day',
function(data) { alert($mite.minutes.minToStr(data[0].time_entry_group.minutes))}
);
@gr2m
gr2m / jquery.focus_select.js
Created May 1, 2011 00:21
$('input, select').focus_select() will focus the <select> and select the <input>. select does not work on <select>s
jQuery.fn.focus_select = function() {
return this.each(function(){
var $this = jQuery(this);
if ( $this.is('select') ) {
$this.focus()
} else {
$this.select()
}
})
}