Skip to content

Instantly share code, notes, and snippets.

@frace
frace / pidof
Created November 27, 2012 20:13 — forked from vgrichina/pidof
pidof for OS X
#!/usr/bin/env bash
if (( $# == 1 )); then
declare proc="$(ps axc | grep "$1")"
read -ra pid <<< "$proc"
if (( $pid )); then
echo $pid
exit 0
else
@frace
frace / vim-statusline-spacer.vim
Last active December 15, 2015 15:29
Create a spacer/margin on the left of the vim statusline according to the numberwidth
function! CreateSpacer()
if &number || &relativenumber
return repeat(" ", &numberwidth + 1)
endif
return ""
endfunction
set statusline=
set statusline+=%{CreateSpacer()}
@frace
frace / GetVimHighlight
Last active December 16, 2015 07:29
Some functions to store and restore values of a given highlight group in vim.
function! functions#store_highlight_attrs(group)
" Wants: Str
" Returns: Dict
" Does: Stores all attribute of the given highlight group
" and returns them as a dictionary.
if has('gui_running')
let l:ui_type = 'gui'
else
let l:ui_type = 'cterm'
@frace
frace / update-meta-dam
Last active December 16, 2015 19:49
Since DAM in TYPO3 does not allow batch processing of meta data for non-default languages we HAVE to do it on our own
UPDATE `tx_dam`
SET
`title`='title',
`loc_country`='country',
`loc_city`='city',
`description`='description',
`alt_text`='alt_text',
`caption`='caption',
`abstract`='abstract'
WHERE `sys_language_uid`=1 (AND `file_mime_type`='image')
@frace
frace / leVader.js
Created May 28, 2013 13:34
A chainable jquery function to fade in a number of elements one after another.
/**
* A chainable function to fade in a number of elements one
* after another.
*
* @param {Object} timing
*
*/
$.fn.leVader = function( timing ) {
this.each(function( index ) {
$( this ).delay( index * timing.delay ).fadeIn( timing.duration );
@frace
frace / 10-set-ssd-ioscheduler.start
Last active August 29, 2015 13:56
A "collection" of approaches to set the io scheduler for ssds on systems where both ssds and hdds are used.
# An openrc init script (local.d) which sets the io scheduler in "/sys/block/sd?/queue/scheduler"
# for a custom list of known solid state drives.
enable=false
local_start()
{
local ssd_scheduler
local -a ssd_devices
@frace
frace / busybox_uninstall_applets
Last active August 29, 2015 13:56
Accidentally executed `busybox --install` on a Gentoo box?
#!/usr/bin/env bash
paths=(
"/bin"
"/sbin"
)
backup="/root/bbbackup"
if [[ ! -d "$backup" ]]; then
@frace
frace / ffmpeg commands
Last active September 11, 2021 08:36
A scrapbook for a script
# Get raw encoder value
ffprobe -v quiet -print_format compact=print_section=0:nokey=1:escape=csv -show_entries format_tags=encoder "$input_file"
# Get raw duration value
ffprobe -v quiet -print_format compact=print_section=0:nokey=1:escape=csv -show_entries format=duration "$input_file"
# Generate spectrogram
ffmpeg -ss "$start_position" -t "$duration" -i "$input_file" -f sox - | sox -t sox - -n spectrogram -o "${output_name}.png"
# Generate raw data used in spectrogram
@frace
frace / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@frace
frace / homebrew_read_access.markdown
Last active August 29, 2015 14:25
Homebrew setup guide for multiuser read acccess on Mac OS X

Prerequisites

Add admin user for Homebrew management and a standard user for daily work.

Installation

As admin user: 0. umask 002

  1. sudo mkdir /usr/local
  2. sudo chown root:admin /usr/local
  3. Install Homebrew in /usr/local