Skip to content

Instantly share code, notes, and snippets.

View yadomi's full-sized avatar
😏
Getting spaghettified in a wormhole

Felix Yadomi yadomi

😏
Getting spaghettified in a wormhole
  • France
View GitHub Profile
@yadomi
yadomi / bash_profile
Last active August 29, 2015 14:02
My OSX Terminal Profile (bash_profile)
__git_ps1 (){
GIT_BRANCH=$(git branch 2>/dev/null | grep '^* ' | cut -c 3-)
if [ -n "$GIT_BRANCH" ]; then
GIT_STATUS=$(git status | grep "nothing to commit")
if [ -z "$GIT_STATUS" ]; then
# printf " $Red($GIT_BRANCH)$Color_Off"
printf "\033[31m ($GIT_BRANCH)\033[0;00m"
else
printf "\033[32m ($GIT_BRANCH)\033[0;00m"
fi
@yadomi
yadomi / sanitize.py
Last active August 29, 2015 14:08
Utility to sanitize some movie filenames
#!/usr/bin/python3
# -*- coding: utf8 -*-
"""Utility to sanitize some warez movies filename"""
__author__ = "Felix Yadomi"
__version__ = "0.0.3"
__email__ = "dev.yadomi@gmail.com"
import sys, os, re
from titlecase import titlecase
@yadomi
yadomi / md5file
Created May 9, 2015 00:45
Rename file or files in directory with md5 hash file
#!/usr/bin/env ruby
require 'digest/md5'
def md5_rename_file(filepath)
newname = Digest::MD5.file(filepath).hexdigest + File.extname(filepath)
puts filepath + ' -> ' + newname
File.rename(filepath, newname)
end
@yadomi
yadomi / pluxml2md.rb
Created May 17, 2015 15:43
Script to migrate articles from PluXML CMS to Jekyll's markdown
require 'nokogiri'
require 'reverse_markdown'
require 'date'
ARTICLE_PATH='/Users/yadomi/Desktop/data/articles/*.xml'
def title doc
doc.at('title').text
end
@yadomi
yadomi / boostrap.sh
Created May 25, 2015 13:46
Bootstrap script to provision a vagrant box with Ruby 2.2
echo "-> Generate locale..."
update-locale LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8
echo "-> Updating packages informations..."
apt-add-repository -y ppa:brightbox/ruby-ng >/dev/null 2>&1
apt-get -y update 2>&1 >> /var/log/provision.log
echo "-> Installing build-essential..." | tee -a /var/log/provision.log
apt-get -y install build-essential zlib1g-dev 2>&1 >> /var/log/provision.log
@yadomi
yadomi / macos_default.sh
Last active July 6, 2020 12:03
Automate the OSX setup process (eg: you got a new Mac)
#!/bin/sh
echo "\nHello, I will make your Mac awesome"
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
echo "-------------------------"
echo "| Binaries |"
echo "-------------------------"
@yadomi
yadomi / trigger_wifi.sh
Created July 19, 2015 16:47
Run command based on Wifi SSID on OSX
SSID=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}')
WALLPAPERS="/Users/yadomi/Dropbox/Applications/WallCentral"
WALLPAPER=$(find $WALLPAPERS -type f -not -path '*/\.*' -not -path '*Icon*' | shuf -n 1)
WALLPAPER_FALLBACK="$WALLPAPERS/a495ebd47cd4e0404b272eaea6cedb23.jpg"
if [ -z $SSID ]; then
exit
fi
@yadomi
yadomi / waypoint.js
Created July 23, 2015 09:14
jQuery plugin to trigger events when element is reached Raw
$.fn.wayPoint = function(options) {
return this.each(function(){
var $this = $(this);
options = $.extend({
upOffset: 0,
downOffset: 0
}, options);
@yadomi
yadomi / stickme.js
Created July 23, 2015 09:15
jQuery plugin to stick element when scrolling
$.fn.stickMe = function(options) {
return this.each(function() {
var $this = $(this);
function onScroll() {
var topToElementStart = $this.offset().top - (options.startOffset + options.offset);
var topToViewportTop = $(window).scrollTop();
var topToViewportBottom = $(window).scrollTop() + $(window).height();
var topToElementEnd = $this.offset().top + options.height;
@yadomi
yadomi / Makefile
Created December 5, 2015 16:35
Simple Makefile for easy ES6 transpilation with babel
LIBS := $(wildcard lib/*.js)
SOURCE_JS := inject.es6
BUILD_JS := dist/inject.min.js
SOURCE_CSS := inject.css
BUILD_CSS := dist/inject.min.css
UGLIFYJS := ./node_modules/uglify-js/bin/uglifyjs
BABEL := ./node_modules/babel-cli/bin/babel.js