Skip to content

Instantly share code, notes, and snippets.

View meetrajesh's full-sized avatar

Rajesh Kumar meetrajesh

View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 21 columns, instead of 15 in line 8.
Type,Permitted,Country,Region,County,City,Delivery Region,Delivery County,Delivery City,Day,Month,Year,Weekday,StartTime,EndTime,Types,Delivery Postal Codes,AddressType,QtyBeerAllowed,QtyWineAllowed,QtySpiritsAllowed
ALCOHOL,ALLOWED,CA,AB,ANY,ANY,AB,ANY,ANY,ANY,ANY,ANY,ANY,10:00 ,23:59 ,DELIVERY,,ANY,ANY,ANY,ANY
ALCOHOL,PROHIBITED,CA,ON,ANY,ANY,ON,ANY,ANY,ANY,ANY,ANY,ANY,9:00 ,23:00,DELIVERY,,Residential,ANY,ANY,ANY
ALCOHOL,ALLOWED,US,AZ,ANY,ANY,AZ,ANY,ANY,ANY,ANY,ANY,ANY,6:00 ,23:59 ,CURBSIDE_AND_NON_CURBSIDE_AND_DELIVERY,,ANY,ANY,ANY,ANY
ALCOHOL,ALLOWED,US,CA,ANY,ANY,CA,ANY,ANY,ANY,ANY,ANY,ANY,6:00 ,23:59 ,CURBSIDE_AND_NON_CURBSIDE_AND_DELIVERY,,ANY,ANY,ANY,ANY
ALCOHOL,PROHIBITED,US,CO,ANY,ANY,CO,ANY,ANY,25,12,ANY,ANY,ANY,ANY,DELIVERY,,ANY,ANY,ANY,ANY
ALCOHOL,ALLOWED,US,CO,ANY,ANY,CO,ANY,ANY,ANY,ANY,ANY,ANY,8:00 ,23:59 ,DELIVERY,,ANY,ANY,ANY,ANY
ALCOHOL,ALLOWED,US,CT,ANY,ANY,CT,ANY,ANY,ANY,ANY,ANY,MON,8:00 ,22:00 ,DELIVERY,,ANY,ANY,ANY,ANY
ALCOHOL,ALLOWED,US,CT,ANY,ANY,CT,ANY,ANY,ANY,ANY,ANY,TUE,8:00 ,22:00
@meetrajesh
meetrajesh / substring_palindromes.rb
Last active October 24, 2017 20:21
Given an arbitrary string (without spaces), print out all substrings that are palindromes
# Given an arbitrary string (without spaces), print out all substrings that are palindromes
def generate_random_string(n)
n.times.map { rand(97..122).chr }.join
end
# SLOW SOLUTION
def all_substrings(chars)
len = chars.length
Not in US
A-1
A-2
A-3
AOS Applicant
Asylee
Asylum Applicant
B-1
B-2
C-1
@meetrajesh
meetrajesh / gist:ddc32f10b7d6481743e6
Last active August 29, 2015 14:07
reindex thin elastic with custom names
# update thin merchant index with new field
include Utils::Business
ThinMerchant.elastic_scan_update do |t|
# only perform this reindex for Nevada for now
next t if t['state'] != 'NV'
tm = ThinMerchant.find_by_id(t['thin_merchant_id'])
if tm
service = Service.find(t['service_id'])
if (external_services = tm.highest_priority_external_services(service).presence) && external_services.count > 0
custom_variation_names = external_services.map(&:variation_name)
@meetrajesh
meetrajesh / gist:5280892
Last active December 15, 2015 15:19
Quick Guide on How to Get Started on Meditation
To get started on meditation, just follow these steps:
Just Sit: Commit to doing nothing more than sitting quietly and watching what
happens. Don't pick up the phone, don't answer the doorbell, don't add
another item to your to-do list. Just sit and observe the thoughts that arise
and pass through your mind. You will likely be surprised by how difficult it
is to sit quietly for 10 minutes. In the process, though, you may learn
something important about the qualities of the restless mind and the
ever-changing nature of life.
@meetrajesh
meetrajesh / binary_search_tree.php
Last active January 18, 2022 16:53
An efficient binary search tree (BST) implementation in PHP.
<?php
class BinarySearchTree {
private $_root;
public function __construct() {
// setup sentinal node
$this->_root = new BinarySearchNode(null);
}
public function getRoot() {
return $this->hasNode() ? $this->_root->right : null;
@meetrajesh
meetrajesh / hash_table.php
Created December 14, 2012 05:12
Basic implementation of a hash table in PHP with collision detection and management (no locking support)
<?php
class HashTable {
private $_array = array();
private $_size = 10000;
public function __construct($size=0) {
$size = (int)$size;
if ($size > 0) {
@meetrajesh
meetrajesh / linked_list.php
Created October 5, 2012 03:06
PHP Linked List Implementation
<?php
class Node {
private $_data;
public $next;
public function __construct($data) {
$this->_data = $data;
}
@meetrajesh
meetrajesh / cons_duplicates.rb
Created June 14, 2012 14:29
Remove consecutive duplicates in an array in Ruby
def remove_consecutive_duplicates(xs)
[xs.first] + xs.each_cons(2).select do |x,y|
x != y
end.map(&:last)
end
remove_consecutive_duplicates([1, 2, 2, 3, 1])
#=> [1,2,3,1]
@meetrajesh
meetrajesh / stack.class.php
Created May 29, 2012 16:55
The Simplest Implementation of a PHP Stack
class stack {
private $arr = array();
public function push($s) {
$this->arr[] = $s;
}
public function pop() {
return array_pop($this->arr);