Skip to content

Instantly share code, notes, and snippets.

View vijedi's full-sized avatar

Tejus Parikh vijedi

View GitHub Profile
@vijedi
vijedi / .tmux.conf
Created May 18, 2022 18:41
.tmux.conf
# For tmux > 2.4a
setw -g mode-keys vi
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X being-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send -X copy-selection-and-cancel
syntax on
set tabstop=4
set shiftwidth=4
set expandtab
set bg=dark
set nu
set ruler
set hlsearch
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:30'
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
@vijedi
vijedi / ng-if.html
Last active March 15, 2016 20:40
Code that renders nothing witin the alert box
<!-- has_alerts is true and view_opts.state is set to 'expired' -->
<div id='BriefAlert' class='alert alert-info' ng-if='has_alerts'>
<span ng-switch='view_opts.state'>
<span ng-switch-when='expired'>Brief closed -- Not completed before expiration date</span>
<span ng-switch-when='reassigend'>Brief closed -- Reassignment of {{reassignmentPhrase()}}</span>
<span ng-switch-when='view_only'>You only have permissions to view the questions of this brief</span>
</span>
</div>
@vijedi
vijedi / ng-show.html
Last active March 15, 2016 20:32
Code that showed the correct thing in the directive
<!-- has_alerts is true and view_opts.state is set to 'expired' -->
<div id='BriefAlert' class='alert alert-info' ng-show='has_alerts'>
<span ng-switch='view_opts.state'>
<span ng-switch-when='expired'>This thing was expired</span>
<span ng-switch-when='reassigend'>This thing was reassigned to someone else</span>
<span ng-switch-when='view_only'>You can only view this thing</span>
</span>
</div>
@vijedi
vijedi / sentence_util.rb
Created November 26, 2014 03:41
Algorithm for comparing sentences
module ViJedi::SentenceUtil
SIMILARITY_PERCENTAGE = 0.4
# boolean check to see if the source and prime sentences are the same
def self.similar(source, prime)
return compute_values(source, prime)[:mismatch_percentage] < SIMILARITY_PERCENTAGE
end
# returns the word difference between the source and prime
def self.word_distance(source, prime)
@vijedi
vijedi / base_controller.rb
Created November 8, 2014 15:14
Pagination with angular-paginate-anything and kaminari
class Api::BaseController < ApplicationController
include Rivalry::OrganizationScope
respond_to :json
private
def self.paginated_action(options = {})
before_filter(options) do |controller|
if request.headers['Range-Unit'] == 'items' &&
request.headers['Range'].present?
@vijedi
vijedi / rails_migration_with_couchrest.sh
Created November 2, 2012 14:08
Generating a rails migration with couchrest
rails g migration migrationname --orm=active_record
@vijedi
vijedi / gist:3880535
Created October 12, 2012 17:55
Force Less CSS into development mode.
<!-- The following lines force less into development mode -->
<script type="text/javascript">
var less = { env: 'development'};
</script>
<link rel="stylesheet/less" type="text/css" href="/less/bootstrap.less" >
<link rel="stylesheet/less" type="text/css" href="/less/responsive.less" >
<%= javascript_include_tag 'less-1.2.2.min' %>
@vijedi
vijedi / active_admin_handling_sort_param.rb
Created October 11, 2012 03:00
Active Admin Handling Sort Param
order = case(params[:order])
when 'user_email_desc'
'email DESC'
when 'user_email_asc'
'email ASC'
else
nil
end
@vijedi
vijedi / active_admin_sortable_column.rb
Created October 11, 2012 02:57
Active Admin Sortable Column
column('Email', :sortable => :user_email) {|user| user.email}