Skip to content

Instantly share code, notes, and snippets.

@t-kalinowski
t-kalinowski / LLaMA.R
Last active October 15, 2024 23:53
LLaMA implemented in R Tensorflow and Keras
## Setup
Sys.setenv(CUDA_VISIBLE_DEVICES='')
options(tensorflow.extract.warn_tensors_passed_asis = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(purrr)
library(glue)
library(envir)
library(tensorflow)
`%(%` <- function(fn, args) {
fn <- substitute(fn)
args <- as.list(substitute(args))
if(!identical(args[[1]], quote(`{`)))
stop("right hand side must be an expressionlist starting with a `{`")
args[[1L]] <- NULL
nms <- names2(args)
for(i in seq_along(args)) {
ar <- args[[i]]
@t-kalinowski
t-kalinowski / VSCodeExtension.py
Created January 29, 2019 14:25 — forked from harry-cpp/VSCodeExtension.py
VSCode extension for Nautilus
# VSCode Nautilus Extension
#
# Place me in ~/.local/share/nautilus-python/extensions/,
# ensure you have python-nautilus package, restrart Nautilus, and enjoy :)
#
# Quick install command:
# mkdir -p ~/.local/share/nautilus-python/extensions && cp -f VSCodeExtension.py ~/.local/share/nautilus-python/extensions/VSCodeExtension.py && nautilus -q
#
# Quick download + install command:
# wget https://gist.githubusercontent.com/cra0zy/f8ec780e16201f81ccd5234856546414/raw/6e53c15ea4b18de077587e781dc95dc7f0582cc3/VSCodeExtension.py && mkdir -p ~/.local/share/nautilus-python/extensions && cp -f VSCodeExtension.py ~/.local/share/nautilus-python/extensions/VSCodeExtension.py && rm VSCodeExtension.py && nautilus -q
@t-kalinowski
t-kalinowski / make_units2.R
Last active September 23, 2017 15:54
Some helpers for package:units
# modified from http://adv-r.had.co.nz/dsl.html
.wrap_bare_symbols_with_make_unit_call <- function(x) {
if (is.atomic(x)) {
x
} else if (is.name(x)) {
chr <- as.character(x)
if(!udunits2::ud.is.parseable(chr))
stop("could not parse ", dbl_quote(chr))
bquote(units::make_unit(.(as.character(x))))
@t-kalinowski
t-kalinowski / ggplot_piper.R
Created June 23, 2016 03:17 — forked from johnDorian/ggplot_piper.R
Piper diagrams using ggplot2.
### A piper diagram based on the ternary plot example here: http://srmulcahy.github.io/2012/12/04/ternary-plots-r.html
### This was written quickly, and most likely contains bugs - I advise you to check it first.
### Jason Lessels [email protected]
### This now consists of two functions. transform_piper_data transforms the data to match
### the coordinates of the piper diagram. ggplot_piper does all of the background.
transform_piper_data <- function(Mg, Ca, Cl,SO4, name=NULL){
if(is.null(name)){
@t-kalinowski
t-kalinowski / CapsLockCtrlEscape.ahk
Created May 22, 2016 23:47 — forked from sedm0784/CapsLockCtrlEscape.ahk
AutoHotkey script to map Caps Lock to Escape when it's pressed on its own, and Ctrl when used in combination with another key, à la Steve Losh. Adapted from the one that does something similar with the Ctrl Key on the Vim Tips Wiki (http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows?oldid=32281). (With some extra key combos added by @r…
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
*CapsLock::
if (g_ControlRepeatDetected)
{
return
}
@t-kalinowski
t-kalinowski / color_picker.R
Created April 23, 2016 17:13 — forked from dsparks/color_picker.R
Color picker in R
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("ggplot2", "proxy")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
nIncrements <- 36
eachIncrement <- seq(0, 1, len = nIncrements)
colorSweep <- expand.grid(eachIncrement, eachIncrement, eachIncrement)
moduloRemainder <- with(colorSweep, Var1*(nIncrements-1)) %%
floor(sqrt(nIncrements))
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/
# Method behind this madness described: http://forums.macrumors.com/showthread.php?t=1409151&page=4
# See discussion in comments here: https://www.macupdate.com/app/mac/39654/lion-tweaks
# And here: http://forums.macrumors.com/showthread.php?t=1410459