Skip to content

Instantly share code, notes, and snippets.

@pranav7
pranav7 / til.md
Last active December 6, 2016 09:52
Conver ruby hash to new syntax

Convert Ruby 1.8 to 1.9 Hash Syntax - for vim

:%s/:\([^ ]*\)\(\s*\)=>/\1:/g
@pranav7
pranav7 / simple_form.rb
Last active July 26, 2019 10:57
Simple form Initializer to work with Semantic UI
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
config.wrappers :default, class: :input, hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
@pranav7
pranav7 / limit_to.md
Last active March 31, 2016 11:09
Angular Directive for limiting number input fields to maximum characters

Angular Directive for limiting number input fields to maximum characters

do ->
  'use strict'

  LimitTo = () ->
    return {
      restrict: "A"
 link: (scope, element, attrs) ->

Last element flag in ngRepeat

$last is what does the trick for you.

%span{ ng: { repeat: "something in vm.somethings" } }
%span {{ something.key }} {{ something.value }}
%span{ ng: { hide: "$last" }} -
@pranav7
pranav7 / sweetalert.md
Last active February 8, 2016 07:05
SweetAlert + Angular - EASY
Capybara.register_driver :chrome do |app|
# optional
client = Selenium::WebDriver::Remote::Http::Default.new
# optional
client.timeout = 120
Capybara::Selenium::Driver.new(app, :browser => :chrome, :http_client => client)
end
Capybara.javascript_driver = :chrome
@pranav7
pranav7 / method_location.rb
Created October 8, 2014 06:14
Finding the exact location of a method in Ruby
# say you want to know the source location of a method :hai on the object O
# you can do
# a method in ruby is also an object. This returns the method object for method :hai
m = O.method(:hai)
# this will give you the exact location of the me
m.source_location
@pranav7
pranav7 / gist:7a18c262a81d474f2306
Last active August 29, 2015 14:06
Output Response HTTP Status of a cURL Request

Output Response HTTP Status of a cURL Request


Append -w "\nSTATUS: %{http_code}\n" at the end of your cURL call.

-w helps you to write an output after completion

-s optional - can be added to silent other outputs from the curl request

Example:
@pranav7
pranav7 / install_instructions.md
Last active August 29, 2015 14:05
Installing Postgis 2.1 on Ubuntu 14.04

If you haven't already installed postgres, you can follow the instructions here.

Go ahead, and run this in your terminal:

sudo apt-get install postgresql-9.3-postgis-2.1 pgadmin3 postgresql-contrib

Enable Adminpack in postgres

sudo -u postgres psql

@pranav7
pranav7 / pranavsingh.zsh-theme
Last active August 29, 2015 14:04
ZSH Theme
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[black]%}%c %{$fg_bold[red]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}) %{$fg[black]%}>%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"