Skip to content

Instantly share code, notes, and snippets.

## * Packages
library(mise)
mise()
## * Constnats .............................................
## Observed Values
obs <- rbind(
c(1070, 1090, 1090),
c(1090, 1020, 990)
)
@RyanGreenup
RyanGreenup / skim_local_mediawiki.bash
Created August 2, 2021 06:51
If yuu're running a local mediawiki, this will fzf over the filenames and offer a text preview before opening the page in the browser
#!/bin/bash
SERVER_DIR="/srv/http/"
DB="${SERVER_DIR}/mediawiki/data/my_wiki.sqlite"
IP="localhost"
PORT="80"
page_name="$(sqlite3 "${DB}" 'SELECT page_title FROM page;' | sk --ansi --preview "sqlite3 "${DB}" 'SELECT old_text FROM text WHERE old_id is ( SELECT content_id FROM content where content_sha1 is ( SELECT rev_sha1 FROM revision WHERE rev_id is ( SELECT page_latest FROM page WHERE page_title is \"{}\")));' | bat --color=always -l org")"
firefox "http://${IP}:${PORT}/mediawiki/index.php/${page_name}"
@RyanGreenup
RyanGreenup / SetCranMirror.bas
Created August 1, 2021 02:32
Set the mirror for R so it doesn't ask when installing packages, use stow to manage symlinks.
#!/bin/bash
IFS="\n"
# Set Directories ............................................
DotFiles="~/DotFiles/"
R_DotFiles="${DotFiles}R/"
# Main Function.............................................
main() {
## Make the directory
library(ggplot2)
# Enter the data in such a way to match the Plot
data <-
rbind(
c("C", 0.97, 1135),
c("C++", 0.84, 3542),
c("Go", 3.75, 894),
c("Rust", 0.93, 763),
@RyanGreenup
RyanGreenup / shelling-simulation.jl
Created March 22, 2021 05:31
Shelling Simulation in Julia
# using PyPlot
using GR
using ColorSchemes
N = 2000
try
mkdir("~/Sync/Documents/tmp/gifs")
catch
end
@RyanGreenup
RyanGreenup / git_changes_fzf.sh
Created February 19, 2021 02:57
Review Git changes using fzf
git log | grep '^commit' | sed 's/^commit\ //' |\
fzf --preview 'git diff {}^! |\
bat --color always'
# Refer to:
#How to extract meta description from urls using python? - Stack Overflow:
#https://stackoverflow.com/questions/38009787/how-to-extract-meta-description-#from-urls-using-python
import appex
import clipboard
def main():
if not appex.is_running_extension():
(defun my-take-screenshot ()
(interactive)
(let
;; Read Filename from Minibuffer
((filename (read-from-minibuffer "image file name: "))
(directory "_media"))
;; Use maim to screenshot
(shell-command (format "maim --select %s/%s/%s.png" default-directory directory filename ))
(defun my-insert-clipboard-png ()
(interactive)
(let
;; Read Filename from Minibuffer
((filename (read-from-minibuffer "image file name: "))
(directory "_media"))
;; Use maim to screenshot
(shell-command (format "mkdir -p %s/%s" default-directory directory))
(shell-command (format "xclip -selection clipboard -t image/png -o > %s/%s/%s.png" default-directory directory filename ))

Editing Math With Texmacs

To edit the contents of the clipboard with TeXMacs:

  1. Save the clipboard to a temp .tex file
  2. Open the .tex file with TeXmacs a. TeXmacs will automatically import it on the fly
  3. From TeXmacs use the GUI to edit the math
  4. Save TeXmacs and it will export the file on the fly
  5. Run the file through pandoc to strip off all the header arguments
  6. Put the file back into the clipboard