Skip to content

Instantly share code, notes, and snippets.

@nitinhayaran
nitinhayaran / smartLookEvent.js
Created February 3, 2021 13:24
smartLookEvent.js
import smartlookClient from 'smartlook-client'
const SmartLookEvent = {
initialize: () => {
const isBotUserAgent = () => {
return (
navigator &&
navigator.userAgent &&
/bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|prerender/i.test(
navigator.userAgent
@nitinhayaran
nitinhayaran / restore.md
Created December 22, 2017 14:00
How to restore specific tables on heroku from backup

How to restore specific tables on heroku from backup

  1. Create a new database instance attached to current application
  2. Restore latest database backup on newly created database
  3. Get the connection url of this backup database. Use this URL in later sql queries.
  4. Connect to database where we have incorrect data
heroku pg:psql --app ck-api-prod
  1. On postgres prompt run following queries. This will create copy table from data in backup database.
@nitinhayaran
nitinhayaran / s3-bucket-move
Created March 16, 2017 09:08 — forked from alanwill/s3-bucket-move
Move an S3 bucket to a different region
aws s3 sync s3://oldbucket s3://newbucket --source-region us-west-1 --region us-west-2
@nitinhayaran
nitinhayaran / gist:e8fe703f79a9da4a5fe5
Last active January 4, 2019 11:19
Import heroku database
heroku pg:backups capture --app sushi
curl -o latest.dump `heroku pg:backups public-url --app sushi`
pg_restore --verbose --clean --no-acl --no-owner -j 8 [-U user_name] -d database_name latest.dump
# To copy prodcution data to staging app
heroku pg:backups restore `heroku pgbackups:url -a production-app` DATABASE -a staging-app
# Store prodcution data to staging
heroku pg:backups restore `heroku pgbackups:url -a production-app` DATABASE -a staging-app
heroku pg:backups restore b001 DATABASE_URL --app sushi
Verifying that +nitinh is my Bitcoin username. You can send me #bitcoin here: https://onename.io/nitinh
@nitinhayaran
nitinhayaran / detectFiles.js
Created July 18, 2014 10:59
Test if dragenter/dragover event contains files
function containsFiles(event) {
if (event.dataTransfer.types) {
for (var i = 0; i < event.dataTransfer.types.length; i++) {
if (event.dataTransfer.types[i] == "Files") {
return true;
}
}
}
return false;
}
@nitinhayaran
nitinhayaran / flickr_urls
Last active April 29, 2023 03:59
Flickr Photo urls size suffixes along with url returned from apis
url_sq : s small square 75x75
url_q : q large square 150x150
url_t : t thumbnail, 100 on longest side
url_s : m small, 240 on longest side
url_n : n small, 320 on longest side
url_m : - medium, 500 on longest side
url_z : z medium 640, 640 on longest side
url_c : c medium 800, 800 on longest side†
url_l : b large, 1024 on longest side*
url_o : o original image, either a jpg, gif or png, depending on source format
@nitinhayaran
nitinhayaran / css_resources.md
Created June 4, 2014 11:48 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@nitinhayaran
nitinhayaran / python_resources.md
Created June 4, 2014 11:48 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@nitinhayaran
nitinhayaran / javascript_resources.md
Created June 4, 2014 11:48 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage