Skip to content

Instantly share code, notes, and snippets.

View vijayparikh's full-sized avatar

Vijay Parikh vijayparikh

View GitHub Profile
@vijayparikh
vijayparikh / 55-bytes-of-css.md
Created September 25, 2022 15:44 — forked from JoeyBurzynski/55-bytes-of-css.md
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@vijayparikh
vijayparikh / README.md
Created June 18, 2021 07:57 — forked from mrkpatchaa/README.md
Bulk delete github repos

Use this trick to bulk delete your old repos or old forks

(Inspired by https://medium.com/@icanhazedit/clean-up-unused-github-rpositories-c2549294ee45#.3hwv4nxv5)

  1. Open in a new tab all to-be-deleted github repositores (Use the mouse’s middle click or Ctrl + Click) https://github.com/username?tab=repositories

  2. Use one tab https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall to shorten them to a list.

  3. Save that list to some path

  4. The list should be in the form of “ur_username\repo_name” per line. Use regex search (Sublime text could help). Search for ' |.*' and replace by empty.

@vijayparikh
vijayparikh / listen.py
Created September 5, 2020 13:40 — forked from kissgyorgy/listen.py
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@vijayparikh
vijayparikh / s3cmd_sync.sh
Created April 24, 2020 19:27 — forked from niraj-shah/s3cmd_sync.sh
s3cmd commands to sync folders to AWS S3
# Command Line to run from terminal
# Logs result to file s3_backup.log
# Command will run in the background
s3cmd sync -v /path/to/folder/ s3://s3-bucket/folder/ > s3_backup.log 2>&1 &
# Crontab command to sync folder to S3
# Command will run 1am every day and logs result to /root/s3_backup.log
0 1 * * * /usr/bin/s3cmd sync -rv /path/to/folder/ s3://s3-bucket/folder/ >> /root/s3_backup.log
@vijayparikh
vijayparikh / SFTP on Amazon S3
Created August 14, 2018 20:17
Setup an SFTP server through an Amazon AWS EC2 Instance
If you need to access/manage files stored on Amazon S3 bucket via SFTP, you can mount the bucket to a file system on a Linux server and access the files using the SFTP as any other files on the server.
Creating Access Server
Launch a new Amazon EC2 server. A basic Amazon Linux AMI (free tier eligible) server will generally suffice and the following instructions are tested on this distribution. Instructions for other distributions may differ.
To install the s3fs file system
- Login to your Linux server via SSH.
@vijayparikh
vijayparikh / membersof.rb
Created June 12, 2018 16:06
Get a list of users and email from slack channel or group
#!/usr/bin/env ruby
require 'optparse'
require 'open-uri'
require 'json'
require 'csv'
options = {}
ARGV << '-h' if ARGV.empty?
OptionParser.new do |opts|
@vijayparikh
vijayparikh / qrCode.swift
Created March 15, 2018 06:53
Generate a QRCode and scale it to a UIImageView working perfectly for AppleTV 4K, iPhone X and iPadPro using Xcode 9.2
@IBOutlet weak var qrCodeBox: UIImageView!
func createQRFromString(_ str: String, size: CGSize) -> UIImage {
let stringData = str.data(using: .utf8)
let qrFilter = CIFilter(name: "CIQRCodeGenerator")!
qrFilter.setValue(stringData, forKey: "inputMessage")
qrFilter.setValue("H", forKey: "inputCorrectionLevel")
let minimalQRimage = qrFilter.outputImage!
@vijayparikh
vijayparikh / ArrayMerge.java
Last active February 16, 2018 23:01
Merge two sorted arrays of different sizes efficiently
import java.io.*;
import java.util.*;
import java.text.*;
public class ArrayMerge {
public static int[] merge(int[] A, int[] B) {
int i, j, k, m, n;
i = 0;
j = 0;
@vijayparikh
vijayparikh / gps_distance.rb
Last active January 11, 2017 06:29
Ruby class to calculate distance in between too lat,long coordinates using the Great Circle algorithm
module GPS
class Distance
RAD_PER_DEG = Math::PI / 180
GREAT_CIRCLE_RADIUS_MILES = 3956
GREAT_CIRCLE_RADIUS_KILOMETERS = 6371 # some algorithms use 6367
GREAT_CIRCLE_RADIUS_FEET = GREAT_CIRCLE_RADIUS_MILES * 5280
GREAT_CIRCLE_RADIUS_METERS = GREAT_CIRCLE_RADIUS_KILOMETERS * 1000
GREAT_CIRCLE_RADIUS_NAUTICAL_MILES = GREAT_CIRCLE_RADIUS_MILES / 1.15078
attr_accessor :great_circle_distance