Skip to content

Instantly share code, notes, and snippets.

View jcberthon's full-sized avatar

Jean-Christophe jcberthon

View GitHub Profile
@iandexter
iandexter / finddupes.pl
Created January 5, 2010 16:07
Find duplicate files
#!/usr/bin/perl -w
use strict;
use File::Find;
use Digest::MD5;
my %files;
find(\&check_file, $ARGV[0] || ".");
@samuelkadolph
samuelkadolph / dups.rb
Created June 23, 2011 05:25
Find duplicate files, works best on jruby for true multithreading
require "digest/md5"
require "thread"
files = Dir["**/*"]
files_mutex = Mutex.new
hashes = Hash.new { |h, k| h[k] = [] }
hashes_mutex = Mutex.new
processors = `sysctl -n hw.logicalcpu`.to_i
processors.times.map do |i|
@erskingardner
erskingardner / string_ext.rb
Created August 4, 2011 07:13
Convert String to Boolean value
class String
def to_bool
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end
end
@tuxdna
tuxdna / duplicate_files.rb
Last active October 1, 2015 12:37
Finds all the duplicate files form a directory ( for Ruby 1.9 )
#!/usr/bin/ruby
## This file finds all the duplicate files form a directory given
## at the command line.
## Released under the GPLv2
## Copyright (C) tuxdna(at)gmail(dot)com
require 'digest/md5'
require 'fileutils'
@miku
miku / fdups.py
Created August 20, 2011 04:53
Find duplicate files in python.
# http://stackoverflow.com/questions/748675/finding-duplicate-files-and-removing-them/748908#748908
import sys
import os
import hashlib
def chunk_reader(fobj, chunk_size=1024):
"""Generator that reads a file in chunks of bytes"""
while True:
chunk = fobj.read(chunk_size)
@osiyuk
osiyuk / docker-gc
Created September 1, 2017 02:14
free up disk space after docker garbage
#!/bin/bash
GARBAGE="/var/lib/docker/aufs/diff"
du -hd 1 $GARBAGE | sort -hrk 1 | head -25
find $GARBAGE -maxdepth 1 -name *-removing -exec rm -rf '{}' \;
@cosmin
cosmin / dupfinder.rb
Created March 30, 2009 09:44
Find and remove duplicate files using Ruby
require 'find'
source = ARGV[0]
destination = ARGV[1]
print "Source = #{source}\n"
print "Destination = #{destination}\n"
files = {}
match_keys = []
@martinseener
martinseener / check_freak.sh
Last active January 9, 2022 03:21
check_freak.sh - A simple nagios-compatible check for the FREAK vulnerability (CVE 2015-0204)
#!/usr/bin/env bash
# check_freak.sh
# (c) 2015 Martin Seener
# Simple script which checks SSL/TLS services for the FREAK vulnerability (CVE 2015-0204)
# It will output if the checked host is vulnerable and returns the right exit code
# so it can also be used as a nagios check!
PROGNAME=$(basename $0)
@jonathonbyrdziak
jonathonbyrdziak / CustomWidgetFile.php
Last active September 29, 2022 22:00
EMPTY WIDGET Plugin code to create a single widget in wordpress.
<?php
/**
* Duplicate this file as many times as you would like, just be sure to change the
* Empty_Widget class name to a custom name of your choice. Have fun! redrokk.com
*
* Plugin Name: Empty Widget
* Description: Single Widget Class handles all of the widget responsibility, all that you need to do is create the html. Just use Find/Replace on the Contact_RedRokk_Widget keyword to rebrand this class for your needs.
* Author: RedRokk Interactive Media
* Version: 1.0.0
* Author URI: http://www.redrokk.com
@vjm
vjm / install.sh
Created March 7, 2015 21:38
Raspberry Pi ELK Stack
sudo apt-get install -y supervisor
sudo mkdir /usr/share/elasticsearch
cd /usr/share/elasticsearch
sudo wget https://download.elasticsearch.org/kibana/kibana/kibana-4.0.1-linux-x64.tar.gz
sudo wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.tar.gz
sudo wget https://download.elasticsearch.org/logstash/logstash/logstash-1.4.2.tar.gz
sudo tar -zxvf elasticsearch-0.90.0.tar.gz