Skip to content

Instantly share code, notes, and snippets.

View crmne's full-sized avatar
👋

Carmine Paolino crmne

👋
View GitHub Profile
@crmne
crmne / gencpuusage.c
Created December 29, 2009 14:32
Generate arbitrary CPU usage
/* Generate arbitrary CPU usage */
#include <stdlib.h>
#include <unistd.h>
#include <err.h>
#include <math.h>
#include <sys/time.h>
#include <stdarg.h>
#include <sys/wait.h>
#define CPUUSAGE 0.2 /* set it to a 0 < float < 1 */
@crmne
crmne / cs.rb
Created January 6, 2010 20:56
Connects to the least busy cs.unibo.it machine
#!/usr/bin/env ruby -wKU
# Connects to a cs.unibo.it machine
require 'optparse'
require 'logger'
logger = Logger.new STDOUT
scriptdir = File.dirname(__FILE__)
options = { :logger => logger, :user => ENV['USER'], :servers => `#{scriptdir}/list_csunibo.rb`.chomp.split(',') }
@crmne
crmne / view_source_in_textmate.scpt
Created January 14, 2010 00:18
Opens the source of the current Safari page in TextMate.
-- Opens the source of the current Safari page in TextMate.
--
-- http://iflipbits.com/post/880085979/view-source-in-textmate-for-safari
tell application "Safari"
if not (exists front document) then
display alert "An error as occurred" message "You need to open a web site first!" as warning
return
end if
@crmne
crmne / git-publish.sh
Created May 28, 2010 12:39
Sharing Git repositories with one command http://iflipbits.com/645186828
#!/bin/bash -e
# Your user web directory, typically "${HOME}/public_html" or "${HOME}/Sites"
PUBLIC_HTML="${HOME}/Sites"
# Subfolder of $PUBLIC_HTML where to put your shared repositories
PUBLIC_GIT="git"
# Save the shared repository with this remote name
REMOTE="public"
# The branch that will be pushed to your shared repository
BRANCH="master"
@crmne
crmne / notify_page_changes.sh
Created July 13, 2010 14:38
Notify if a page changes
#!/usr/bin/env sh
# This script notifies when a page changes.
# The first argument is the url, the other is a command that will notify you,
# like 'growlnotify -s -p 2 -t "Title" -m "Message"' if you use Growl.
#
# Example:
# $ notify_page_changes.sh 'http://reddit.com' 'growlnotify -s -p 2 -t "Reddit.com" -m "Changed"'
#
# IMPORTANT: remember to put your arguments in quotation marks!
@crmne
crmne / md5crypt.py
Created August 15, 2010 10:44
UNIX and Apache compatible MD5 password encryption
#!/usr/bin/env python
# Based on FreeBSD src/lib/libcrypt/crypt.c 1.2
# http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libcrypt/crypt.c?rev=1.2&content-type=text/plain
# Original license:
# * "THE BEER-WARE LICENSE" (Revision 42):
# * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
# * can do whatever you want with this stuff. If we meet some day, and you think
# * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
@crmne
crmne / ie9build.rb
Created August 22, 2010 23:15 — forked from sr3d/ie9build.rb
Pack JS and CSS in PNG
#!/usr/bin/env ruby
require 'ftools'
require 'fileutils'
require 'rubygems'
require 'RMagick'
include Magick
require 'open3'
def merge( files = [] )
@crmne
crmne / unique_insert_with_ids.cpp
Created October 16, 2010 22:32
This is how you can insert elements in a container, without repetition, and obtaining unique ids. Useful for inserting vertexes in Boost.Graph. See http://stackoverflow.com/questions/3950841
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main (int argc, char const *argv[])
{
string array[] = { "zero", "one", "one", "zero", "two", "three", "zero" };
@crmne
crmne / view_generated_source_in_textmate.scpt
Created October 26, 2010 17:11
Opens the generated source of the current Safari page in TextMate. Javascript trick thanks to @dpkendal http://gist.github.com/646570
(*
Opens the generated source of the current Safari page in TextMate.
To make it a System Service (with keyboard shorcuts!), visit:
http://iflipbits.com/post/880085979/view-source-in-textmate-for-safari
*)
tell application "Safari"
if not (exists front document) then
display alert "An error as occurred" message "You need to open a web site first!" as warning
@crmne
crmne / .gitignore
Created January 13, 2011 09:31
Create directory hard links on Mac OS X
hlink.o
hlink