Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
Unlimited Code Works! ⚔️

Shivansh Saini shivanshs9

🔥
Unlimited Code Works! ⚔️
View GitHub Profile
@shivanshs9
shivanshs9 / System Design.md
Created Feb 2, 2021 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@shivanshs9
shivanshs9 / gist:b321f21bf78cedd660ee94f1d4352eb1
Created Sep 5, 2020
Script to simultaneously reassign owner of all tables in a given DB (source: https://stackoverflow.com/a/2686185/2674983)
View gist:b321f21bf78cedd660ee94f1d4352eb1
### Use:
# reassign_owner dbName newOwner oldOwner/root dbHost
reassign_owner() {
db="$1"
newUser="$2"
owner="${3:-$newUser}"
dbHost="$4"
local pw
echo -n "Password: " > /dev/tty
@shivanshs9
shivanshs9 / git-backcommit
Last active Jul 22, 2020
Wraps 'git commit' command to override AuthorDate and CommitDate (if date is provided)
View git-backcommit
#!/usr/bin/env bash
## Copyright 2020 Shivansh Saini<shivanshs9@gmail.com>
# Licensed under MIT
usage() {
cat << EOD
Usage: `basename $0` [options] [date] -- [commit args]
View versioning.yml
name: Keep the versions up-to-date
on:
release:
types: [published, edited]
jobs:
actions-tagger:
runs-on: ubuntu-latest
steps:
- uses: Actions-R-Us/actions-tagger@v2
env:
View build-release.yml
# Combined workflow to build and create release
## It's an hack until https://github.community/t/triggering-a-new-workflow-from-another-workflow/16250/24 is solved by Github
---
name: Build and Release
on:
push:
branches:
- master
jobs:
build:
@shivanshs9
shivanshs9 / a2dp.py
Last active Jun 22, 2020 — forked from pylover/a2dp.py
Fixing bluetooth stereo headphone/headset problem in ubuntu 16.04, 16.10 and also debian jessie, with bluez5.
View a2dp.py
#! /usr/bin/env python3
"""
Fixing bluetooth stereo headphone/headset problem in ubuntu 16.04 and also debian jessie, with bluez5.
Workaround for bug: https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197
Run it with python3.5 or higher after pairing/connecting the bluetooth stereo headphone.
This will be only fixes the bluez5 problem mentioned above .
@shivanshs9
shivanshs9 / adb_backup.zsh
Created May 22, 2020
Backup folders locally via adb
View adb_backup.zsh
input=()
for path in /sdcard/{"Pictures","Download","DCIM"}; do
input+=$(adb shell "ls -d '$path'")
done
for path in $input; do
adb pull $path &
done
View rename-database.sql
DROP PROCEDURE IF EXISTS moveTables;
DROP PROCEDURE IF EXISTS renameDatabase;
DELIMITER $$
CREATE PROCEDURE moveTables(_schemaName varchar(100), _newSchemaName varchar(100))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE table_name VARCHAR(64);
DECLARE table_cursor CURSOR FOR SELECT information_schema.tables.table_name FROM information_schema.tables
WHERE information_schema.tables.table_schema = _schemaName;
View keybase.md

Keybase proof

I hereby claim:

  • I am shivanshs9 on github.
  • I am shivanshs9 (https://keybase.io/shivanshs9) on keybase.
  • I have a public key whose fingerprint is AB5F BF93 4643 CDEF C77F 7686 4A92 F697 E2C6 C0FC

To claim this, I am signing this object:

@shivanshs9
shivanshs9 / mixins.py
Created Dec 8, 2018
Mixin for Django Rest Framework View/Viewsets to use different response data/serializers without unnecessary hacks.
View mixins.py
class UnsafeResponseSerializerMixin(object):
"""
Apply this mixin to any view or viewset to automatically use a different response
serializer on POST, PUT or PATCH requests.
Override 'get_response_data' method to return back the desired data, or
'get_response' method to also provide additional changs to the returned Response.
"""
def get_response_data(self, request):