Skip to content

Instantly share code, notes, and snippets.

View psahni's full-sized avatar

Prashant psahni

View GitHub Profile
@psahni
psahni / iframe_lightbox
Created May 28, 2013 11:48
lightbox inside lightbox iframe
$('.open-lightbox-xapp').live('click', function (event) {
event.preventDefault();
var xappDId = $(this).attr('xapp_id')
var message = "";
if(typeof $(this).attr('content_id') === 'undefined'){
if(typeof $(this).attr('showcase_id') !== 'undefined')
if($(this).data('customize') !== 'undefined')
message = 'customize-' + $(this).attr('showcase_id') + '-' +xappDId;
else
@psahni
psahni / remote_server_execute_cmd.rb
Created May 28, 2013 14:05
Run a command on the remote server
##############################################################
# Run a remote command on the remote server
# Dependency - net-ssh gem
##############################################################
require 'rubygems'
require 'net/ssh'
@hostname = "test.example.com"
@username = "username"
@psahni
psahni / distance_indices.rb
Last active December 18, 2015 06:09
Adjacent Element Distance.
class InvalidRange < Exception;end
class InvalidLength < Exception;end
@pairs_distance = {}
def solution(arr)
if ( (arr.min < -214748364) || (arr.max > 214748364) )
raise InvalidRange.new("Invalid Range")
end
if (arr.length > 40000)
@psahni
psahni / boilerplate
Created August 9, 2013 13:49
boilerplate
* Front End development - It provides a framwork, to start working with html5
* Responsive develpment
* Html5 development
* Collection of templates
* Twitter Bootstarp + H5BP - Initializer project
[ Notes from the video http://www.youtube.com/watch?v=qyM37XKkmKQ ]
@psahni
psahni / mysql_remove_password
Created October 25, 2013 10:38
mysql_remove_password
# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
@psahni
psahni / bootstrap_form.css
Created November 14, 2013 13:05
Bootstrap css form example
<div class='row top-buffer'>
<div class='span7'>
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Email</label>
<div class="controls">
<input type="text" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="control-group">
1) Failure:
MultibyteCharsUTF8BehaviourTest#test_capitalize_bang_should_change_wrapped_string [/home/prashant/trantor/rails/activesupport/test/multibyte_chars_test.rb:126]:
Expected " él piDió Un bUen café " to not be equal to " él piDió Un bUen café ".
2) Failure:
MultibyteCharsUTF8BehaviourTest#test_capitalize_should_work_on_ascii_characters [/home/prashant/trantor/rails/activesupport/test/multibyte_chars_test.rb:449]:
Expected: "Abc"
Actual: abc
@psahni
psahni / tdd
Created February 20, 2014 12:53
Test driven development
- The difference between software engg. and programming is same as difference between surgery and cutting people open.
- There are many things that involves in the soft. dev. process like architecture, methodology, conventions and standards, version control, coordination with team members.
- Test provide better documentation of code, long term time savings, identify future errors.
- What TDD: what is code going to do
* Write a test, that will pass if the code does that thing
* Run the test, see it fail
* Write the code
* Run the test, see it pass
@psahni
psahni / custom_variables_desc.md
Last active August 29, 2015 13:57
Custom Variables Description - Getting Started

#Custom Variables

  • Custom variables are a way for you to insert custom data into Google Analytics.

  • Very useful for analyzing user behavior on page views

  • There are 4 parts to a custom variable: 1. The name of the variable 2. The values for each variable 3. The index or slot of the variable and the scope of the variable

  1. The scope of the variable
@psahni
psahni / trait.rb
Last active August 29, 2015 13:57
Custom Accessor
module Trait
def traits(*arr)
arr.each do |trait|
class_eval do
define_method trait.to_s + "=" do |val|
@trait||={}
@trait[trait] = val
end
end