Skip to content

Instantly share code, notes, and snippets.

View ScrambledBits's full-sized avatar

Emilio Castro ScrambledBits

View GitHub Profile
@ScrambledBits
ScrambledBits / ColorizedLogs.sh
Last active February 1, 2016 19:39
This snippet finds all log files under /var/log and displays them in realtime with color highlight. CCZE must be installed.
#!/bin/bash
find /var/log -type f -iregex '.*[^\.][^0-9]+$' -not -iregex '.*gz$' 2> /dev/null | xargs tail -n0 -f | ccze -A
#!/usr/bin/env bash
# Simple move this file into your Rails `script` folder. Also make sure you `chmod +x puma.sh`.
# Please modify the CONSTANT variables to fit your configurations.
# The script will start with config set by $PUMA_CONFIG_FILE by default
PUMA_CONFIG_FILE=config/puma.rb
PUMA_PID_FILE=tmp/pids/puma.pid
PUMA_SOCKET=tmp/sockets/puma.sock
<?php
function array_keys_multi(array $array)
{
$keys = array();
foreach ($array as $key => $value) {
$keys[] = $key;
if (is_array($array[$key])) {
$keys = array_merge($keys, array_keys_multi($array[$key]));
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
<?php
// Code snippet to extract the icon from an exe file on a Linux system -- tested on Debian Wheezy
// Install icoutils on your system e.g. sudo apt-get install icoutils
// Web process must have write privileges to /tmp
///** Config **///
$input_file = '/path/to/program.exe';
@ScrambledBits
ScrambledBits / iptables_block.sh
Created December 11, 2012 03:29
SSH Dictionary Attack Prevention with iptables
#!/bin/bash
iptables -N SSH_CHECK
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j SSH_CHECK
iptables -A SSH_CHECK -m recent --set --name SSH
iptables -A SSH_CHECK -m recent --update --seconds 60 --hitcount 4 --name SSH -j DROP
@ScrambledBits
ScrambledBits / server_backup.sh
Created December 11, 2012 03:09
Server Backup
#!/bin/bash
tar -cvpzf /backup/backup$(date +%d-%m-%Y).tar.gz --exclude=backup --exclude=bin --exclude=boot --exclude=dev --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 /
mysqldump -u root -p --all-databases | gzip > /backup/backup-database_$(date '+%m-%d-%Y').sql.gz
cd /backup/
for i in $(ls backup*); do dropbox_upload.sh upload $i /backup/*; done
@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
@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 / 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",