Skip to content

Instantly share code, notes, and snippets.

" begin vundle code
filetype plugin indent off
syntax off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Bundle 'nickspoons/vim-sharpenup'
Bundle 'puremourning/vimspector'
Bundle 'dense-analysis/ale'
Bundle 'RRethy/vim-illuminate'
Bundle 'inside/vim-search-pulse'
@wilvk
wilvk / index.js
Last active March 21, 2019 10:30
example sync file api in node/express
var express = require('express');
var fs = require('fs');
var app = express();
var port = process.env.PORT || 8080;
app.get('/api', function(req, res) {
var contents = fs.readFileSync('DATA.txt', 'utf8');
res.send("test info: " + contents);
});
@wilvk
wilvk / actionable_dict.py
Created December 22, 2018 05:52
A Python Dictionary that can be used for notifications of nested dictionary changes
class ActionableDict(dict):
parent = None
def __init__(self, initial_dict, parent = None):
self.parent = parent
for key, value in initial_dict.items():
if isinstance(value, dict):
initial_dict[key] = ActionableDict(value, self)
super().__init__(initial_dict)
@wilvk
wilvk / .tmux.conf
Created September 18, 2018 00:26
tmux settings for mac
set-window-option -g mode-keys vi
set -g history-limit 999999
bind-key -r k select-pane -U
bind-key -r j select-pane -D
bind-key -r h select-pane -L
bind-key -r l select-pane -R
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
@wilvk
wilvk / for_bashrc
Created July 15, 2018 01:51
Get gmt time
gmttime () {
curl http://s3.amazonaws.com -v 2>&1 | grep "Date: " | awk '{ print $3 " " $5 " " $4 " " $7 " " $6 " GMT"}'
}
@wilvk
wilvk / Github.js
Last active May 16, 2018 10:14
How to implement a Github icon in material-ui-next
import React from 'react';
import SvgIcon from '@material-ui/core/SvgIcon';
class GithubIcon extends React.Component {
render() {
return (
<SvgIcon {...this.props}>
<path d="M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1-.7.1-.7.1-.7 1.2 0 1.9 1.2 1.9 1.2 1 1.8 2.8 1.3 3.5 1 0-.8.4-1.3.7-1.6-2.7-.3-5.5-1.3-5.5-6 0-1.2.5-2.3 1.3-3.1-.2-.4-.6-1.6 0-3.2 0 0 1-.3 3.4 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.6 1.6.2 2.8 0 3.2.9.8 1.3 1.9 1.3 3.2 0 4.6-2.8 5.6-5.5 5.9.5.4.9 1 .9 2.2v3.3c0 .3.1.7.8.6A12 12 0 0 0 12 .3" />
</SvgIcon>
@wilvk
wilvk / get_idletime
Created April 22, 2018 10:13
Get the total number of seconds that the ec2-user has been idle - useful for shutting down instances
#!/bin/bash
RAW_TIME=$(w -hs ec2-user | awk '{print $4}')
SECONDS=0
MINUTES=0
TOTAL_SECONDS=0
DAYS=0
if [[ $RAW_TIME = *"days"* ]]; then
@wilvk
wilvk / Cowbell Roland TR-808.rb
Created January 7, 2018 04:23
Roland TR-808 Cowbell loop on Sonic Pi
use_synth :square
with_fx :lpf, cutoff: hz_to_midi(850), _slide_shape: 4 do
for x in 1..100
play hz_to_midi(540), decay: 0.3, sustain_level: 0.0
play hz_to_midi(800), decay: 0.3, sustain_level: 0.0
sleep 0.2
end
end
@wilvk
wilvk / testrunning.sh
Created January 1, 2018 02:42
bash script to test if a process is running and do an action if it is or isn't
#!/bin/bash
PROCESS_GREP_STRING=eth
PROCESS_COUNT_THRESHOLD=3
SLEEP_TIMEOUT=5
RUNNING_COMMAND="echo 'Running'"
NOT_RUNNING_COMMAND="echo 'Not Running'"
while :
do
@wilvk
wilvk / kill_open_files.sh
Created August 16, 2017 06:50
Linux - Kill all processes of deleted files that are still open
#!/bin/bash
lsof|grep deleted|awk '{print $2}'|xargs kill -9