Skip to content

Instantly share code, notes, and snippets.

View gyulalaszlo's full-sized avatar

Gyula László gyulalaszlo

View GitHub Profile
@gyulalaszlo
gyulalaszlo / index.html
Last active November 25, 2016 11:09
D3 training 2016.11.25
<!DOCTYPE html>
<html>
<head>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-color.v1.min.js"></script>
<script src="https://d3js.org/d3-dispatch.v1.min.js"></script>
<script src="https://d3js.org/d3-ease.v1.min.js"></script>
<script src="https://d3js.org/d3-interpolate.v1.min.js"></script>
@gyulalaszlo
gyulalaszlo / LogWatcher.cs
Created November 9, 2015 16:03
C# log file watcher
using System;
using System.Threading;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
///
@gyulalaszlo
gyulalaszlo / loaded_dice_basline.cljc
Created August 26, 2015 15:57
Loaded dice simulation in clojure
(ns clj-loaded-dice.core)
(defn make-loaded-dice
"Create the data structure for the loaded dice."
[& probabilities]
(let [total-probability (apply + probabilities)]
(->>
;; normalize the probabilities to sum up to 1
(map #(/ % total-probability) probabilities)
@gyulalaszlo
gyulalaszlo / test.cpp
Last active August 29, 2015 14:24
Comparison of in-place vs return-by-value
// This is a bad comparison as the data gets written back to the source array,
// so in-place has an advantage here.
// Compile with
//
// clang++ --std=c++11 -stdlib=libstdc++ -static -lstdc++ test.cpp
// On my machine it prints:
// When running unoptimized:
@gyulalaszlo
gyulalaszlo / evan_alt.zsh-theme
Created April 28, 2015 17:49
Birx zsh theme for Oh-my-zsh
# Evan describes this sexy prompt as: "a skinny, topless prompt"
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)%{$reset_color%}"
local dir_str="%{$fg[cyan]%}%2~%{$reset_color%}"
PROMPT='${ret_status} %m :: ${dir_str} %B»%b %{$reset_color%}'
@gyulalaszlo
gyulalaszlo / clj-dag.clj
Last active August 29, 2015 14:18
Simple Clojure code to solve a DAG
; Takes a list of tasks and their dependencies, solves a DAG
; and returns the order in which the tasks
; should be run, grouping the paralellizable tasks into lists.
;
; Transforms this task list:
; {:sql_1 []
; :sql_sum [:sql_1]
; :sql_3 []
; :view [:sql_1 :sql_sum]}
;
@gyulalaszlo
gyulalaszlo / dag_processing_test.rb
Last active August 29, 2015 14:18
Example of processing a DAG in ruby
class Task
attr_reader :key, :deps, :block, :all_dependencies
# Creates a new task
def initialize key, &to_do_block
@key, @deps, @all_dependencies = key, [], []
@block = to_do_block.to_proc if to_do_block
end
# Mark the dependencies of this task
@gyulalaszlo
gyulalaszlo / haml_watcher.thor
Last active December 13, 2015 20:39
A Thor task to watch a (directory of .haml templates and compile them to another directory. See usage.md at the bottom.
# Script to watch a directory for any changes to a haml file
# and compile it.
# Copyright © 2013 Gyula László. Code released under the DWTFYW License.
require 'fssm'
require 'haml'
class HamlWatch < Thor
@gyulalaszlo
gyulalaszlo / quicksearch.coffee
Created September 10, 2012 16:06
STA szallasfoglalo transcode
from_date_strings = (s1, s2)->
s2 = "0#{s2}" if s2 < 10
"#{s2}.#{s1[4..5]}.#{s1[0..3]}"
$(->
$('#repcsi_es_szallas form').submit ->
self = this
t = (sc)-> $(sc, self)
@gyulalaszlo
gyulalaszlo / abingo_logAnal.thor
Created January 16, 2012 01:31
Mopping up the floor after ABingo shits itself
#encoding: UTF-8
require 'rubygems'
require 'builder'
#Started POST "/gyorskereso/repjegy/purchase?url=http%3A%2F%2Fflight1.onlinetravel.ch%2Fcgi-bin%2Fflightmore" for 188.36.35.62 at 2011-12-03 04:11:57 +0000
REQUEST_LINE = /^Started ([A-Z]+) "(.*?)" for ([0-9\.]+) at (.*?)$/
LAYOUT_RENDER_LINE = /^Rendered (.*?) within (.*?) \(/
ABINGO_BINGO = /ABingo#bingo!/