Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dusekdan's full-sized avatar
🟠
MIA

Daniel Dusek dusekdan

🟠
MIA
View GitHub Profile
/**
* Displays program's help screen
*/
void showHelp ()
{
printf ("Ticket algorithm synchronization demo.\n\n");
printf ("Usage: ./XXX N M\n\n");
printf ("Creates N threads and simulates M number of total passes through critical section protected by ticket algorithm.\n\n");
printf ("No other available options. Wrong parameters to the program shows this help.\n");
}
@dusekdan
dusekdan / FIT-VUT-WAP-DOMTreeJS.htm
Last active May 11, 2017 14:33
Update wrong function call (refactoring left over)
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
// DOM Node Type ELEMENT (=> we are only interested in elements, we dont want (attributes/CDATA/etc.))
var DOM_TYPE_ELEMENT = 1;
// TAG NAME of root element we want to use for DOM tree traversing
var ROOT_NODE_TAG_NAME = 'html';
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
// Identificator of span which display mode should be altered
var SPAN_IDENTIFICATION = 'elementident';
function changeDisplayModeToBlock(elementId)
{
@dusekdan
dusekdan / XPath selector - All URLs from HTML attributes
Last active November 22, 2021 12:52
Extracts URLs from HTML attributes with type of URI.
-- When fed to XPath selects all URLs from HTML document
-- from within HTML attributes designated to hold URL
-- One-line version
"//a/@href | //applet/@codebase | //area/@href | //base/@href | //blockquote/@cite | //body/@background | //del/@cite | //form/@action | //frame/@src | //frame/@longdesc | //head/@profile | //iframe/@longdesc | //iframe/@url | //img/@longdesc | //img/@usemap | //input/@src | //input/@usemap | //ins/@cite | //object/@classid | //object/@codebase | //object/@data | //object/@usemap | //q/@cite | //img/@src | //link/@href | //source/@src | //embed/@src | //script/@src | //audio/@src | //button/@formaction | //command/@icon | //html/@manifest | //input/@formaction | //video/@poster | //video/@src"
-- Multi-line version (readable)
"//a/@href
| //applet/@codebase
| //area/@href
| //base/@href
% #1
% Get last element from the list
% Explanation:
% Last element of list containing one element is the element
% Recursively call my_last on TAIL of the list, in rule head notice the underscore
% sign. We put it there because our rule body does not need to contain named
% reference to the list head - in other words, we don't care about it.
my_last(X, [X]).
my_last(X, [_|T]) :- my_last(X, T).
@dusekdan
dusekdan / 99 Haskell Problems with explanation.hs
Last active June 2, 2017 18:54
99 Haskell Problems (https://wiki.haskell.org/99_questions) as solved and explained by Daniel Dušek
-- #1
-- Find the last element of a list
-- Explanation:
-- Last element of one-element list is the element
-- General list last element is discovered by recursively calling myLast over
-- the tail of the list (xs). Once case myLast [x] is hit, we got our last
-- element.
myLast :: [a] -> a
myLast [x] = x
myLast (x:xs) = myLast(xs)
SHELL := /bin/bash
# Retrieves todo items from LaTeX file and prints them (+ their count)
define get_todo_items
@allTodoItems=$$(grep -i '% todo' xdusek21.tex | wc -l); echo -e "\n\e[33mFound \e[91m$$allTodoItems \e[33mTODO items:\n"
@grep -i '% todo' xdusek21.tex | while read -r line ; do echo -e "\t \e[92m$$line\n" ; done ; echo -e "\e[39m"
endef
all:
# Spotify fix
127.0.0.1 media-match.com
127.0.0.1 adclick.g.doublecklick.net
127.0.0.1 www.googleadservices.com
127.0.0.1 pagead2.googlesyndication.com
127.0.0.1 desktop.spotify.com
127.0.0.1 googleads.g.doubleclick.net
127.0.0.1 audio2.spotify.com
127.0.0.1 www.omaze.com
127.0.0.1 omaze.com

Vypracování otázek z první přednášky

2.01: Sebereflexe a sebeřízení

2.01.1 Peníze:

  • A. Nefungují jako motivace, pouze jako faktor hygieny, tedy stimulace.
  • B. Jsou stimulantem, protože nemohou vyvolat pocit motivace.
  • C. Mohou motivovat i stimulovat, byť je schopnost motivace omezena.
  • D. Fungují jako nejsilnější faktor motivace i stimulace zároveň.

2.01.2 Ke které behaviorální kompetenci se vztahuje následující chování: "Kritika ho uráží anebo pobuřuje, na útoky reaguje agresivně, často reaguje emocionálně a nekontroluje se. Vůči ostatním je zaujatý.":

import sys
import os
import datetime
from shutil import copy
# By far the easiest way to get song duration is to use mutagen library. You
# can install it using PIP as follows:
# pip install mutagen
from mutagen.mp3 import MP3
from mutagen import MutagenError