Skip to content

Instantly share code, notes, and snippets.

@manishval
manishval / gist:8409471
Last active January 3, 2016 04:29
Bash keyboard shortcuts
- command + a to go to the beginning of a line
- command + e to go to the end of a line
- alt+f forward word (unless system shortcut for file menu)
- alt+b back word
- command + b back char
- command + f forward char.
- command + u to kill (cut) from current location to beginning of the line
- command + k to kill (cut) from current location to end of line
- command + w to kill (cut) from current location to beginning of word
- command + y to paste (copied / cut) lines
@manishval
manishval / gist:8270078
Created January 5, 2014 16:11
UIImage form view
- (UIImage *)imageOfView:(UIView *)view
{
// This if-else clause used to check whether the device support retina display or not so that
// we can render image for both retina and non retina devices.
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
}
else
@manishval
manishval / gist:6195208
Created August 9, 2013 16:54
Good modal jQuery plugin - TB
<html>
<head>
<link href="http://vadimg.com/twitter-bootstrap-wizard-example/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://vadimg.com/twitter-bootstrap-wizard-example/bootstrap/js/bootstrap.min.js"></script>
<script src="http://vadimg.com/twitter-bootstrap-wizard-example/jquery.bootstrap.wizard.js"></script>
</head>
<body>
<div id="rootwizard">
In your PhotoController index action get the top 3 un-voted photos:
```
@photos = Photo.unvoted.limit(3)
```
Then in your view you wrap each photo within a div, and give this div a data-id attribute with the photo's id as the value. Example:
```
<div id="photos">
@manishval
manishval / countries.rb
Created April 16, 2013 01:59
Countries
Country.create( name: "Afghanistan", code: "AF" )
Country.create( name: "Aland Islands", code: "AX")
Country.create( name: "Albania", code: "AL",visa_required: true )
Country.create( name: "Algeria", code: "DZ" )
Country.create( name: "American Samoa", code: "AS" )
Country.create( name: "Andorra", code: "AD" )
Country.create( name: "Angola", code: "AO" )
Country.create( name: "Anguilla", code: "AI" )
Country.create( name: "Antarctica", code: "AQ" )
Country.create( name: "Antigua and Barbuda", code: "AG" )
@manishval
manishval / template.rb
Last active December 11, 2015 23:49
Basic Rails application template
if yes?('Would you like to install country select')
gem('country_select')
end
gem 'bootstrap-will_paginate'
gem 'stamp'
gem 'gom_theme', path: '../gom_theme'
gem 'validates_timeliness'
gem_group :development do
@manishval
manishval / Gemfile
Created October 20, 2012 00:59 — forked from jacquescrocker/Gemfile
Gemfile for DeployButton.com
# deploybtn Gemfile
source 'https://rubygems.org'
gem "rake", ">= 0.9.2"
gem 'rails', ">= 3.2.7"
gem 'json'
gem "rails_config", "0.2.5"
gem "guid"
@manishval
manishval / gist:3113006
Created July 14, 2012 19:43
ValidateCreditCardNumber
private bool ValidateCreditCardNumber(string creditCardNumber)
{
//Replace any character other than 0-9 with ""
creditCardNumber = Regex.Replace(creditCardNumber,@"[^0-9]","");
int cardSize = creditCardNumber.Length;
//Creditcard number length must be between 13 and 16
if (cardSize >= 13 && cardSize <= 16)
{
def full_name
if first_name.blank?
last_name
else
[first_name, last_name].compact.join(' ')
end
end