Skip to content

Instantly share code, notes, and snippets.

@randika
randika / gist:1538916
Created December 30, 2011 09:17
Rails dynamic layout rendering
class ApplicationController < ActionController::Base
layout :app_layout
def app_layout
if something == "some_other_thing"
"some_layout"
else
"application"
end
end
@randika
randika / gist:1554545
Created January 3, 2012 11:24
Conditional Layout in rails
layout Proc.new{ ['edit', 'create'].include?(action_name) ? 'application' : 'cms' }
@randika
randika / deploy.rb
Created March 14, 2012 15:50
Capistrano receip
set :application, "myapp-name"
set :repository, "."
set :deploy_via, :copy
set :scm, :git
set :branch, "master"
set :user, "ubuntu"
set :use_sudo, false
@randika
randika / gist:2293201
Created April 3, 2012 16:05
Django: Add migration with South
# This example show how to integrate "South" into your exiting Django projects
# South - intelligent schema and data migrations for Django projects.
# Install South from pip
$ sudo pip install South
# Run the sysncdb
$ python manage.py syncdb
# Do an initial migration
@randika
randika / gist:3377460
Created August 17, 2012 09:38
MSSQL Find table last modify dates
SELECT name, modify_date
FROM sys.objects
WHERE type = 'P' order by modify_date desc
SELECT name, modify_date
FROM sys.tables
order by modify_date desc
<meta name="viewport" content="">
<!--
Within the content="" you can enter a load of comma delimited values, but we’re going to to focus on the fundamental ones for now.
-->
<!--
For example, if your mobile design is purposely laid out at 320px you can specify the viewport width:
-->
@randika
randika / gist:4729773
Last active December 12, 2015 06:29
SQL SELECT WHERE IN CLAUSE with multiple columns
Select DISTINCT t1.* from table1 t1 INNER JOIN(
SELECT table2_col_1 ,table2_col_2, table2_col_3 from table2 t2
) temp_table
ON t1.Id = temp_table.table2_col_1 OR t1.id = temp_table.table2_col_2 OR t1.id = temp_table.table2_col_3
Select DISTINCT t.* from topics t INNER JOIN(
SELECT topic_one ,topic_two, topic_three from entries e WHERE e.politician_id = 3
) temp_table
ON t.Id = temp_table.topic_one OR t.id = temp_table.topic_two OR t.id = temp_table.topic_three
@randika
randika / gist:4943487
Created February 13, 2013 09:58
rails simple_form grouped_collection_select example
<%= f.grouped_collection_select :parent_id, Characteristic.roots, :children, :name, :id, :name, {:include_blank => true}%>
@import "bootstrap";
body { padding-top: 60px;}
@import "bootstrap-responsive";
@media (max-width: 767px) {
.sidebar-nav-fixed {
width:auto;
}
}
<header class="navbar navbar-fixed-top">
<nav class="navbar-inner">
<div class="container">
<a data-toggle="collapse" data-target=".nav-collapse" class="btn btn-navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/?locale=en">manthri.lk</a>
<ul class="nav nav-collapse in collapse" style="height: 80px;">