Skip to content

Instantly share code, notes, and snippets.

View rarous's full-sized avatar
💭
I may be slow to respond.

Aleš Roubíček rarous

💭
I may be slow to respond.
View GitHub Profile
/**
* @copyright 2015-2016 TopMonks s.r.o.
* @flow weak
*/
import React, {Children, cloneElement} from 'react';
import component from '../component';
import {Map} from 'immutable';
type Crop = 'scale' | 'fill' | 'lfill' | 'fit' | 'mfit' | 'limit' | 'pad' | 'lpad' | 'mpad' | 'crop' | 'thumb';
export function registrationNumberValidator(regNr) {
if (!regNr || (typeof regNr !== "string") || regNr.length !== 8) return false;
const [n8, n7, n6, n5, n4, n3, n2, x] = regNr.split("").map(Number);
return (
x ===
(11 -
((8 * n8 + 7 * n7 + 6 * n6 + 5 * n5 + 4 * n4 + 3 * n3 + 2 * n2) % 11)) %
10
);
}
@rarous
rarous / config.yml
Created July 6, 2021 05:10
Ukázka užití yq na transformaci stack file
steps:
- checkout
- yq/install:
version: v4.9.6
arch: amd64
- read_access_envs:
stack_name: << parameters.stack_name >>
- run:
name: Set ENVs to stack
command: |
(def data
[{:title "Getting started"
:reset_lesson_position false
:lessons [{:name "Welcome"}
{:name "Installation"}]}
{:title "Basic operator"
:reset_lesson_position false
:lessons [{:name "Addition / Subtraction"}
{:name "Multiplication / Division"}]}
{:title "Advanced topics"
@rarous
rarous / Deploy.ps1
Created September 14, 2010 14:06
Script for packaging and deployment of ASP.NET applications to IIS via Web Deploment Tools
Properties {
$Build_dir = Split-Path $psake.build_script_file
$Packages_dir = Join-Path $build_dir 'Packages'
$MsDeploy_dir = Join-Path $env:ProgramFiles 'IIS\Microsoft Web Deploy'
$SiteName = 'www.example.com'
$Package = "$SiteName.zip"
$Dest = 'hosting.com'
$UserName = 'IIS User Name'
$Pwd = 'Secret Password'
@rarous
rarous / 1.cs
Last active February 16, 2021 14:13
static string TryGetErrorMessage(XElement html)
{
var errMessage = html.GetElementsByClassName("ErrorMessage").FirstOrDefault();
var errText = html.GetElementsByClassName("ErrorText").FirstOrDefault();
var errorMessage = String.Empty;
if (errMessage != null && (!errMessage.Attributes("style").Any() || (errMessage.Attributes("style").Any() && errMessage.Attributes("style").First().Value != "visibility:hidden;")))
errorMessage = errMessage.Value.Trim();
if (errText != null)
errorMessage = errText.Value.Trim();
return errorMessage;

Keybase proof

I hereby claim:

  • I am rarous on github.
  • I am rarous (https://keybase.io/rarous) on keybase.
  • I have a public key ASBuiDfE06iXsjjSc07H7z5dnMK3hezIB8ZF8bmil8b7AQo

To claim this, I am signing this object:

const apiCertificate = getCertificate(this.domainName);
this.apiDistribution = new aws.apigateway.DomainName(name, {
domainName: this.domainName,
endpointConfiguration: { types: "EDGE" },
securityPolicy: "TLS_1_2",
certificateArn: apiCertificate.apply(x => x.arn)
});
const hostedZone = getHostedZone(this.domainName);
this.dnsRecord = new aws.route53.Record(name, {
name: this.domainName,
@rarous
rarous / typovy-sebeklam.ts
Created May 3, 2020 16:04
Ukázka typové masturbace, kvůli špatně otypované knihovně
// drive().files.export je otypovaná jako Promise<void>,
// ale skutečný typ je dán parametrem v { responseType: "stream" }
// Aby se uspokojil kompilátor, musíme nejprve typ zázračně zapomenout
// a pak si ho přetypovat dle libosti. Masturbace.
async function convertToPdf(fileId: string): Promise<fs.ReadStream> {
const response: unknown = await drive().files.export(
{ fileId, mimeType: "application/pdf" },
{ responseType: "stream" }
);
@rarous
rarous / trace.json
Created April 28, 2020 13:51
Pay to go app
This file has been truncated, but you can view the full file.
{"traceEvents":[
{"args":{"name":"CrBrowserMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":29580,"tid":775,"ts":0},
{"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":29580,"tid":33027,"ts":0},
{"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":29583,"tid":24835,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":29585,"tid":775,"ts":0},
{"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":29585,"tid":19715,"ts":0},
{"args":{"name":"Chrome_DevToolsHandlerThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":29580,"tid":46083,"ts":0},
{"args":{"name":"Chrome_IOThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":29580,"tid":29187,"ts":0},
{"args":{"name":"Chrome_ChildIOThread"},"cat":"__metadata","name":"thread_name","ph":"M","pid":29585,"tid":18179,"ts":0},
{"args":{"name":"Chrome_Chi