Skip to content

Instantly share code, notes, and snippets.

View prayashm's full-sized avatar
🌴
In code we trust!

Prayash Mohapatra prayashm

🌴
In code we trust!
View GitHub Profile
@prayashm
prayashm / data.json
Created August 3, 2021 19:53
Sendgrid Dynamic template renders fine in Code studio, but not when sent as email
{
"items": [1, 2, 3]
}

Keybase proof

I hereby claim:

  • I am prayashm on github.
  • I am prayash (https://keybase.io/prayash) on keybase.
  • I have a public key ASDugapoAxOlxVOvH0d-Yv_YLYy_hGMmAUrNnqOSHhhGvAo

To claim this, I am signing this object:

@prayashm
prayashm / using_defaultdict.py
Created May 30, 2018 10:47
Using Defaultdict
from collections import defaultdict
new_dict = defaultdict(int)
old_dict = {'one': 1, 'two': 2} # One returned from API
new_dict.update(old_dict)
new_dict['one'] # returns 1
new_dict['not_there'] # returns 0
@prayashm
prayashm / graph.py
Created February 5, 2018 19:09
Realtime Graphs in Bokeh
from bokeh.plotting import figure, curdoc
from bokeh.driving import linear
from impact import from_csv, reader
import random
p = figure(plot_width=1000, plot_height=600)
r1 = p.line([], [], color="firebrick", line_width=2)
r2 = p.line([], [], color="limegreen", line_width=2)
r3 = p.line([], [], color="limegreen", line_width=2)
@prayashm
prayashm / parseUri.js
Created August 29, 2017 13:01
Parse URI
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
@prayashm
prayashm / install-docker.sh
Last active July 23, 2017 06:06 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"

Keybase proof

I hereby claim:

  • I am prayashm on github.
  • I am prayash (https://keybase.io/prayash) on keybase.
  • I have a public key whose fingerprint is 132E F3E8 13DB 68E9 62A7 3E5C 7F6A 04FD D83B C656

To claim this, I am signing this object:

function isElementInViewport (el) {
//special bonus for those using jQuery
if (typeof jQuery === "function" && el instanceof jQuery) {
el = el[0];
}
var rect = el.getBoundingClientRect();
return (
var Xpath = {};
// ********************************************************************************************* //
// XPATH
/**
* Gets an XPath for an element which describes its hierarchical location.
*/
Xpath.getElementXPath = function(element)
{
ALTER TABLE `review` AUTO_INCREMENT=1