Skip to content

Instantly share code, notes, and snippets.

View laurentperrinet's full-sized avatar
👁️‍🗨️
Busy coding...

Laurent Perrinet laurentperrinet

👁️‍🗨️
Busy coding...
View GitHub Profile
#!/usr/bin/env python
# https://gist.github.com/laurentperrinet/94fbcc0dab15736cd66c9ffc669b625b
# install the API using `conda install openai` (MMV)
# setup your API key by including `export OPENAI_API_KEY="sk-xxxxxyyyyyyyzzzz"` in your `.zshrc` (MMV)
import argparse
parser = argparse.ArgumentParser(description='A simple CLI for chat-GPT with my prefered settings')
parser.add_argument('prompt', help="A useful prompt.", default='Demonstrate that the earth is flat.', type=str)
parser.add_argument("--max_tokens", help="Set the maximum tokens number", default=1000, type=int)
@laurentperrinet
laurentperrinet / fit_vonmises.py
Last active June 23, 2022 07:32
Quick function to fit a Von Mises distribution
import numpy as np
# https://en.wikipedia.org/wiki/Von_Mises_distribution
def tuning_function(theta, theta0, kappa, fmax, bsl, theta_bound):
# Von Mises, with kappa the concentration, theta0 the location
# fmax the firing rate at pref ori, bsl the min firing rate (not the baseline, which was substracted)
tf = bsl + np.exp(kappa*(np.cos(2*np.pi/theta_bound*(theta-theta0))-1)) * (fmax-bsl)
return tf
# we will use the tutorial from https://lmfit.github.io/lmfit-py/model.html :
@laurentperrinet
laurentperrinet / rename_files.py
Created August 4, 2020 08:33
A short python script to rename a bunch of files
#!/usr/bin/env python3
"""
rename a bunch of files given a glob pattern and change A into B
rename_files.py -g "**/*.pdf" -a "\\" -b "_" --dry-run
rename_files.py -g "**/*" -a "\\" -b "_"
"""
import argparse
@laurentperrinet
laurentperrinet / nb_remove_output.py
Last active March 26, 2017 07:27 — forked from decabyte/nb_remove_output.py
Remove output from Jupyter notebook from the command line
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Remove output from existing Jupyter Notebooks.
Modified from remove_output by Minrk, damianavila, gabraganca.
References:
[0]: https://github.com/jupyter/nbformat
[1]: http://nbformat.readthedocs.org/en/latest/index.html
[2]: http://blog.jupyter.org/2015/04/15/the-big-split/
@agramfort
agramfort / lasso_ista_fista.py
Created January 31, 2016 14:33
Lasso with ISTA and FISTA
#!/usr/bin/env python
#
# Solve LASSO regression problem with ISTA and FISTA
# iterative solvers.
# Author : Alexandre Gramfort, first.last@telecom-paristech.fr
# License BSD
import time
from math import sqrt
@rxaviers
rxaviers / gist:7360908
Last active September 21, 2024 18:09
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@timo
timo / conftest.py
Created May 6, 2012 11:10 — forked from minrk/checkipnb.py
collect ipython notebook files for py.test runs
# put this file into any folder under which ipynb files shall be collected.
import pytest
import os,sys
wrapped_stdin = sys.stdin
sys.stdin = sys.__stdin__
from IPython.zmq.blockingkernelmanager import BlockingKernelManager
sys.stdin = wrapped_stdin
from IPython.nbformat.current import reads