Skip to content

Instantly share code, notes, and snippets.

View strboul's full-sized avatar

Metin Yazici strboul

View GitHub Profile
@strboul
strboul / ggplot2.R
Created February 18, 2021 20:36
ggplot2 regression cookbok
# Residuals
# See also: http://www.cookbook-r.com/Statistical_analysis/Logistic_regression/
model_iris <- lm(Petal.Width ~ Petal.Length, data = iris)
fit <- data.frame(Petal.Width = iris$Petal.Width,
residuals = resid(model_iris),
fitted = fitted(model_iris))
# Residuals vs. Response variable
@strboul
strboul / nvim_lua_api.lua
Created January 8, 2021 12:09
Nvim Lua API stratch file
-- Resource
-- https://github.com/neovim/neovim/blob/master/runtime/doc/api.txt
-- Windows
vim.api.nvim_list_wins()
vim.api.nvim_get_current_win()
-- example float window
vim.api.nvim_open_win(0, false, {relative='win', row=3, col=3, width=12, height=3})
@strboul
strboul / fzf_smart_finder.lua
Last active January 7, 2021 13:19
FZF 'smart finder' buffers + files + gitwhatchanged etc. in one pane
-- Plug 'https://github.com/vijaymarupudi/nvim-fzf'
-- nnoremap <leader>k <cmd>lua require('fzf_smart_finder').sf()<CR>
--
-- Important note: run all `nvim_fzf` functions in coroutine
local fzf = require 'fzf'.fzf
local action = require 'fzf.actions'.action
coroutine.wrap(function()
-- items is a table of selected or hovered fzf items
@strboul
strboul / netrw.vim
Created October 11, 2020 11:31
(Retired) netrw config - it's buggy and not part of the workflow any more, but just keep here for the reference
" retirement note: it's too buggy
" tree-view
let g:netrw_liststyle=3
" don't show help banner
let g:netrw_banner=0
" use netrw as 'split windows', not as 'project drawer'
" (see https://github.com/tpope/vim-vinegar/)
let g:netrw_browse_split=0
let g:netrw_altv=1
@strboul
strboul / train.html
Created October 1, 2020 16:16
My first train drawn with SVG
<!DOCTYPE html>
<html>
<head>
<title>My first train drawn with SVG</title>
</head>
<body>
<svg>
<rect fill="Firebrick" width="20" height="30" x="10" y="20" />
<rect fill="Firebrick" width="100" height="50" x="0" y="50" />
@strboul
strboul / write-to-tempfile.py
Created June 17, 2020 13:50
Write to a tempfile by 'tempfile' module (in Python 3.7)
import tempfile
def write_to_temp_file(obj):
"""
Write an object to a temporary file. The location of the temp file is
determined by the OS.
Args:
obj: a writable object.
<!DOCTYPE html>
<!--
Pure CSS tabs (with Flex)
Adapted from:
- https://codepen.io/renatorib/pen/rlpfj
- https://webdevtrick.com/pure-css-tabs-responsive/
-->
<html>
<head>
<meta charset="UTF-8">
@strboul
strboul / sqlalchemy-fun.py
Created April 8, 2020 21:52
SQLAlchemy function based
# SQLAlchemy -> ORM (Object Relational Mapper)
#
# Active record pattern
# https://en.wikipedia.org/wiki/Active_record_pattern
#
# This is equal
# part = new Part()
# part.name = "Sample part"
# part.price = 123.45
# part.save()
@strboul
strboul / linear-reg-r-squared.R
Created February 22, 2020 19:52
Linear regression R-squared
## Linear regression R-squared test
library(ggplot2)
library(patchwork)
regressionPlot <- function(df) {
mod <- lm(y ~ x, df)
mod_rsq <- summary(mod)[["r.squared"]]
@strboul
strboul / transform-r-to-c.R
Created February 2, 2020 12:14
Transform R's numeric to C's double (and vice versa)
## Transform R's numeric to C's double (and vice versa)
Test <- inline::cfunction(c(x = "numeric"), "
/***** R to C *****/
// Don't do this!!! You will have a segfault if you provide a
// vector bigger than 1e5.
// for (size_t i = 0; i < Rf_length(x); i++) {
// x_dbl[i] = REAL(x)[i];
// }