Skip to content

Instantly share code, notes, and snippets.

@Domon
Domon / gist:117869
Created May 26, 2009 03:15
my nginx.conf
We couldn’t find that file to show.
@Domon
Domon / strace nginx worker process
Created May 26, 2009 03:31
strace nginx worker process
recv(7, "GET / HTTP/1.1\r\nUser-Agent: Mozil"..., 1024, 0) = 592
time(NULL) = 1243308555
stat64("/webapps/blog/public/", {st_mode=S_IFDIR|0755, st_size=304, ...}) = 0
time(NULL) = 1243308555
stat64("/webapps/blog/public/index.html", 0xbf9786cc) = -1 ENOENT (No such file or directory)
time(NULL) = 1243308555
stat64("/webapps/blog/public/../config/environment.rb", {st_mode=S_IFREG|0644, st_size=1975, ...}) = 0
epoll_ctl(10, EPOLL_CTL_MOD, 7, {EPOLLIN|EPOLLOUT|EPOLLET, {u32=3109490768, u64=196383019088}}) = 0
getsockname(7, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("140.117.198.224")}, [16]) = 0
socket(PF_FILE, SOCK_STREAM, 0) = 11
@Domon
Domon / player-intermediate.rb
Created August 29, 2009 09:38
my player.rb for ruby-warrior intermediate
DEBUG = false
class Player
DIRS = [:forward, :right, :backward, :left]
def initialize
@max_health = nil
@warrior = nil
@direction = :forward
end
def play_turn(warrior)
@max_health ||= warrior.health
C:\ruby> gem list -r
*** REMOTE GEMS ***
ERROR: While executing gem ... (Gem::RemoteSourceException)
HTTP Response 403
C:\ruby> gem update --system
Updating RubyGems...
ERROR: While executing gem ... (Gem::RemoteSourceException)
HTTP Response 403
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
int main(int argc, char **argv)
{
kill(getpid(), SIGSEGV);
return 0;
}
Traceback (most recent call last):
File "/home/plurk/plurk/new_production/ext/parts/web/wsgiserver/__init__.py", line 1177, in communicate
req.respond()
File "/home/plurk/plurk/new_production/ext/parts/web/wsgiserver/__init__.py", line 547, in respond
self._respond()
File "/home/plurk/plurk/new_production/ext/parts/web/wsgiserver/__init__.py", line 559, in _respond
response = self.wsgi_app(self.environ, self.start_response)
File "/home/plurk/plurk/new_production/ext/werkzeug/utils.py", line 859, in __call__
return self.app(environ, start_response)
File "/home/plurk/plurk/new_production/ext/parts/web/web.py", line 274, in dispatch_request
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
google.pacman ||
function () {
var a = true,
e = false,
g = {},
i = [1, 4, 2, 8],
l = {
0 : {
axis: 0,
increment: 0
heffalump:~ james$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.1]
heffalump:~ james$ php -v
PHP 5.3.4 (cli) (built: Jan 17 2011 21:54:20)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
heffalump:~ james$ cat foo.rb
msg = "Hello world"
ruby-1.9.2-p0 adella:benchmarks$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0]
ruby-1.9.2-p0 adella:benchmarks$ php -v
PHP 5.3.3 (cli) (built: Aug 22 2010 19:41:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
ruby-1.9.2-p0 adella:benchmarks$ cat foo.rb
msg = "Hello world"