require "socket"
server = TCPServer.open(2626)
loop do
Thread.fork(server.accept) do |client|
client.puts("Hello, I'm Ruby TCP server", "I'm disconnecting, bye :*")
This file contains 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
class User | |
include DataMapper::Resource | |
property :id, Serial | |
property :username, String, :required => true, :unique => true | |
property :address_street_address, String | |
property :address_location, String | |
property :address_subdivision, String | |
property :address_country, String |
This file contains 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
p = /\A(aa|aab?)+\Z/ | |
@counter = 0 | |
s = "" | |
t = [] | |
64.times { t << Thread.fork { puts "start" }; t.last.join } | |
while s.length < 200 | |
i = s.length % t.size | |
t[i].join | |
t[i] = Thread.fork(s.dup) do |s| |
This file contains 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
class Hashtable | |
INITIAL_TABLE_SIZE = 32 | |
Entry = Struct.new(:key, :value) | |
def initialize | |
@table = Array.new(INITIAL_TABLE_SIZE) | |
end | |
attr_accessor :table |
This file contains 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
# | |
# Przekształcanie algorytmów rekurencyjnych w iteracyjne | |
# na przykładzie znanych i kochanych algorytmów: | |
# BinarySearch i QuickSort ;) | |
# | |
# | |
# ======================== Binary Search Algorithm ================================= |
- Strona domowa
- Najlepsze IDE do Scali w tej chwili to InteliJ IDEA
- Tutorial (trochę stary, ale dobry, sam się z niego nauczyłem Scali)
- Prezentacja o Scali (nowsza wersja tej prezentacji)
- Scala Tricks
- Książka (Piersza edycja udostępniona free)
- Inna książka free
This file contains 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
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}' | |
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}' | |
local git_branch='$(git_prompt_info)%{$reset_color%}' | |
PROMPT="╭─${user_host} ${current_dir} ${git_branch} | |
╰─%B$%b " | |
RPS1="${return_code}" |
This file contains 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
import scala.collection.immutable.TreeMap | |
import scala.util.Random | |
/* 100 prisoners problem - simulation of various strategies | |
* Decription at: | |
* - http://en.m.wikipedia.org/wiki/100_prisoners_problem | |
* - https://www.youtube.com/watch?v=eivGlBKlK6M | |
*/ |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="org.example.battery_level_monitor_example" | |
android:versionCode="1" | |
android:versionName="0.0.1"> | |
<uses-sdk | |
android:minSdkVersion="9" | |
android:targetSdkVersion="16" /> |
OlderNewer