Skip to content

Instantly share code, notes, and snippets.

View vishnun's full-sized avatar

Vishnu Narang vishnun

View GitHub Profile
@vishnun
vishnun / dabblet.css
Created October 24, 2012 07:02
Checkbox Hack
/* Checkbox Hack */
input[type=checkbox] {
position: absolute;
top: -9999px;
left: -9999px;
}
label {
-webkit-appearance: push-button;
-moz-appearance: button;
@vishnun
vishnun / index.md
Created October 25, 2013 09:02 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@vishnun
vishnun / stick.js.coffee
Created October 30, 2013 05:16
My Gist to make a stick to top kinda header
$(document).ready ->
StickTop.initApp()
@StickTop =
app:
initHeaderBinding: (headerSelector)->
$(window).on "scroll", ()->
if $('body').scrollTop() > 65
$(headerSelector).addClass('fixed-to-top')
$('.stick-top').slideDown(400)
@vishnun
vishnun / gist:7313759
Last active December 27, 2015 10:49
Sublime Text Short Cuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
namespace :unicorn do
##
# Tasks
desc "Start unicorn"
task(:start) {
config = rails_root + "config/unicorn.rb"
sh "bundle exec unicorn --daemonize --config-file #{config}"
}
@vishnun
vishnun / failsafe
Last active September 24, 2016 00:25
FailSafe for project
javascript: function failsafe() {
if(location.href.indexOf('failsafe')==-1){
if (location.href.indexOf('?') == -1) {
location.href = location.href.concat("?failsafe=true");
}else{
location.href = location.href.concat("&failsafe=true");
}
} else {
var href = location.href.replace("failsafe=true","");
if(location.href.lastIndexOf("&") === location.href.length-1){
@vishnun
vishnun / tab.bash
Last active August 29, 2015 14:18 — forked from bobthecow/tab.bash
#!/bin/bash
#
# Open new Terminal tabs from the command line
#
# Author: Justin Hileman (http://justinhileman.com)
#
# Installation:
# Add the following function to your `.bashrc` or `.bash_profile`,
# or save it somewhere (e.g. `~/.tab.bash`) and source it in `.bashrc`
#
@vishnun
vishnun / visual_testing_using_phantomcss_and_casper_js
Created May 28, 2015 03:59
Using network monitoring and wait time combined to deterministically capture entire page.
var casper = require("casper").create();
casper.options.waitTimeout = 25000;
var url_list = casper.cli.get(0);
var fileName = casper.cli.get(1);
var result = url_list.split(",");
var requests = {}, responses = {};
casper.start().eachThen(result, function(urlData) {
casper.thenOpen(urlData.data, function(urlData) {
@vishnun
vishnun / jquery.dynatable.min.js
Created June 8, 2015 10:01
jquery.dynatable.min.js
!function(t){function e(t,e,a,n){for(var r="",s=0,i=a.length;i>s;s++)r+=n(a[s],e);return"<tr>"+r+"</tr>"}function a(t,e){var a=t.attributeWriter(e),n="<td";return(t.hidden||t.textAlign)&&(n+=' style="',t.hidden&&(n+="display: none;"),t.textAlign&&(n+="text-align: "+t.textAlign+";"),n+='"'),n+">"+a+"</td>"}function n(t){return t[this.id]}function r(e){return t(e).html()}function s(e,a){this.update=function(){var n="",r=a.table.columns,s=a.writers._rowWriter,i=a.writers._cellWriter;e.$element.trigger("dynatable:beforeUpdate",n);for(var o=0,d=a.dataset.records.length;d>o;o++){var u=a.dataset.records[o],l=s(o,u,r,i);n+=l}if(a.features.recordCount&&t("#dynatable-record-count-"+e.element.id).replaceWith(e.recordsCount.create()),a.features.paginate&&(t("#dynatable-pagination-links-"+e.element.id).replaceWith(e.paginationLinks.create()),a.features.perPageSelect&&t("#dynatable-per-page-"+e.element.id).val(parseInt(a.dataset.perPage))),a.features.sort&&r){e.sortsHeaders.removeAllArrows();for(var o=0,d=r.length;d>o;o++)
@vishnun
vishnun / jquery.dynatable.css
Created June 8, 2015 10:04
jquery.dynatable.css
th{background:#006a72}th a{color:#fff}th a:hover{color:#fff;text-decoration:underline}.dynatable-search{float:right;margin-bottom:10px}.dynatable-pagination-links{float:right}.dynatable-record-count{display:block;padding:5px 0}.dynatable-pagination-links li,.dynatable-pagination-links span{display:inline-block}.dynatable-page-break,.dynatable-page-link{display:block;padding:5px 7px}.dynatable-page-link{cursor:pointer}.dynatable-active-page,.dynatable-disabled-page{cursor:text}.dynatable-active-page:hover,.dynatable-disabled-page:hover{text-decoration:none}.dynatable-active-page{background:#006a72;border-radius:5px;color:#fff}.dynatable-active-page:hover{color:#fff}.dynatable-disabled-page,.dynatable-disabled-page:hover{background:0 0;color:#999}