Skip to content

Instantly share code, notes, and snippets.

View asinghvi17's full-sized avatar
📑

Anshul Singhvi asinghvi17

📑
View GitHub Profile
@asinghvi17
asinghvi17 / fitzhugh_nagumo_makielayout.jl
Last active May 10, 2022 19:46
Gist of one of my FHN MakieLayout figures
using Makie, MakieTeX, CairoMakie
# Makie v0.17 and associated packages
using DifferentialEquations, Polynomials
# define the default theme
Makie.set_theme!(Theme(
font = "CMU Serif",
fontsize = 12, # 12,
Axis = (
@asinghvi17
asinghvi17 / cobweb.jl
Last active May 7, 2022 14:47
Interactive cobweb plot with Makie
using Makie, GLMakie
f(x::Real, r::Real) = r * x * (1 - x)
function cobweb(
xᵢ::Real,
curve_f::Function,
r::Real;
nstep::Real = 30
)::Vector{Point2f} # col 1 is x, col 2 is y
@asinghvi17
asinghvi17 / insert_pdf_description.jl
Created May 7, 2022 14:27
PDF metadata writing script for Julia
# Author: Anshul Singhvi
# Works as of 20220507
# Basically, the function is used to edit the metadata of a PDF using Ghostscript
# This could be made pure-Julian with the right logic (searching for keywords, etc.)
# but that is annoying to do.
using Ghostscript_jll
const AUTHOR = Ref{String}("Anshul Singhvi")
@asinghvi17
asinghvi17 / position_popup.jl
Created August 6, 2020 00:46
Makie position popup along multiple axes
using Makie
using Makie.AbstractPlotting.MakieLayout
function position_popup!(
scene, axes;
formatter = (point::Point2f0) -> string(round.(Float64.(point), digits = 3)),
)
visible = Observable(false)
@asinghvi17
asinghvi17 / tex_prototype.jl
Last active March 15, 2023 01:22
TeX rendering handled using Julia - mostly in memory!
# Generate the tex file
rawtex = raw"""
\documentclass{standalone}
\begin{document}
\[\left[{\frac{-\hbar^{2}}{2m}}\nabla^{2}+V(\mathbf{r})\right]\Psi(\mathbf{r}) = E\Psi(\mathbf{r})\] % Schrodinger equation
\end{document}
"""
lua_stdin = IOBuffer(writable = true)
# setup
# import Pkg;
# Pkg.pkg"add Makie#master PlotUtils GeoInterface GeoJSON"
using Makie
using GeoInterface, GeoJSON
using PlotUtils
states = download("https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/us-states.json")
@asinghvi17
asinghvi17 / frequency_estimator.py
Created June 28, 2019 15:16 — forked from endolith/frequency_estimator.py
Frequency estimation methods in Python
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread
## setup differential equation
using DifferentialEquations,
ParameterizedFunctions
lorenz = @ode_def Lorenz begin # define the system
dx = σ * (y - x)
dy = x * (ρ - z) - y
dz = x * y - β*z
end σ ρ β
#!/usr/bin/env julia
### USAGE
# GITHUB_AUTH="MY_GITHUB_AUTH_TOKEN_HERE" FILENAME.jl <per-package usage>
###
## NOTE:
# To set this up, you will need to change the two constants below
# to the user who will fork,
# and the organization which owns the repos.
@asinghvi17
asinghvi17 / mkprojects.jl
Last active May 1, 2019 19:23
Create Project.tomls for an entire organization's repos.
#!/usr/bin/env julia
### USAGE
# GITHUB_AUTH="MY_GITHUB_AUTH_TOKEN_HERE" mkproj.jl <packages names (WITH .jl)>...
###
## NOTE:
# To set this up, you will need to change the two constants below
# to the user who will fork,
# and the organization which owns the repos.