This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ for i in `seq 200`; do ruby puzzle6_2_debug.rb ; done | uniq | |
result = [0, 14, 13, 12, 11, 10, 8, 8, 6, 6, 5, 3, 3, 2, 1, 10] | |
result = [13, 12, 12, 10, 10, 8, 7, 6, 6, 4, 4, 2, 2, 1, 15, 0] | |
result = [0, 14, 13, 12, 11, 10, 8, 8, 6, 6, 5, 3, 3, 2, 1, 10] | |
result = [6, 6, 4, 2, 2, 0, 0, 15, 13, 12, 11, 11, 9, 8, 4, 9] | |
result = [0, 14, 13, 12, 11, 10, 8, 8, 6, 6, 5, 3, 3, 2, 1, 10] | |
result = [2, 1, 0, 15, 13, 12, 11, 11, 9, 9, 7, 7, 5, 5, 4, 1] | |
result = [0, 14, 13, 12, 11, 10, 8, 8, 6, 6, 5, 3, 3, 2, 1, 10] | |
result = [8, 7, 7, 5, 5, 3, 2, 1, 1, 0, 14, 14, 12, 12, 10, 11] | |
result = [0, 14, 13, 12, 11, 10, 8, 8, 6, 6, 5, 3, 3, 2, 1, 10] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/foo.service | |
[Unit] | |
Description=Foo service | |
Wants=nginx.service | |
Requires=postgresql.service | |
After=postgresql.service | |
[Service] | |
Type=simple | |
User=foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra" | |
get "/*" do | |
content_type "text/plain" | |
ret = "" | |
env.each_key do |k| | |
ret += "%25s = %s\n" % [k, env[k]] | |
end | |
ret | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Verkkouutiset title-killer | |
// @namespace Rennex | |
// @include http://www.verkkouutiset.fi/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
document.querySelector("article").removeAttribute("title") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra" | |
set :show_exceptions, :after_handler | |
error do | |
"Custom error page!" | |
end | |
get "/" do | |
"Hello! <a href='error'>Click to get an error</a>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The files shown below let you define the location of the database in one place, | |
and easily run migrations, the main web app, and any backend utility scripts. | |
# do this in the web app or utility script: | |
require_relative "database.rb" | |
# to run migrations (in the shell): | |
$ ./migrate | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra/base" | |
class Foo < Sinatra::Base | |
get "/" do | |
"foo!" | |
end | |
end | |
class Bar < Sinatra::Base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1] pry(main)> x = (1..5) | |
=> 1..5 | |
[2] pry(main)> p x | |
1..5 | |
=> 1..5 | |
[3] pry(main)> p *x | |
1 | |
2 | |
3 | |
4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) { | |
long x = ""-""; | |
char *y = "foo"; | |
char *z = "foo"; | |
printf("null is %p, x is %ld\n", NULL, x); | |
printf("y is %p, z is %p\n", y, z); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra" | |
DATA = File.read("data.txt") | |
get "/" do | |
"I have some data for you: #{DATA}" | |
end |