This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#returns 'active' if current page == uri | |
#depth specifies how much of the URL is compared, either [:controller, :action, :complete] | |
def class_for_link(uri, depth=:action) | |
path_hash = ActionController::Routing::Routes.recognize_path(uri, { :method => :get }) | |
match = case depth | |
when :controller | |
path_hash[:controller] == controller.controller_name | |
when :complete | |
uri == request.path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= link_to "COUNTRIES", entities_path(:countries), :class => class_for_link(model_path(4), :complete) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
// Activate PJAX on ul.menu links | |
// Response will be loaded into #main element on the page | |
$('ul.menu a').pjax('#main') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from | |
if (some_var == null | |
// to | |
if (some_var === null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var some_var; | |
some_var === null; // false | |
some_var == null; // true | |
some_var; // undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (some_var === undefined) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
undefined = "don't ever do this"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typeof(some_var) // returns 'undefined' | |
//Therefore, the correct way in javascript to check if a variable has a value is: | |
typeof some_var === 'undefined' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Crazy Slow | |
UPDATE protected_areas SET criteria = 'Not Applicable' WHERE designation_id != 5; | |
# Near instant | |
UPDATE protected_areas SET criteria = 'Not Applicable' | |
FROM protected_areas AS pa | |
LEFT OUTER JOIN designations ON pa.designation_id = designations.id | |
WHERE designations.id = 5 AND pa.designation_id = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Somewhat copied from https://github.com/spf13/spf13-vim/blob/master/.vimrc | |
set nocompatible " We're running Vim, not Vi! | |
call pathogen#runtime_append_all_bundles() " add pathogen | |
" UI stuff | |
syntax on " Enable syntax highlighting | |
set background=dark " Assume a dark background | |
color ir_black | |
set backspace=indent,eol,start " backspace for dummys |
OlderNewer