Skip to content

Instantly share code, notes, and snippets.

@stefanschmidt
stefanschmidt / remove-annotations.sh
Last active February 1, 2024 17:01
Remove all annotations from a PDF document
pdftk original.pdf output uncompressed.pdf uncompress
LANG=C sed -n '/^\/Annots/!p' uncompressed.pdf > stripped.pdf
pdftk stripped.pdf output final.pdf compress
@jrsmith3
jrsmith3 / doi2bib.py
Last active May 17, 2024 17:43
Python method to access crossref.org DOI bibtex metadata resolver
import requests
def doi2bib(doi):
"""
Return a bibTeX string of metadata for a given DOI.
"""
url = "http://dx.doi.org/" + doi
headers = {"accept": "application/x-bibtex"}
@niksumeiko
niksumeiko / git.migrate
Last active November 10, 2024 18:26
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@andydawson
andydawson / gradient.md
Last active April 12, 2023 09:03
Manual gradient in Stan 2.10

Implementing your own gradient function in Stan.

Here's a summary of how to implement a gradient function manually in Stan 2.10 in order to override autodiff. I wanted to do this because my run-times were long, and I knew I could save some time by hard-coding my gradient function. That being said, autodiff is great, and is almost always fast enough.

Step 1. Create the .stan file which implements the model.

Two reasons to do this:

  1. This will allow you to easily generate a .cpp file that will contain the basic structure you need.
  2. Great for testing to make sure your hacked code gives identical output to what you would get using Stan.
@patriciogonzalezvivo
patriciogonzalezvivo / PythonSetup.md
Created October 7, 2014 23:17
How to install Python correctly on Mac OSX

Install Homebrew

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Add PATH to ~/.bash_profile and ~/.zshrc

export PATH=/usr/local/bin:$PATH
@jg-you
jg-you / draw_nx_beautiful.py
Last active October 30, 2022 00:04
Beautiful networkx graph
import copy
import networkx
import matplotlib.pyplot as plt
# Generate a graph.
# Here I chose an ER graph.
g = nx.erdos_renyi_graph(20, 0.3)
# Get positions.
# Here I use the spectral layout and add a little bit of noise.
@CaroManel
CaroManel / git-reset-remote.sh
Created March 2, 2017 03:41
Reset remote git repository to delete all commits
rm -r .git
git init
(create files)
git add -A
git commit -m 'Initial commit'
git remote add origin <url>
git push --force --set-upstream origin master
@jnaecker
jnaecker / git+overleaf+github.md
Last active June 24, 2024 06:25
Using Overleaf as your TeX editor but getting your files to Github

git + overleaf + github

Setup

Connect Overleaf and your local repo

  1. Make a new project on Overleaf.
  2. In the share menu, copy the link from "Clone with git"
  3. On your computer:
    • use cd to navigate to where you want to put your project
rm -rf ~/.atom
rm -rf /usr/local/bin/atom
rm -rf /usr/local/bin/apm
rm -rf /Applications/Atom.app
rm -rf ~/Library/Preferences/com.github.atom.plist
rm -rf ~/"Library/Application Support/com.github.atom.ShipIt"
rm -rf ~/"Library/Application Support/Atom"
rm -rf ~/"Library/Saved Application State/com.github.atom.savedState"
rm -rf ~/Library/Caches/com.github.atom
rm -rf ~/Library/Caches/com.github.atom.Shipit
@goweiting
goweiting / install.conda.md
Last active January 7, 2021 17:05
Installing graph-tool with other packages staying in an virtual env (conda)

There is no guarantee that this will work, i wrote this so in case anyone else have the same goal in mind. Using: Ubuntu 16.04; miniconda2

What i want to achieve:

  1. use graph-tool
  2. all other packages should fall in a virtual environment

Failed attempts:

  1. I attempted to build graph-tool from scratch but did not work, and couldnt seem to pull everything together.
  2. Attempt to use all the graph-tool packages on anaconda cloud... (idgi)