Skip to content

Instantly share code, notes, and snippets.

View ELLIOTTCABLE's full-sized avatar
🐫

ELLIOTTCABLE

🐫
View GitHub Profile
[Mon Sep 15 - 09:36:15] [elliottcable @ Geoffrey] [~/Code/school/]
-- javac Exercises.java && java Exercises
Exercises.java:11: cannot find symbol
symbol : method getCharAt(int)
location: class java.lang.String
char last_character = input.getCharAt(last_char_index);
^
1 error
[Mon Sep 15 - 09:42:34] [elliottcable @ Geoffrey] [~/Code/school/]
--
module Kernel
# Runs the passed block of code, if the calling file is the one being executed.
def on_execute
calling_file = caller.first.split(':').first
if File.expand_path(calling_file) == File.expand_path($0)
yield
end
end
#!/bin/env ruby
############################################################################
# textilewc: Count words in a Textile file, if somewhat crudely.
# By Tammy Cravit, [email protected]
#
# $Revision$ $Date$
#
# If a single file is provided on the command line, it displays the number
# of words in the file. If multiple files are given on the command line, it
# generates a listing similar to the output of wc(1), except that directories
%w[rubygems RedCloth].each {|dep| require dep }
module RedCloth
module Formatters::None
include RedCloth::Formatters::Base
end
class TextileDoc
%w[rubygems RedCloth stringray].each {|dep| require dep }
class RedCloth::TextileDoc
def clean(*rules)
# Fragile! Oh well. )-:
out = to_html.gsub(/<\/?[^>]*>/, "")
out.gsub(/\&\#[0123456789]+\;/, "?") # Replace entities with a question mark
end
end
%w[rubygems open-uri hpricot].each {|dep| require dep }
(1..10000).each do |n|
doc = Hpricot( open("http://google.com/search?q=#{n}") )
results = (doc/'#ssb'/'p'/'b')[2].inner_html.gsub(',', '').to_i
puts "#{n}:\t#{results}"
break if n == results
end
[root@myhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1008M 457M 501M 48% /
none 851M 0 851M 0% /dev/shm
/dev/sda2 147G 188M 140G 1% /mnt
-- sudo du -h --max-depth=1
Password:
2.3M ./etc
4.0K ./opt
348K ./dev
32K ./root
24K ./mnt
4.2M ./bin
16K ./media
301M ./var
-- cat /proc/partitions
major minor #blocks name
8 2 156352512 sda2
8 3 917504 sda3
8 1 1048576 sda1
[Thu Sep 18 - 02:11:40] [elliottcable @ bafflement] [//]
-- mount
/dev/sda1 on / type ext3 (rw)
none on /dev type ramfs (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
/dev/sda2 on /mnt type ext3 (rw)