Skip to content

Instantly share code, notes, and snippets.

# Using comma as decimal separator in Rails 4 based on
# http://stjhimy.com/posts/11-using-comma-as-decimal-separator
ActiveRecord::ConnectionAdapters::Column.class_eval do
class << self
def value_to_float(value)
if value.class == Float
value
elsif value.class == String
value.gsub(',', '.').to_f
@ukasiu
ukasiu / convert.rb
Last active August 29, 2015 13:56
Enrollme googlecalendar export improver
#!/usr/bin/env ruby
# Skrypcik konwerujący zbugowany eksport do GoogleCalendar z Enrollme
# 9:35 - 11:05 -> 9:30 - 11:00
# 12:50 - 14:20 -> 12:45 - 14:15
# 14:40 - 16:10 -> 14:30 - 16:00
# 17:50 - 19:20 -> 17:45 - 19:15
TIME_MAPPING = {
'(DTSTART:.+)(T093000)(Z)' => 'T093500',
'(DTEND:.+)(T110000)(Z)' => 'T110500',
'(DTSTART:.+)(T124500)(Z)' => 'T125000',
@ukasiu
ukasiu / asd6.md
Created April 12, 2014 16:19
ASD6

Ćwiczenia 5

z iConem :D
  1. Sprawdzamy czy drzewo jest drzewem AVL

    struct Node {
        Node *left, *right;
        int val;
    }
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@ukasiu
ukasiu / keybase.txt
Created April 15, 2015 08:05
keybase
### Keybase proof
I hereby claim:
* I am ukasiu on github.
* I am lukaszgurdek (https://keybase.io/lukaszgurdek) on keybase.
* I have a public key whose fingerprint is 678B 88A7 9E88 C12A 096C 8E5B 8354 1D22 CED8 336B
To claim this, I am signing this object:
@ukasiu
ukasiu / ostatnia_cyfra_silni.cpp
Last active December 25, 2015 12:49
No, mała liczba, to sprawdziłem metodą dość brutalną podstawiając pod modulo dość dużą potęgę 10 i też mi wyszło 8. Pytanie tylko jak zrobić krótki a zarazem poprawny kod ;)
#include<iostream>
#define ULL unsigned long long
using namespace std;
ULL tenn(ULL n) {
ULL w=1,ten=1;
while(w<=n) {
w*=5; ten*=10;
}
return ten;
@ukasiu
ukasiu / Makefile
Created October 28, 2013 09:25
Makefile na jtp i wdi
#jtp
%: %.c
gcc -Wall -O2 -ansi -pedantic -std=c99 -lm -o bin/$@ $<
#wdi
%: %.cpp
g++ -O2 $< -o bin/$@
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.beans.factory.InitializingBean;
import org.jasig.cas.adaptors.jdbc.AbstractJdbcUsernamePasswordAuthenticationHandler;
/**
* Class that given a table, username field and password field will query a
* database table to see if the user exists. If the user exists, the
* encrypted password, from the datbase, will be compared to the plain
* text password, from the credentials, by using the BCrypt tools.
@ukasiu
ukasiu / pl.yml
Created January 3, 2014 22:50
Polish long date format translation with grammatical cases aka stycznia, lutego, marca...
# To be added in proper place
pl:
date:
genitive_month_names:
-
- stycznia
- lutego
- marca
- kwietnia
- maja
@ukasiu
ukasiu / kolokwium9_10_zad1.cpp
Last active January 3, 2016 16:49
Kolokwium zaliczeniowe WDI 2009/2010
/*Zad. 1 Dana jest duża tablica typu tab=array[1..n] of integer. Proszę napisać funkcję, która
zwraca informację, czy w tablicy zachodzi następujący warunek: „wszystkie elementy, których
indeks jest elementem ciągu Fibonacciego są liczbami złożonymi, a wśród pozostałych
przynajmniej jedna jest liczbą pierwszą”.
Uwagi:
• Czas na rozwiązanie zadania wynosi 25 minut, za zadanie można otrzymać 5 punktów.
• Oceniane będą: przejrzystość i czytelność kodu oraz efektywność rozwiązania.*/
#include<cstdio>
using namespace std;