Skip to content

Instantly share code, notes, and snippets.

View terkalma's full-sized avatar
🏠
Working from home

Terkál Róbert terkalma

🏠
Working from home
View GitHub Profile
@terkalma
terkalma / decode_session_cookie.rb
Last active August 25, 2017 19:52 — forked from profh/decode_session_cookie.rb
A simple script to decode Rails 4 session cookies
class Control {
float a1, a2, a3, a4, a5, a6;
Control(float a1, float a2, float a3, float a4, float a5, float a6) {
this.a1 = a1;
this.a2 = a2;
this.a3 = a3;
this.a4 = a4;
this.a5 = a5;
this.a6 = a6;
require 'Date'
class Derangement
@@derangements = Hash.new do |hash, index|
hash[index] = []
end
def initialize(n)
@random = Random.new
@terkalma
terkalma / Gemfile
Last active August 29, 2015 14:27
fbfun
source 'https://rubygems.org'
gem 'rest-client'
gem 'byebug'
import numpy as np
class Estimator:
def __init__(self, x, y):
"""
x -- matrix where each row is a feature vector
y -- vector of labels
"""
self.x = x
self.y = y
#
# Recursion generating all valid 5 length permutations.
#
def patterns(pattern, i)
if pattern.length == 5
p_p pattern and return
end
(1..5).each do |v|
if is_valid(pattern[0...i], v)
@terkalma
terkalma / img_2_wav.py
Created February 21, 2015 13:22
wav processing
import numpy as np
import cv2
import os
import pdb
import wave
from array import array
from bisect import bisect
PICTURE_PATH = '~/Downloads/1001-2000/'
// BreakTheRope challenge on codility
// https://codility.com/programmers/challenges/sulphur2014
#include <iostream>
#include <vector>
using namespace std;
int solution(vector<int> &A, vector<int> &B, vector<int> &C) {
@terkalma
terkalma / paths.rb
Created December 5, 2014 21:35
# /r/dailyprogrammer #188 hard
# /r/dailyprogrammer #188 hard
@lines = []
file_enum = File.open('input.txt','rb').each
first_line = file_enum.next
@m, @n = first_line.split(/\W/).map(&:to_i)
@n.times do |i|
line = file_enum.next.split('')
line.map! do |chr|
@terkalma
terkalma / query_duration.rb
Created November 13, 2014 01:22
Nice robot voice reading the duration of all your queries on OSX.
# Nice robot voice reading the duration of all your queries on OSX.
ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
`say #{event.duration}`
end