Skip to content

Instantly share code, notes, and snippets.

View jay-johnson's full-sized avatar

Jay jay-johnson

View GitHub Profile
@jay-johnson
jay-johnson / Polars Rust - Convert DataFrame Epoch Column in Milliseconds (i64) to a UTC date-formatted string
Last active November 15, 2022 18:57
Polars Rust - Convert DataFrame Epoch Column in Milliseconds (i64) to a UTC date-formatted string
let date_utc_str_s: Series = Series::new(
"date_utc_str",
df
.column("date")
.unwrap()
.cast(&DataType::Datetime(
polars::datatypes::TimeUnit::Milliseconds,
None))
.unwrap()
.strftime("%Y-%m-%dT%H:%M:%SZ")
@jay-johnson
jay-johnson / Open a file at specific line and column with vim.md
Last active November 3, 2022 15:02
Open a file at specific line and column with vim

Open a file at specific line and column with vim

Example error message when deserializing json:

expected a string at line 1 column 435
# cursor(LINE_NUM, COL_NUM)
vi file-with-nested-json-error.json "+call cursor(1, 435)"
@jay-johnson
jay-johnson / install-ycm-with-vim-src.sh
Last active July 21, 2019 21:37
Unofficial - Install YouCompleteMe with Vim from Source
#!/bin/bash
function install_ycm() {
mkdir -p ~/.vim
curdir=$(pwd)
if [[ "$(which xcode-select)" != "" ]]; then
# you may need to install packages with: xcode-select --install
echo ""
echo "installing XQuartz"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null
@jay-johnson
jay-johnson / grow-fs.sh
Created June 1, 2019 07:18
Resize partition to maximum using parted in non-interactive mode
#!/bin/bash
# example from
# for donkey car
# https://serverfault.com/questions/870594/resize-partition-to-maximum-using-parted-in-non-interactive-mode
set -e
if [[ $# -eq 0 ]] ; then
echo 'please tell me the device to resize as the first parameter, like /dev/sda'
DEVICE=eno1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
@jay-johnson
jay-johnson / use system for libvirt.sh
Created March 24, 2019 06:33
use system for libvirt
export LIBVIRT_DEFAULT_URI="qemu:///system"
@jay-johnson
jay-johnson / .bashrc
Created March 15, 2019 16:08
base bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac

Set these under iTerm2 > Preferences > Keys

Vim Page Down

control + d

Send Text with "vim" Special Chars

to

@jay-johnson
jay-johnson / Asciinema Command Example
Created January 9, 2019 16:59
Asciinema Command Example
file=/data/asciinema/sa-2-fullstack; rm -f ${file}; asciinema rec ${file} -i 2 -t "title_here"
@jay-johnson
jay-johnson / convert_date_columns_from_UTC_to_EST_dates.py
Last active January 3, 2019 19:02
Pandas Convert Date Column From UTC to EST dates
#!/usr/bin/env python
import pandas as pd
df = pd.DataFrame([
{
'date': '2019-01-01 14:30:00',
'epochms': 1546353000000
},
{