Skip to content

Instantly share code, notes, and snippets.

View viveksinha's full-sized avatar
🎯
Focusing

Vivek Sinha viveksinha

🎯
Focusing
View GitHub Profile
@viveksinha
viveksinha / base64_padding.md
Created January 3, 2020 06:16 — forked from perrygeo/base64_padding.md
Avoiding TypeError: Incorrect padding with Python's base64 encoding

Avoiding padding errors with Python's base64 encoding

>>> import base64
>>> data = '{"u": "test"}'
>>> code = base64.b64encode(data)
>>> code
'eyJ1IjogInRlc3QifQ=='
@viveksinha
viveksinha / psql_useful_stat_queries.sql
Created September 12, 2019 07:46 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@viveksinha
viveksinha / primary_key_postgresql.sql
Last active May 14, 2019 06:06 — forked from mmasashi/example_query.txt
Get primary key columns on PostgreSQL/Amazon Redshift
SELECT
f.attnum AS number,
c.relname AS table_name,
f.attname AS column_name,
FROM pg_attribute f
JOIN pg_class c ON c.oid = f.attrelid
JOIN pg_type t ON t.oid = f.atttypid
LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = f.attnum
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_constraint p ON p.conrelid = c.oid AND f.attnum = ANY (p.conkey)
@viveksinha
viveksinha / file0.txt
Created December 17, 2018 07:35 — forked from giwa/file0.txt
Install hive on Mac with Homebrew ref: http://qiita.com/giwa/items/dabf0bb21ae242532423
$ brew update
$ brew install hive
@viveksinha
viveksinha / table_relationships.sql
Created August 29, 2018 05:58
one-to-many and many-to-many table relationships design
-- One-to-many relationship
CREATE TABLE customers (
customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
);
@viveksinha
viveksinha / InnerJoin_LeftJoin_RightJoin.sql
Last active August 29, 2018 05:19
Different types of SQL JOIN clauses and their use
CREATE TABLE `advisors` (
`advisor_id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
PRIMARY KEY (`advisor_id`)
)
CREATE TABLE `students` (
`student_id` int(11) NOT NULL AUTO_INCREMENT,
@viveksinha
viveksinha / update_column_type.sql
Created August 16, 2018 06:55 — forked from mmasashi/update_column_type.sql
How to change the column type for Redshift.
BEGIN;
LOCK table_name;
ALTER TABLE table_name ADD COLUMN column_new column_type;
UPDATE table_name SET column_new = column_name;
ALTER TABLE table_name DROP column_name;
ALTER TABLE table_name RENAME column_new TO column_name;
END;
-- varchar -> integer
-- UPDATE cpvbeacon_dev SET column_new = CAST (nullif(column_name, '') AS INTEGER);
@viveksinha
viveksinha / firefox-gestures.md
Created June 14, 2018 08:53 — forked from louischan/firefox-gestures.md
Enable Multi-touch Gestures in Firefox
  1. Open about:config in Firefox
  2. Set the following values
  3. Restart Firefox
browser.snapshots.limit           5
browser.gesture.pinch.in          cmd_fullZoomReduce
browser.gesture.pinch.out         cmd_fullZoomEnlarge
browser.gesture.pinch.latched     false
browser.gesture.pinch.threshold 35
@viveksinha
viveksinha / TestHttp.java
Created June 7, 2018 16:44 — forked from ttreitlinger/TestHttp.java
apache http client sample
package http;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
@viveksinha
viveksinha / rm_mysql.md
Created May 1, 2018 03:10 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql