Skip to content

Instantly share code, notes, and snippets.

View TeWu's full-sized avatar
💭
Loading...

Tomasz Więch TeWu

💭
Loading...
View GitHub Profile
@TeWu
TeWu / shift_ciphers_challenge.rb
Last active May 18, 2020 17:09
Shift Ciphers Challenge
## Here values of secret_offset, secret_key1, secret_key2, plaintext_01, plaintext_02 and plaintext_03 are set
require 'shift_ciphers' # Library's code at: https://github.com/TeWu/shift-ciphers (version 1.0.1)
caesar = ShiftCiphers::Caesar.new(offset: secret_offset)
vigenere = ShiftCiphers::Vigenere.new(secret_key1)
strong_vigenere = ShiftCiphers::HardenedVigenere.new(secret_key2)
p caesar.encrypt(plaintext_01) # => "!M;BL;AtKw;MH;ytBEd;uNM;BM;BL;PHKLx;GxOxK;MH;AtOx;MKBxw;MH;LNvvxxwe;1_AxHwHKx;)HHLxOxEM"
p vigenere.encrypt(plaintext_02) # => "qit$b#D1R-js+ntrt'-7U-hy+bImv-Ehw-Hv/z9$T:l6&qty\".{Go{m1@p"
@TeWu
TeWu / Naprawa_MBR_Windows10.md
Last active July 22, 2018 15:48
Naprawa MBR Windows 10

Naprawa MBR Windows 10

  1. Włóż płytę instalacyjną Windows 10 do napędu DVD
  2. Uruchom komputer ponownie, bootując go z tej płyty
  3. Po uruchomieniu instalatora kliknij w Repair your computer w lewym dolnym rogu okienka instalatora
  4. Wybierz Troubleshoot -> Command Prompt by otworzyć konsolę
  5. Wykonaj w konsoli następujące polecenia:
bootrec /FixMbr
@TeWu
TeWu / t_test_example.r
Last active February 19, 2022 21:05
R Student's t-Test
observations <- c(17.13, 17.71, 17.51, 19.39, 17.70, 19.15, 17.17, 18.48, 21.71, 19.55, 17.63, 18.55, 14.77)
tr <- t.test(observations, mu=18, conf.level=0.99)
tr # print Test Results
# Plot t-distribution
stderr <- sqrt(var(observations)/length(observations))
x <- seq(-4, 4, by=0.01)
y <- dt(x, df=tr$parameter)
plot(x, y, type='l')
abline(v=0, col="black")
@TeWu
TeWu / hermite_interpolator.rb
Last active October 9, 2017 01:37
Hermite Interpolator
##
# Polynomial interpolator using both sample values and sample derivatives.
# Source: https://commons.apache.org/proper/commons-math/javadocs/api-3.6/org/apache/commons/math3/analysis/interpolation/HermiteInterpolator.html
#
class HermiteInterpolator
def initialize(*points_and_derivatives)
@abscissae = []
@top_diagonal = []
@TeWu
TeWu / krpc_events.rb
Last active July 1, 2019 14:02
krpc-rb Events API
##
## Some non-binding thoughts on krpc-rb Events API.
## (This API Concept is probably too high-level.)
##
KRPC.connect do |client|
v = client.space_center.active_vessel
# Fires once
v.orbit.once :apoapsis_altitude, :change do |apo|
@TeWu
TeWu / lambda_factorial.js
Last active September 2, 2024 18:34
Factorial function in lambda calculus - implemented in JS
///
/// Factorial function in lambda calculus - implemented in JS
///
//// Lambda calculus
// zero = λs.λz.z
// succ = λn.λs.λz.s (n s z)
// mult = λn.λm.λs.m (n s)
// pred = λn.λf.λx.n(λg.λh.h (g f))(λu.x)(λu.u)
// minus = λn.λm.m pred n
@TeWu
TeWu / roles_bitmask_serializer_support.rb
Created April 30, 2017 12:07
RolesBitmaskSerializerSupport
module RolesBitmaskSerializerSupport
extend ActiveSupport::Concern
RolesBitmaskSerializer = GamesBox::Serializers::RolesBitmaskSerializer
class_methods do
def serialize_as_roles_bitmask(deserialized_attr, serialized_attr)
deser_setter_name = "#{deserialized_attr}=".to_sym
ser_setter_name = "#{serialized_attr}=".to_sym
setInterval(() => $('body').css('background-color', "#"+(Math.round(Math.random()*1000000))),500)
@TeWu
TeWu / fib.rb
Last active December 15, 2016 16:56
## INSPIRED BY: Eigenvectors and eigenvalues | Essence of linear algebra, chapter 10
## https://www.youtube.com/watch?v=PFDu9oVAE-g&feature=youtu.be&t=16m28s
require 'bigdecimal'
def fib(n, accuracy = 100)
n = BigDecimal.new(n - 1)
accuracy = 10 if n < 80
sqrt5 = BigDecimal.new(5).sqrt(accuracy) # sqrt(p1) - Returns the square root of the value. If p1 is specified, returns at least that many significant digits.
# Where all the 'magic' happens: