Skip to content

Instantly share code, notes, and snippets.

View atelic's full-sized avatar

Eric Barbour atelic

View GitHub Profile
@atelic
atelic / findWithAttr.js
Last active August 29, 2015 14:24
Find with attribute in JS
// source: https://stackoverflow.com/questions/7176908/how-to-get-index-of-object-by-its-property-in-javascript
function findWithAttr(array, attr, value) {
for(var i = 0; i < array.length; i += 1) {
if(array[i][attr] === value) {
return i;
}
}
}
var Data = [
@atelic
atelic / tmux.conf
Last active November 5, 2023 23:39
A vim-friendly tmux config
# change prefix to Ctrl-a (like in gnu-screen)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# shell
set -g default-command /bin/zsh
set -g default-shell /bin/zsh
@atelic
atelic / is_running.sh
Created May 26, 2015 19:25
A bash script to check if a process is running
#! /bin/bash
process=$1
ps cax | grep $process > /dev/null
if [ $? -eq 0 ]; then
echo "process is running"
else
echo "process is not running"
fi
@atelic
atelic / gulpfile.js
Created May 24, 2015 04:00
Basic gulpfile for minify and concat css and javascript
/*
Before using make sure you have:
npm install --save-dev gulp gulp-minify-css gulp-concat gulp-uglify gulp-autoprefixer gulp-sass
Make sure to change the directory names in the default watch function to the CSS/SCSS/SASS directories you are using so it reloads
*/
var gulp = require('gulp'),
minifyCSS = require('gulp-minify-css'),
concat = require('gulp-concat')
@atelic
atelic / mkorg.rb
Last active August 29, 2015 14:21
A quick and dirty script that inserts my custom org-mode header into new files
#! /usr/bin/env ruby
if ARGV.empty?
puts "Please enter a file name"
end
new_file = ARGV[0]
org_file = File.new(new_file, "w+")
org_file.puts("#+HTML_HEAD: <link rel=\"stylesheet\" type=\"text/css\" href=\"http://thomasf.github.io/solarized-css/solarized-light.min.css\" />\n")
org_file.puts("#+TITLE: \n")
@atelic
atelic / dmenu2.sh
Created May 15, 2015 05:13
An awesome dmenu2 script for a configurable program launcher
#!/bin/sh
# Define your battery device. Look up in '/sys/class/power_supply/' for a directory named 'BAT0' ( it also can be 'BAT1 or something else )
device='BAT0'
battery="$(cat /sys/class/power_supply/$device/capacity)%"
# Volume Status for alsa users
volume="$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')"
# Define your preferred terminal
@atelic
atelic / google.py
Created May 15, 2015 05:05
Python 2 script that googles your argument with a small GUI
#!/usr/bin/python2
import os, urllib
google = os.popen('zenity --entry --text="Enter your search: " --title="goog.py"').read()
google = urllib.quote(google)
os.system('google-chrome-stable http://google.com/search?q=%s' % (google) )
@atelic
atelic / todo_generator.rb
Last active August 29, 2015 14:21
Ruby script that finds all TODO comments in a file or multiple files and outputs to out.txt
#! /usr/bin/env ruby
if ARGV.empty?
puts "Please enter a file name"
exit
end
out_file = File.new("out.txt", "w+")
puts "Appending to output file..."
@atelic
atelic / fizz_buzz.rb
Created May 13, 2015 05:04
Shortest FizzBuzz in ruby I can come up with
1.upto(100){|n|puts n%15==0?"FizzBuzz":n%5==0?"Buzz":n%3==0?"Fizz":n}
@atelic
atelic / pixellock.sh
Created May 13, 2015 03:35
Another i3lock script
#!/usr/bin/env bash
icon="$HOME/path/to/lock.png"
tmpbg='/tmp/screen.png'
(( $# )) && { icon=$1; }
scrot "$tmpbg"
convert "$tmpbg" -scale 10% -scale 1000% "$tmpbg"
convert "$tmpbg" "$icon" -gravity center -composite -matte "$tmpbg"