Skip to content

Instantly share code, notes, and snippets.

View courtsimas's full-sized avatar
🏠
Building

Court Simas courtsimas

🏠
Building
View GitHub Profile
@courtsimas
courtsimas / gist:2586844
Created May 3, 2012 16:09
handling a missing template due to wrong format
rescue_from ActionView::MissingTemplate do |e|
self.formats = [:html]
render "#{params[:action]}"
end
navigator.geolocation.getCurrentPosition(locationSuccess, locationFail);
function locationSuccess(position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
}
function locationFail() {
alert(‘Oops, could not find you.’);
}
@courtsimas
courtsimas / gist:2295765
Created April 3, 2012 21:54
hide url bar
// Hide URL bar for iOS and android
hideAddressBar = function(){
if (navigator.userAgent.match(/Android/i)) {
window.scrollTo(0,0); // reset in case prev not scrolled
var nPageH = $(document).height();
var nViewH = window.outerHeight;
if (nViewH > nPageH ) {
nViewH = nViewH / window.devicePixelRatio;
$('body').css('height',nViewH + 'px');
@courtsimas
courtsimas / gist:2243988
Created March 29, 2012 21:28
list of all tables
ActiveRecord::Base.connection.tables.map do |table|
table.capitalize.singularize.camelize
end
@courtsimas
courtsimas / gist:2243978
Created March 29, 2012 21:26
get all models
ActiveRecord::Base.descendants.collect { |type| type.name }.sort
@courtsimas
courtsimas / browsercms.rb
Created March 27, 2012 23:13
turn off cms subdomain redirect for browsercms
#config/initializers/browsercms.rb
#...
Cms::DomainSupport.class_eval do
def cms_site?
true && current_user.able_to?(:administrate, :edit_content, :publish_content)
end
end
@courtsimas
courtsimas / gist:1246537
Created September 27, 2011 23:22
problem
<tr>
<td style="color: #373737;font-size: 12px; border-bottom: 1px solid #ACDAE3; padding: 10px;"><%= image_tag("/images/checkbox#{entry.bloating? ? '-checked' : ''}.png") %></td>
<td style="color: #373737;font-size: 12px; border-bottom: 1px solid #ACDAE3; padding: 10px;">Bloating</td>
</td>
@courtsimas
courtsimas / syntax_not_checked
Created September 10, 2011 18:58
a little sortable magic
$("ul#sidebar_whatever").sortable({
placeholder: "ui-state-highlight",
update: function(event, ui) { //this is where we'll do some updating crap
$("ul#sidebar_whatever").find('li.widget').each(function(){
var val = $(this).find('input.hidden_cool_input').val();// this val will be like "124,1"
var result = val.split(',');
var order = $("ul#sidebar_whatever li.widget").index($(this))//getting the order of the current element in the loop
result[1] = order; // we're reassigning the order
$(this).find('input.hidden_cool_input').val(result.toString());//we're putting the values back in, as "124,0" or "125,3" or whatever.
})
@courtsimas
courtsimas / gist:1190428
Created September 3, 2011 02:19
sass mixins
@mixin gradient($first, $second, $colorstop:0) {
background: $first;
background: -webkit-gradient(linear, left top, left bottom, from($first), color-stop($colorstop, $first), to($second));
background: -moz-linear-gradient(top, $first $colorstop, $second);
}
@mixin border-gradient($first, $second, $colorstop:0) {
border-color:$first;
border-style:double;
-webkit-border-image: -webkit-gradient(linear, 0 100%, 0 0, from($first), to($second)) 1 100%;
@courtsimas
courtsimas / gist:1167053
Created August 24, 2011 01:01
@import-once hack for sass
//sessions.css.scss - file #1 that i only want to let the _style.scss import be included once
$imported-once-files: ();
@function import-once($name) {
@if index($imported-once-files, $name) {
@return false;
}
$imported-once-files: append($imported-once-files, $name);
@return true;