Skip to content

Instantly share code, notes, and snippets.

View jacoborus's full-sized avatar

Jacobo Tabernero jacoborus

View GitHub Profile
@jacoborus
jacoborus / safename.js
Created July 23, 2013 03:40
Basic safe name for files
/* safe name for files */
var safeFilename = function ( name ) {
name = name.replace(/ /g, '-');
name = name.replace(/[^A-Za-z0-9-_\.]/g, '');
name = name.replace(/\.+/g, '.');
name = name.replace(/-+/g, '-');
name = name.replace(/_+/g, '_');
return name;
}
@jacoborus
jacoborus / Preferences.sublime-settings
Created August 1, 2013 23:21
My Sublime Text user settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",
".subl"
],
@jacoborus
jacoborus / UUID4.js
Last active December 29, 2015 23:39
UUID rfc4122 version 4
// from http://stackoverflow.com/a/2117523/1409080
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
@jacoborus
jacoborus / adesis.zsh-theme
Last active August 29, 2015 14:10
Adesis ZSH theme
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
#
@jacoborus
jacoborus / .tmux.conf
Last active July 23, 2017 02:10
tmux + vim configuration
# set Zsh as your default Tmux shell
set-option -g default-shell /bin/zsh
# UTF is great, let us use that
set -g utf8
set-window-option -g utf8 on
# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"
@jacoborus
jacoborus / show_colors.sh
Created May 16, 2015 19:04
Show terminal colors
#!/usr/bin/env bash
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
@jacoborus
jacoborus / outputTemp.js
Last active July 23, 2019 14:10
closerToZero
function outputTemp (tempRow) {
return tempRow
.split(' ')
.map(n => Number(n))
.reduce((min, val) => {
const abs = Math.abs(val)
const pos = val >= 0
if ((pos && abs === min.abs) || abs < min.abs) {
return { val, abs }
}