Skip to content

Instantly share code, notes, and snippets.

View v1k45's full-sized avatar

Vikas v1k45

View GitHub Profile
@v1k45
v1k45 / tests.py
Last active March 24, 2016 07:41
tests for checking if issue #24 on django-notify-x is reproducible
from django.test import TestCase
from notify.signals import notify
from notify.models import Notification
from django.contrib.auth.models import User
from .models import Post
class NotificationCreateTestCase(TestCase):
def setUp(self):
@v1k45
v1k45 / .vimrc
Created September 12, 2017 05:44
My VIM config file
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
if has('vim_starting')
set nocompatible " Be iMproved
endif
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
let g:vim_bootstrap_langs = "javascript,python"
@v1k45
v1k45 / .zshrc
Created September 13, 2017 12:56
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/vikas/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="terminalparty"
@v1k45
v1k45 / to_json.py
Created July 28, 2018 20:16
hack to convert js object to json string
import re
import json
PRIMITIVE_DATA_GROUPER = r"(?P<initiator>\{|)(\s|)(?P<key>\w+):(\"|)(?P<value>(\B|[\w\s:-]+|\w+\((\"|)\w+(\"|)\)|function\(\)\{[\s\w\"\?\=:-]+\}))(\"|)(?P<terminator>,|\}|\},|\s,)"
OBJECT_DATA_GROUPER = r"(?P<key>\w+):(?P<identifier_token>(\{|\[))"
def get_data():
with open("data") as f:
content = f.read()
@v1k45
v1k45 / rebase.md
Created July 2, 2019 15:27
How to handle multi-dependent branch rebases

Consider three branches:

  • master

  • feature

    • sub-feature

    If due to some changes in master, a conflict arises in feature, the same conflict will also reflect in sub-feature.

    Do this to retain the commit history of feature in sub-feature for seamless branching.

@v1k45
v1k45 / aria2.py
Last active January 17, 2023 09:24
Helper class to interact with Aria2 XMLRPC
from xmlrpc.client import ServerProxy
class Aria2(ServerProxy):
def __init__(self, *args, **kwargs):
url = "http://aria2-host:6800/rpc"
super().__init__(url, *args, **kwargs)
def _ServerProxy__request(self, methodname, params):
params = ("token:rpc_secret_token", *params)
@v1k45
v1k45 / squashmigrations.md
Last active July 21, 2022 00:13
Quick and dirty django migration squashing

Using squashmigrations is a fucking pain.

Just delete all migration files

rm project/**/migrations/00*.py

Run makemigrations and fake migrate the database: