Skip to content

Instantly share code, notes, and snippets.

View shrayasr's full-sized avatar

Shrayas Rajagopal shrayasr

View GitHub Profile
@shrayasr
shrayasr / keybase.md
Created March 25, 2015 18:24
keybase.md

Keybase proof

I hereby claim:

  • I am shrayasr on github.
  • I am shrayasr (https://keybase.io/shrayasr) on keybase.
  • I have a public key whose fingerprint is 12A3 E09D 419C 1251 CEDA 92F9 3375 F9A3 8F7E CFC6

To claim this, I am signing this object:

@shrayasr
shrayasr / emmet-awesomeness.md
Last active August 29, 2015 14:17
Emmet Awesomeness

Emmet Awesomeness

Lets face it, writing HTML is really not a fun thing to do. With so many < and so many > and all the horrific closing tags. There has to be a better way.

Enter Emmet. Emmet is a plugin for many text editors that makes the job of writing HTML super easy. It provides a bunch of abbreviations whose syntax is inspired by CSS.

@shrayasr
shrayasr / bulk-insert-sa.md
Last active December 11, 2020 16:04
Bulk Inserts via SQLAlchemy and Flask-SQLAlchemy

Bulk Inserts via SQLAlchemy and Flask-SQLAlchemy

Problem

I ran into an issue today where I had to perform a bulk insert into a postgres DB. I was already using SQLAlchemy and Flask-SQLAlchemy to manage the connections to the db and I didn't want to have to use things like psycopg2 directly.

Solution

Note: SQLAlchemy provides an ORM. It isn't just an ORM. That is an important thing to be kept in mind. This means that you can bypass choose to not use the ORM layer when you don't want it. The idea with an ORM is to track changes to objects and when you have a case like that is when you'd use the ORM. In a bulk upload scenario, you don't need to track changes to objects. All you care is that everything be pushed into the DB.

@shrayasr
shrayasr / sort-and-awk-inside-file.md
Last active August 29, 2015 14:16
Summing a list of numbers from within a file using the shell

File containing numbers

Andaman Nicobar,25
Andhra Pradesh,3550
Arunachal Pradesh,37
Assam,616
Bihar,1777
Chandigarh,32
Chhattisgarh,313
Dadra & Nagar Haveli,3

Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

This is where any fun you might have been having ends. Now it’s time to get serious and talk about rules.

Writing CSS is hard. Even if you know all the intricacies of position and float and overflow and z-index, it’s easy to end up with spaghetti code where you need inline styles, !important rules, unused cruft, and general confusion. This guide provides some architecture for writing CSS so it stays clean and ma

@shrayasr
shrayasr / titbits.txt
Last active August 29, 2015 14:12
Programming titbits
// C# | Sorted list, and iterating through them
int value = 1;
SortedList<string, int> sl = new SortedList<string, int>();
sl.add("key", value)
foreach(KeyValuePair<string,int> kv in sl)
{
Console.WriteLine(kv.Key + "=>" + kv.Value);
}
@shrayasr
shrayasr / pair-program-tmux.md
Last active March 29, 2022 13:58
Pair programming with Tmux

Pair programming with Tmux

Using the same user

User 1

  1. SSH into the box

     user1@user1-machine$ ssh user@host
    
@shrayasr
shrayasr / win-dev-env.md
Last active September 18, 2018 15:45
Setting up my windows dev environment

Setting up my development environment on windows

So, I recently switched jobs and moved from SAP to Logic Soft Pvt. Ltd. We here @ Logic Soft build applications on the windows platform. Which makes it absolutely necessary for me to have a windows laptop.

Today, The Dell Inspiron 15 5000 series (5547) that I ordered came in. Really nice piece of hardware. This document entails my journey in setting up a decently functional development environment

@shrayasr
shrayasr / update-sidebar-praw.md
Last active August 9, 2020 08:33
Updating sidebar content with PRAW

Updating reddit sidebar content with PRAW

PRAW is the AWESOME Reddit API Wrapper written in Python.

Download PRAW

pip install praw

Import PRAW

@shrayasr
shrayasr / getting-started-with-flask-login.md
Last active June 30, 2019 15:46
Getting started with Flask-Login

Getting started with Flask-Login

Pre-requisites

  • Flask pip install flask
  • Flask-Login pip install flask-login

Steps

  • Create your user model class: User. This would be a class that stores information about your User. Essentially the user_name, user_id, email, etc.