Skip to content

Instantly share code, notes, and snippets.

@morganp
morganp / make_ruby_project
Created July 14, 2011 07:56
Set up a new Ruby Project
#!/usr/bin/env ruby
## Setting up files for a new Bundler/RVM Ruby project
## $ make_ruby_project some_new_project
##
## This could be cleaner split into multiple files and seperate templates
## But a single file in the your bin directory is easier to manage
##
## A More mainstream version is part of bundler
## bundle gem some_new_project
##
@morganp
morganp / gist:1105096
Created July 25, 2011 20:23
Old Avahi Setup
We couldn’t find that file to show.
@morganp
morganp / fstab
Created July 26, 2011 22:04
etc/fstab main fs server
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sde1 during installation
UUID=59a61ceb-fee3-460a-97c5-e9f115776daf / ext4 errors=remount-ro 0 1
@morganp
morganp / base.sh
Created August 1, 2011 08:52
Bash get base dir of script
BaseDir=$(dirname $(which ${0}))
@morganp
morganp / sensible_sort.rb
Created August 6, 2011 21:52
A simple natural sorting
def sensible_sort(unsorted)
return unsorted.sort_by {|k| k.to_s.split(/((?:(?:^|\s)[-+])?(?:\.\d+|\d+(?:\.\d+?(?:[eE]\d+)?(?:$|(?![eE\.])))?))/ms).map{|v| Float(v) rescue v.downcase}}
end
# 1
# 2
#11
#12
##not
@morganp
morganp / timeformat.v
Last active July 29, 2020 16:53
Verilog time format
//To change the way (below) is displayed
$display("%t", $realtime);
//$timeformat(unit#, prec#, "unit", minwidth);
$timeformat(-3, 2, " ms", 10); // -3 and " ms" give useful display msg
unit is the base that time is to be displayed in, from 0 to -15
precision is the number of decimal points to display.
"unit" is a string appended to the time, such as " ns".
minwidth is the minimum number of characters that will be displayed.
@morganp
morganp / seperator.rb
Last active October 31, 2017 17:47
List of TV show names as Regular expressions (Ruby)
SEPERATOR = '[-\._ ]'
def SEPERATOR?
"#{SEPERATOR}?"
end
@morganp
morganp / verilog.md
Created October 25, 2011 19:22
Verilog Internet Resources
@morganp
morganp / perlruby.md
Created November 1, 2011 17:08
Perl vs Ruby

[Perl vs Ruby][source1]

Among many differences are: a much better object system and much better functionals (being stuck with $_ is damned ugly IMO)...I write a lot of Perl code and practically think in it, but Ruby is still way easier for me to read. -- TheerasakPhotha

[ruby-lang][source2]

more powerful than Perl, and more object-oriented than Python

Visual apperance

@morganp
morganp / string_cell.m
Created November 17, 2011 17:06
Matlab cells end+1 trick
names = {};
for i=1:10
names{end+1} = 'string';
end
%% http://stackoverflow.com/questions/2288899/cell-array-appending-in-matlab