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.util.control.TailCalls._ | |
object Main extends App { | |
def findSumProduct(factors: Int): Option[Long] = { | |
def recurseStartNumber(level: Int): Int = if (level < factors - 2) 1 else 2 | |
def inner(level: Int, currentNumber: Int, sum: Long, product: Long, knownMin: Option[Long]): TailRec[Option[Long]] = { |
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
mvn archetype:generate \ ‹ruby-2.1.5› | |
-DarchetypeGroupId=org.apache.flink \ | |
-DarchetypeArtifactId=flink-quickstart-scala \ | |
-DarchetypeVersion=1.1.2 \ | |
-DgroupId=org.apache.flink.quickstart \ | |
-DartifactId=flink-scala-project \ | |
-Dversion=0.1 \ | |
-Dpackage=org.apache.flink.quickstart \ | |
-DinteractiveMode=false |
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
#!/usr/bin/env ruby | |
# Kills resque workers that are there for longer than 24 hours | |
processes = `ps ax -o pid,cmd`.split("\n") | |
processes_by_pid = processes.inject({}) do |hash, line| | |
pid, cmd = line.split(" resque-1.25.2: ") | |
hash unless pid && cmd |
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
# http://www.skorks.com/2010/05/closures-a-simple-explanation-using-ruby/ | |
# "In computer science, a closure is a first-class function with free variables that are bound in the lexical environment." | |
# | |
# "A closure is a function that is said to be "closed over" it’s free variables" | |
# | |
# | |
# * You can pass it around like an object (to be called later) | |
# | |
# * It remembers the values of all the variables that were in scope when the function was created. It is then able to |
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
#!/bin/bash | |
gnome-shell --replace & | |
killall gnome-terminal | |
sleep 2 | |
gnome-terminal --hide-menubar --maximize -e "bash -l -c 'unset TMUX; tmux attach'" &>/dev/null & |
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
#!/usr/bin/ruby | |
require 'yaml' | |
files = Dir["**/*.rb"] + Dir["**/*.haml"] | |
patterns = [ | |
/ t\('([^']+)'\)/, # t('') | |
/ t\("([^"]+)"\)/, # t("") | |
/I18n.translate\("([^"]+)"\)/, # I18n.translate("") |
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
# | |
# The MySQL database server configuration file. | |
# | |
# You can copy this to one of: | |
# - "/etc/mysql/my.cnf" to set global options, | |
# - "~/.my.cnf" to set user-specific options. | |
# | |
# One can use all long options that the program supports. | |
# Run program with --help to get a list of available options and with | |
# --print-defaults to see which it would actually understand and use. |
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
Using /home/kazjote/.rvm/gems/ruby-1.9.3-p327 | |
➜ threads time ruby threads.rb 1 | |
ruby threads.rb 1 0.02s user 0.01s system 0% cpu 10.054 total | |
➜ threads time ruby threads.rb 2 | |
ruby threads.rb 2 0.02s user 0.02s system 0% cpu 6.049 total | |
➜ threads time ruby threads.rb 4 | |
ruby threads.rb 4 0.01s user 0.02s system 0% cpu 4.040 total | |
➜ threads time ruby threads.rb 8 | |
ruby threads.rb 8 0.02s user 0.02s system 1% cpu 3.037 total | |
➜ threads time ruby threads.rb 16 |
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
const Gio = imports.gi.Gio; | |
let file = Gio.File.new_for_path('file.txt'); | |
stream = file.replace(null, false, null, null, null); | |
let str = 'hello Kacper :)'; | |
stream.write(str, null, null, null); | |
stream.close(null); |
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
require 'httparty' | |
Array.new(32) {|i| i}.map do |worker| | |
fork do | |
file = File.open("worker_#{worker}.log", "w") | |
1000.times do |i| | |
url = "http://localhost:9290/tests/test1.txt" | |
page = HTTParty.get(url) | |
file.puts("==============") | |
file.puts("url: #{url}") |
NewerOlder