Skip to content

Instantly share code, notes, and snippets.

View ScrambledBits's full-sized avatar

Emilio Castro ScrambledBits

View GitHub Profile
@ScrambledBits
ScrambledBits / bashrc.sh
Last active September 30, 2015 08:38
This is my .bashrc file, feel free to use it all or parts of it in your own .bashrc file. If you have any improvements, let me know. This is for an Ubuntu system, but it could work on any system with some tweaking.
# prefix
export PS1="\[$(tput setaf 7) $(tput setab 1)\][\@]\[$(tput bold)\] [\u@\H: \w] # \[$(tput sgr0)\]"
# environment variable
export PATH=$PATH:$HOME/bin/
# remove duplicates from history
export HISTCONTROL=ignoreboth
# colors
@ScrambledBits
ScrambledBits / lindns.sh
Created February 19, 2012 20:26 — forked from disusered/lindns.sh
Linode Dynamic DNS
# update our entry with our ip
wget -qO- https://api.linode.com/?api_key=KEY\&api_action=domain.resource.update\&domainid=DOMAINID\&resourceid=RESOURCEID\&Target="[remote_addr]"
#
# in case you don't have your Domain ID on hand, you would need to run the following command first:
# wget -qO- https://api.linode.com/?api_key=APIKEY\&api_action=domain.list | tr ',' '\n'```
#
# afterwards, we can get the ResourceID via:
# wget -qO- https://api.linode.com/?api_key=APIKEY\&api_action=domain.resource.list\&domainid=DOMAINID| tr ',' '\n'```
#
@ScrambledBits
ScrambledBits / decompress_remote.sh
Created April 4, 2012 18:56
Decompress a remote tar file
#!/bin/bash
USER=$1
SERVER=$2
FILE_PATH=$3
ssh $USER@$SERVER "cat $FILE_PATH" | tar zxvf -
@ScrambledBits
ScrambledBits / system_backup.sh
Created April 20, 2012 05:10
Backup entire system with tar
#!/bin/bash
tar -cvpzf /backup/backup$(date +%d-%m-%Y).tar.gz --exclude=backup --exclude=bin --exclude=boot --exclude=dev --exclude=etc --exclude=lib --exclude=lost+found --exclude=media --exclude=mnt --exclude=opt --exclude=proc --exclude=sbin --exclude=selinux --exclude=srv --exclude=sys --exclude=tmp --exclude=usr --exclude=var/backup --exclude=var/backups --exclude=var/cache --exclude=var/crash --exclude=var/lib --exclude=var/local --exclude=var/lock --exclude=var/log --exclude=var/mail --exclude=var/opt --exclude=var/run --exclude=var/spool --exclude=var/tmp --exclude=var/vmail /
@ScrambledBits
ScrambledBits / remove_kernels.sh
Created April 20, 2012 05:31
Remove old kernels
#!/bin/bash
ls /boot/ | grep vmlinuz | sed 's@vmlinuz-@linux-image-@g' | grep -v `uname -r` > /tmp/kernelList
for I in `cat /tmp/kernelList`
do
aptitude remove $I
done
rm -f /tmp/kernelList
update-grub
@ScrambledBits
ScrambledBits / datauri.php
Created May 31, 2012 06:56 — forked from rodneyrehm/datauri.php
PHP: datauri.php - convert image to data-uri
#!/opt/local/bin/php
<?php
/*
1) replace the shebang (first line) with the path to your php binary
(probably something like /usr/bin/php)
2) move the file to /usr/local/bin/datauri.php
(this should be in your PATH)
3) chmod ugo+rx /usr/local/bin/datauri.php
(make the script executable for everyone)
@ScrambledBits
ScrambledBits / snippets.php
Created June 1, 2012 06:26
Random PHP snippets
<?php
// Strip HTML characters from a given text.
$text = htmlspecialchars(strip_tags($input));
// Remove links from a string
$string = preg_replace('/\b(https?|ftp|file:(\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $string);
//detect iPhone/iPod/iPad
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) {
@ScrambledBits
ScrambledBits / Fetch.jq
Last active February 1, 2016 21:36
Fetch.sublime-settings
{
"files":
{
"Dojo": "http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js",
"MooTools": "http://mootools.net/download/get/mootools-core-1.4.5-full-compat-yc.js",
"PrototypeJS": "https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js",
"jQuery": "http://code.jquery.com/jquery.min.js",
"jQueryUI": "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js",
"normalize.css": "https://github.com/necolas/normalize.css/raw/master/normalize.css",
"jquery": "http://code.jquery.com/jquery.min.js",
@ScrambledBits
ScrambledBits / html5-with-flash-fallback.html
Created November 4, 2012 02:14
HTML5 Video with a flash fallback solution
<!-- first try HTML5 playback: if serving as XML, expand `controls` to `controls="controls"` and autoplay likewise -->
<!-- warning: playback does not work on iOS3 if you include the poster attribute! fixed in iOS4.0 -->
<video width="640" height="360" controls>
<!-- MP4 must be first for iPad! -->
<source src="__VIDEO__.MP4" type="video/mp4" /><!-- Safari / iOS video -->
<source src="__VIDEO__.OGV" type="video/ogg" /><!-- Firefox / Opera / Chrome10 -->
<!-- fallback to Flash: -->
<object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF">
<!-- Firefox uses the `data` attribute above, IE/Safari uses the param below -->
<param name="movie" value="__FLASH__.SWF" />
@ScrambledBits
ScrambledBits / validator
Created November 9, 2012 03:48 — forked from dennysfredericci/validator
An easy way to use JQuery Validation with Twitter Bootstrap Popover
$('form').validate(
{
rules: {
numero: {
required: true
},
descricao: {
minlength: 3,
email: true,
required: true