Skip to content

Instantly share code, notes, and snippets.

@dtoma
dtoma / gist:7659427
Created November 26, 2013 14:40
Travian 3.6 Login
my $url = URI->new("http://tc6.travian.fr/dorf1.php");
my $info = POST $url, [
'action' => 'dorf1.php',
'login' => 's1',
'name' => '[name]',
'password' => '[password]',
'login' => '',
'autologin' => 'ja',
];
$browser->request($info)->as_string;
@dtoma
dtoma / gist:7927794
Created December 12, 2013 13:16
Ruby - Get number of days in a month
require 'date'
def days_in_month(year, month)
Date.new(year, month, -1).day
end
@dtoma
dtoma / gist:8020289
Created December 18, 2013 10:36
Select multiple values
<form>
<select name="multiple_select[]" size="10" multiple> <!-- Note the brackets -->
</select>
</div>
@dtoma
dtoma / gist:8025255
Last active December 31, 2015 18:09
Ruby - generate random hexadecimal colour
colour = "%06x" % (rand * 0xffffff)
@dtoma
dtoma / hash.rb
Last active January 2, 2016 09:29
Trick for infinite-level hash
# (cf. https://www.ruby-forum.com/topic/140570#624505)
lazy = lambda { |h,k| h[k] = Hash.new(&lazy) }
my_hash = Hash.new(&lazy)
@dtoma
dtoma / nginx
Created June 27, 2014 13:50
nginx init.d file
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@dtoma
dtoma / epoll_server.py
Last active January 30, 2024 05:12
epoll tcp server in python
#!/usr/bin/env python
"""Simple server using epoll."""
from __future__ import print_function
from contextlib import contextmanager
import socket
import select
@dtoma
dtoma / alpine.md
Last active August 29, 2015 14:22
Alpine Linux - Getting Started
setup-interfaces
rc-service networking restart
setup-apkrepos
apk update
apk upgrade
apk add build-base
@dtoma
dtoma / lexicon.md
Last active March 24, 2016 09:44
Lexicon - Finance
  • Equity: A stock or any other security representing an ownership interest.

  • Futures Contract: a type of derivative instrument, or financial contract, in which two parties agree to transact a set of financial instruments or physical commodities for future delivery at a particular price.

  • Fixed-income Security: An investment that provides a return in the form of fixed periodic payments and the eventual return of principal at maturity. Unlike a variable-income security, where payments change based on some underlying measure such as short-term interest rates, the payments of a fixed-income security are known in advance.

  • Security: a tradable financial asset. It is commonly used to mean any form of financial instrument, but the legal definition of a "security" varies by legal and regulatory jurisdiction.

  • Derivatives: A derivative is a security with a price that is dependent upon or derived from one or more underlying assets. The derivative itself is a contract between two or more part

@dtoma
dtoma / lexicon.md
Last active December 16, 2015 12:32
Lexicon - CS
  • algebraic data type: a kind of composite type, i.e. a type formed by combining other types. Two common classes of algebraic type are:
    • product types i.e. tuples
    • records and sum types, also called tagged or disjoint unions or variant types

Algebraic" refers to the property that an Algebraic Data Type is created by "algebraic" operations. The "algebra" here is "sums" and "products":

  • "sum" is alternation (A | B, meaning A or B but not both)
  • "product" is combination (A B, meaning A and B together)

Wikipedia
Haskell Wiki