Skip to content

Instantly share code, notes, and snippets.

@svoboda-jan
svoboda-jan / dice_betting_game.rb
Created November 3, 2024 19:50
A dice betting game using Opal Ruby to Javascript source-to-source compiler
# Dice Betting Game, https://opalrb.com/try/
bank = 100;
while bank > 0 do
bet = `prompt("Place your bet")`.to_i
dice1 = (rand * 6).ceil
dice2 = (rand * 6).ceil
outcome = dice1 == dice2
bank += bet if outcome
bank -= bet unless outcome
puts "Numbers are: #{dice1} #{dice2}"
@svoboda-jan
svoboda-jan / calendar2.rb
Created October 29, 2024 17:39
Example code for a console calendar in Ruby
# Console Calendar
DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
IS_LEAP_YEAR = Time.now.year % 400 == 0 || (
Time.now.year % 4 == 0 && Time.now.year % 100 != 0
)
HIGHLIGHT_CURRENNT_DAY = true
def days_in_month(month)
return 29 if Time.now.month == 2
@svoboda-jan
svoboda-jan / print.html
Created October 27, 2024 13:03
Print command for JavaScript
<script>
// Creates a Print function as an alias for console.log
// Usage Print("Hello World");
function Print(v) { console.log(v); return v };
</script>
@svoboda-jan
svoboda-jan / glibc-2.17_centos6.sh
Created October 21, 2024 17:23 — forked from harv/glibc-2.17_centos6.sh
update glibc to 2.17 for CentOS 6
#! /bin/sh
# update glibc to 2.17 for CentOS 6
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-common-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-devel-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-headers-2.17-55.el6.x86_64.rpm
sudo rpm -Uvh glibc-2.17-55.el6.x86_64.rpm \
@svoboda-jan
svoboda-jan / czech_name_days.rb
Created October 3, 2024 18:34
Current Czech Name Day
# Current Czech Name Day
require "base64"
name = ""; name_next = ""
Base64.decode64(DATA.read).each_line do |line|
name_day = line.split(" ", 3)
if name_day[0].to_i == Time.now.month && Time.now.day == name_day[1].to_i
name = name_day[2].strip
name = name[1..-1] if name.start_with? "|"
require "socket"
class Pt32
class Status
attr_reader :temperature, :program, :boiler_on
def initialize(temperature, program, boiler_on)
@temperature, @program, @boiler_on = temperature, program, boiler_on
end
end
@svoboda-jan
svoboda-jan / curl.md
Created June 20, 2024 06:18 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@svoboda-jan
svoboda-jan / smstools-eventhandler.sh
Created June 9, 2024 10:56 — forked from x-magic/smstools-eventhandler.sh
SMS Server Tools 3 event handler script (mainly used for converting messages to UTF-8 encoding, for example, those messages with CJK characters included)
#!/bin/bash
#
# This script processes events from smsd.
# It mainly will converts SMS encoded with UCS2 encoding to UTF-8 format expected by many other applications.
# To use it, edit your /etc/smsd.conf and add the following line:
#
# eventhandler = /path/to/smstools-eventhandler.sh
#
# When a new message is received in /var/spool/incoming/, message files with following header line will be converted:
#
@svoboda-jan
svoboda-jan / smstools-eventhandler.sh
Created June 9, 2024 10:56 — forked from x-magic/smstools-eventhandler.sh
SMS Server Tools 3 event handler script (mainly used for converting messages to UTF-8 encoding, for example, those messages with CJK characters included)
#!/bin/bash
#
# This script processes events from smsd.
# It mainly will converts SMS encoded with UCS2 encoding to UTF-8 format expected by many other applications.
# To use it, edit your /etc/smsd.conf and add the following line:
#
# eventhandler = /path/to/smstools-eventhandler.sh
#
# When a new message is received in /var/spool/incoming/, message files with following header line will be converted:
#
@svoboda-jan
svoboda-jan / mysql57-in-centos7.md
Created May 19, 2024 13:04 — forked from linuxkathirvel/mysql57-in-centos7.md
Install MySQL 5.7 in CentOS7/RHEL7

MySQL 5.7 installation in CentOS 7

sudo su

# Remove MariaDB packages
yum list installed | grep -i maria
yum remove mariadb.x86_64
yum remove mariadb-libs.x86_64

# Download MySQL 5.7 RPM tar