Skip to content

Instantly share code, notes, and snippets.

View benkaiser's full-sized avatar
🌴
Loving Life

Benjamin Kaiser benkaiser

🌴
Loving Life
View GitHub Profile
@benkaiser
benkaiser / script.bash
Last active August 29, 2015 14:25
Convert CSV with positive and negative lines into one with only positive lines
# empty the file
touch positive.csv;
# loop the file
cat mixed.csv | while read line; do
# store the 2nd column minus quotes in the variable X
X=$(echo $line | cut -d ',' -f2 | tr -d '"');
# if it's greater than 0, put it into the output file
if [[ $X -gt 0 ]] then
echo $line >> positive.csv;
fi;
@benkaiser
benkaiser / windowmove.sh
Created January 5, 2015 12:41
shift a window to the side when focused. Good for keeping floating chat windows to the side of the screen in i3 (tiling window manager)
#!/bin/bash
name="Emily Brinsmead"
windowname=$(xdotool getactivewindow getwindowname)
width=$(xdotool search --name "Emily Brinsmead" getwindowgeometry --shell | grep "WIDTH=" | tr -cd "[:digit:]")-40;
#echo $windowname;
if [ "$windowname" == "$name" ]
then
echo "focus"
xdotool search --name "$name" windowmove --relative -- $((36-$width)) 'y'
else
@benkaiser
benkaiser / frame_counter.js
Created November 6, 2014 02:39
frame_counter
// constants
var MISSED_FRAMES = 10;
// application
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
@benkaiser
benkaiser / jumblesort.js
Created September 1, 2014 11:38
Funny sorting function I jokingly came up with last semester that sorts lists with order O(n^n^n).Seriously this is a joke, don't ever use it.
// sort the list in order O(n^n^n)
function jumblesort(list){
while(!sorted(list)){
list = shuffle(list);
}
return list;
}
function shuffle(list) {
for(var i = list.length - 1; i > 0; i--) {
@benkaiser
benkaiser / reverse_pointer.c
Created August 13, 2014 13:44
Reverses a linked-list in O(n) time and O(1) space
#include "stdio.h"
#include <stdlib.h>
typedef struct Item Item;
struct Item {
int value;
Item* next;
};
@benkaiser
benkaiser / app.js
Created May 29, 2014 07:28
Download youtube video, convert it to mp3 and tag it
var ffmpeg = require("fluent-ffmpeg");
var taglib = require("taglib");
var ytdl = require("ytdl");
var fs = require("fs");
var url = 'http://www.youtube.com/watch?v=gXK5YpoadCU';
var title = "";
var authot = "";
@benkaiser
benkaiser / config.cson
Last active August 29, 2015 14:01
Atom Settings
'editor':
'fontSize': 16
'showInvisibles': true
'showIndentGuide': true
'invisibles':
'cr': 'EW! CR!'
'tab': 'TAB?'
'eol': ''
'core':
'themes': [
@benkaiser
benkaiser / find.sh
Created February 17, 2014 00:58
Find all files in directory and sort them descending based on size
find -type f | xargs du --block-size=1K | sort -rn
@benkaiser
benkaiser / crontab
Created February 13, 2014 11:43
xkcd crontab
* * * * * DISPLAY=:0 /usr/bin/bash /home/benkaiser/.i3/update_background
@benkaiser
benkaiser / .conkyrc
Last active November 20, 2016 20:54
My conkyrc file. Mainly defaults except for colors and my added xkcd title text viewer
# Conky, a system monitor, based on torsmo
#
# Any original torsmo code is licensed under the BSD license
#
# All code written since the fork of torsmo is licensed under the GPL
#
# Please see COPYING for details
#
# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
# Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)