Skip to content

Instantly share code, notes, and snippets.

View spkprav's full-sized avatar
🧑‍🚀
spkprav@github:(me) $ git merge multiverse

Praveen Kumar S spkprav

🧑‍🚀
spkprav@github:(me) $ git merge multiverse
View GitHub Profile
@spkprav
spkprav / cookieLoginChromeExtension.js
Last active May 8, 2024 04:13
Cookie Login in Chrome Extension
// This goes into background/index.js
function parseJwt(token) {
// Decode base64url encoded string
function base64UrlDecode(str) {
return decodeURIComponent(
atob(str.replace(/_/g, "/").replace(/-/g, "+"))
.split("")
.map(c => '%' + c.charCodeAt(0).toString(16).padStart(2, '0'))
.join("")
);
@spkprav
spkprav / minute_notifier.py
Last active October 17, 2023 14:56
This is one of the strategies that I am using to catch a trade at the earliest, yet to work on automating the trade
# This script will fetch the notifier data from unstructured CSV data
# and convert that into structured and store the same into MongoDB
# This converted structured data is used to visualize in charts
import pdb
import os
import csv
import pandas as pd
import numpy as np
from datetime import datetime
<?php /* Template Name: Products */ ?>
<?php get_header()?>
<script type="text/javascript">
<?php
$pod = pods('product');
$params = array(
"where" => "d.product_price"
);
$pod->find($params,$limit=-1);
@spkprav
spkprav / Ubuntu, Rails, Puma and Nginx setup.md
Last active April 28, 2017 10:15
Ubuntu, Rails, Puma and Nginx setup

Install dependecies:

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

RVM Installation:

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
@spkprav
spkprav / dropbox
Last active May 10, 2016 12:43 — forked from lmammino/dropbox
Run dropbox CLI as service
#/etc/init.d/dropbox
start() {
echo "Starting dropbox..."
start-stop-daemon -b -o -c dropbox -S -x /dropbox/.dropbox-dist/dropboxd
}
stop() {
echo "Stopping dropbox..."
start-stop-daemon -o -c dropbox -K -x /dropbox/.dropbox-dist/dropboxd
@spkprav
spkprav / api_helper.md
Last active April 13, 2016 08:07
JSON Pagination using Kaminari
ERB File
# api/v1/posts/index.json.jbuilder
json.pagination paginate(@collection)

API Paginate Helper

Ruby
@spkprav
spkprav / web-fonts-asset-pipeline.md
Created April 1, 2016 10:56 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@spkprav
spkprav / ruby_setup.md
Created April 1, 2016 07:44 — forked from julionc/ruby_setup.md
Deploy Ruby On Rails on Ubuntu 14.04

Deploy Ruby On Rails on Ubuntu 14.04

Server: Nginx with Phusion Passenger

Ruby Version: 2.1.3

User System: deploy

User System

@spkprav
spkprav / install_passenger_nginx_digital_ocean.sh
Last active December 4, 2015 16:47 — forked from sathishmanohar/install_passenger_nginx_digital_ocean.sh
Steps to setup and install passenger nginx and rails on digital ocean
# Login as root
ssh root@domain
# Create deploy user
adduser <username> #Adds User with username given. Enter Password when Prompted. Other Details are Optional
# Add user to sudo group
usermod -g <groupname> <username>
# Add .ssh/authorized_keys for deploy user
@spkprav
spkprav / residence_search_hack.rb
Created October 8, 2015 11:30
Residence search hack
class Residency < ActiveRecord::Base
scope :filter, lambda { |query, *attributes|
return if query.blank?
attributes = self.new.attributes.keys if attributes.empty?
query.split(/\s/).inject(self) do |collection, phrase|
conditions = [""]
attributes.each do |attribute|
conditions[0] << attribute.to_s << " ILIKE ? OR "