Skip to content

Instantly share code, notes, and snippets.

View sudarshan85's full-sized avatar

sudarshan sudarshan85

  • University of Tenneessee
  • Knoxville, TN
View GitHub Profile
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@masih
masih / fish_shell_local_install.sh
Last active November 15, 2024 03:54
Installs Fish Shell without root access
#!/bin/bash
# Script for installing Fish Shell on systems without root access.
# Fish Shell will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
FISH_SHELL_VERSION=2.1.1
@Zearin
Zearin / python_decorator_guide.md
Last active April 26, 2025 15:21
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@ericdouglas
ericdouglas / super-tip.txt
Last active October 6, 2024 18:28
Change 4 spaces to 2 spaces indentation and change tab to spaces - Vim tip
// 4 spaces to 2 spaces
%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
// Tab to 2 spaces
:%s/\t/ /g
@t-vi
t-vi / validation_set_split.py
Last active August 18, 2017 16:08
Torch validation set split (MNIST example)
import torch.utils.data
from torchvision import datasets, transforms
class PartialDataset(torch.utils.data.Dataset):
def __init__(self, parent_ds, offset, length):
self.parent_ds = parent_ds
self.offset = offset
self.length = length
assert len(parent_ds)>=offset+length, Exception("Parent Dataset not long enough")
super(PartialDataset, self).__init__()
@Kshitij09
Kshitij09 / PrintCallback.py
Last active June 20, 2020 12:31
`PrintCallback` for PytorchLightining to create tabular logs of metrics in Jupyter Notebook
import torch
from pytorch_lightning import Callback
from IPython.display import display, clear_output
import copy
import pandas as pd
def unwrap(x):
if isinstance(x,torch.Tensor):
return x.item()
return x
@jph00
jph00 / py.md
Last active May 31, 2022 06:16
Organized and hyperlinked index to every module, function, and class in the Python standard library

All of the python 3.9 standard library

For a version without the collapsible details sections (so you can search the whole thing in your browser), click here.

df_test = pd.DataFrame(test_ds, columns=['text', 'author'])
# make a unique list of authors
auth = sorted(set(df['author']))
# make a dict of possible signatures where key is the labeled entity and value is a list of possible signatures
auth_dict = {}
auth_dict[auth[0]] = ['ben', 'benjamin', 'rogers', 'benjamin rogers','ben rogers','br']
auth_dict[auth[1]] = ['chris', 'dorland','chris dorland','cd']
auth_dict[auth[2]] = ['drew','fossum','drew fossum','df']
auth_dict[auth[3]] = ['jeffrey','shankman','jeffrey shankman','js']
auth_dict[auth[4]] = ['kevin','presto','kevin presto','kp']
@Maharshi-Pandya
Maharshi-Pandya / contemplative-llms.txt
Last active May 14, 2025 00:59
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference