Skip to content

Instantly share code, notes, and snippets.

View v6ak's full-sized avatar

Vít Šesták v6ak

View GitHub Profile

Tak ukážu příklad v jazyce Scala. Nedávno jsem psal nějaké zpracování akordama označkovaného textu a konverzi do PDF. Controller by v imperativní verzi (tj. s callbacky) mohl vypadat zhruba takto:

def processChordbook(songText: String) {
	convertToPdf(songText).onSuccess{ pdfData =>
		setHeader("Content-type"->"application/pdf")
		out.write(pdfData)
		out.close()
	}
}
@v6ak
v6ak / sum.scala
Last active August 29, 2015 14:20
scala> import scala.concurrent._
import scala.concurrent._
scala> // Nadefinujeme funkci plus. Ta chce kromě hodnot ke sčítání také ExecutionContext, který určuje,
//kde se to vykoná.
scala> def plus(x: Int, y: Int)(implicit ec: ExecutionContext) = Future{x+y}
plus: (x: Int, y: Int)(implicit ec: scala.concurrent.ExecutionContext)scala.concurrent.Future[Int]
scala> // Podobně nadefinujeme i sum. Bude pracovat se spojovými seznamy. Bacha při kopírování na
My main partition:
% grep 99999999 /mnt/q/var/log/boot.log
Starting Cryptography Setup for luks-99999999-8888-7777-6666-555555555555...
[ OK ] Found device /dev/mapper/luks-99999999-8888-7777-6666-555555555555.
[ OK ] Started Cryptography Setup for luks-99999999-8888-7777-6666-555555555555.
Expecting device dev-disk-by\x2duuid-99999999\x2d8888\x2d7777\x2d6666\x2d555555555555.device...
Expecting device dev-mapper-luks\x2d99999999\x2d8888\x2d7777\x2d6666\x2d555555555555.device...
[ OK ] Found device /dev/mapper/luks-99999999-8888-7777-6666-555555555555.
………
# I pressed Ctrl+Alt+Delete
<?php
function lacyConnection() {
$conn = null;
return function() use (&$conn) {
if ($conn!==null) {
return $conn;
}else{
return connect(…);
}
}
<?php
function lacyConnection() {
$conn = null;
return function() use (&$conn) {
if ($conn===null) {
$conn = connect(…);
}
return $conn;
}
};
<?php
function lacyConnection() {
$conn = null;
return function() use (&$conn) {
if ($conn!==null) {
return $conn;
}else{
$comm = connect(…);
return $comm;
}
cryptswap1 /dev/sdaX /dev/random swap,cipher=aes-cbc-essiv:sha256
$ yum --installroot /var/lib/qubes/dom0-updates --config=/etc/yum.conf check-update -v
Loading "langpacks" plugin
Loading "post-transaction-actions" plugin
Loading "yum-qubes-hooks" plugin
Adding en_US to language list
Config time: 0.011
Yum version: 3.4.3
rpmdb time: 0.000
Building updates object
Setting up Package Sacks
#!/bin/bash
old=""
while true; do
new="$(xdotool getwindowfocus)"
if [ "$old" != "$new" ]; then
echo a
# Tried both windowfocus and windowactivate
xdotool \
search --onlyvisible --class '^Plasma$' \
windowfocus --sync \
$ sudo qubes-dom0-update --enablerepo=qubes-dom0-unstable qubes-gui-dom0
2015-05-24T12:34:16+0000
Using sys-firewall as UpdateVM to download updates for Dom0; this may take some time...
Running command on VM: 'sys-firewall'...
Loaded plugins: langpacks, post-transaction-actions, yum-qubes-hooks
Package matching qubes-gui-dom0-3.0.2-1.fc20.x86_64 already installed. Checking for update.
Nothing to do
Existing lock /var/run/yum.pid: another copy is running as pid 5308.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit