Skip to content

Instantly share code, notes, and snippets.

@eddieantonio
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddieantonio/1dcbcc8f6ed53e1a4b63 to your computer and use it in GitHub Desktop.
Save eddieantonio/1dcbcc8f6ed53e1a4b63 to your computer and use it in GitHub Desktop.
I don't know why.
#!/usr/bin/env ruby
# The Xcode prefix for C stuff.
PREFIX = `xcrun --show-sdk-path`.chomp
# Ze masterpiece.
def have_a_nap
puts "Le 💤 "
pause
end
def fire_ze_missiles
puts "🔥 ze 🚀"
end
# wtf...?
def pause
# See: man 2 sigsuspend
num = find_syscall :sigsuspend
sigmask = 0
syscall(num, sigmask)
end
def find_syscall(name)
filename = File.join PREFIX, '/usr/include/sys/syscall.h'
line = File.open filename do | file |
file.grep(/#{name}/).first
end
# Don't use #to_i so that conversion can fail instead of returning 0.
Integer(line[/\s\d+/])
end
begin
have_a_nap
ensure
fire_ze_missiles
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment