Skip to content

Instantly share code, notes, and snippets.

View Humberd's full-sized avatar

Maciej Sawicki Humberd

  • Warsaw, Poland
View GitHub Profile
@Humberd
Humberd / async-validator-wrapper.ts
Last active October 31, 2019 19:00
Async Validator Wrapper for Angular 2 Reactive Forms.This wrapper lets you debounce your asyncValidator instead of on every keystroke
import { AbstractControl } from "@angular/forms";
import { Observable } from "rxjs/Observable";
import { Subject } from "rxjs/Subject";
export class QstAsyncValidatorWrapper {
/*
* Angular async validators are triggered on every key stroke.
* This function debounces triggering an async validator.
*
var _0xeae2 = ["\x79\x31\x79", "\x79\x79\x32", "\x79\x79\x33", "\x79\x79\x34", "\x79\x79\x35", "\x79\x79\x36", "\x79\x79\x37", "\x79\x79\x38", "\x79\x79\x39", "\x79\x32\x30", "\x79\x32\x79", "\x79\x32\x32", "\x79\x32\x33", "\x79\x32\x34", "\x79\x32\x35", "\x79\x32\x36", "\x79\x32\x37", "\x79\x32\x38", "\x79\x32\x39", "\x79\x33\x30", "\x21\x33\x21", "\x21\x33\x32", "\x21\x33\x33", "\x21\x33\x34", "\x21\x33\x35", "\x21\x33\x36", "\x21\x33\x37", "\x21\x33\x38", "\x21\x33\x39", "\x21\x34\x30", "\x21\x34\x21", "\x21\x34\x32", "\x21\x34\x33", "\x21\x34\x34", "\x21\x34\x35", "\x21\x34\x36", "\x21\x34\x37", "\x21\x34\x38", "\x21\x34\x39", "\x21\x35\x30", "\x21\x35\x21", "\x21\x35\x32", "\x21\x35\x33", "\x31\x62\x34", "\x31\x62\x62", "\x31\x62\x61", "\x31\x62\x37", "\x31\x62\x38", "\x31\x62\x39", "\x31\x61\x30", "\x31\x61\x31", "\x31\x61\x32", "\x31\x61\x33", "\x31\x61\x34", "\x31\x61\x62", "\x31\x61\x61", "\x31\x61\x37", "\x31\x61\x38", "\x31\x61\x39", "\x31\x37\x30", "\x31\x37\x31", "\x31\x37\x32", "\x31\x37\x33", "
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<title>Document</title>
@Humberd
Humberd / scratch.ts
Created January 21, 2018 19:08
foobar
export const calculateParticipantsNumberOnParticipantCreate = functions.database.ref("/users/{userId}/zgloszenia/{zgloszenieId}")
.onCreate(event2 => {
const {userId, zgloszenieId} = event2.params;
return event2.data.adminRef.root.child(`/users/${userId}/wyniki`).once('value')
.then(eventSnapshot => {
const {rokMatury, przedmioty} = eventSnapshot.val();
return event2.data.adminRef.root.child(`/users/${userId}/zgloszenia/${zgloszenieId}`).update({
liczbaPunktow: 12345
@Humberd
Humberd / scratch_2.ts
Created January 22, 2018 16:51
removeuser
export const removeUserFromRankingOnZgloszenieDelete = functions.database.ref('/users/{userId}/zgloszenia/{zgloszenieId}')
.onDelete(event2 => {
const {userId, zgloszenieId} = event2.params;
const {kodKierunku} = event2.data;
return evet2.data.adminRef.root.child(`/ranking/${kodKierunku}/zgloszenia/${zgloszenieId}`).remove()
});
struct BoardColumn {
int iteration;
bool* column;
int columnIndex;
int leftColumnProcRank;
int rightColumnProcRank;
};
std::vector<BoardColumn> bcs; // BoardColumnS
////////////////////////////////// task1
db.Film.createIndex({address: "text"})
/////////////////////////////////// task2
db.zadanieMongo.find(
{
age: {$lt: 20},
$text: { $search: "California Texas Pennsylvania" }
},
{
fun main(args: Array<String>) {
val firstSection:Double = 1.0;
val lastSection:Double = 2.0;
val epsilon:Double = 0.00000001;
val b = Bisekcja(firstSection,lastSection,epsilon).also { }
println("Miejsce zerowe funkcji: " + b.zero() + ". Liczba iteracji: " + b.zero())
}
@Humberd
Humberd / love-watcher
Last active February 15, 2019 19:58
Paste this script directly in the URL of your erepublik tab and you will be redirected to one of the active love boosted AIR battles. If it finds nothing it will retry by itself in 10 seconds.
javascript:async function loop() { async function getBattles() { const response = await fetch( 'https://www.erepublik.com/en/military/campaigns-new/'); const data = await response.json(); const battleIds = Object.keys(data.battles); const airBattleIds = battleIds.filter( it => data.battles[it].type === 'aircraft', ); return airBattleIds; } async function hasLoveBoost(battleId) { const response = await fetch( `https://www.erepublik.com/en/military/nbp-stats/${battleId}/4`); const data = await response.json(); return data.battleEffects.valentinesDay.is_active; } function printLinks(battleId) { return `https://www.erepublik.com/en/military/battlefield/${battleId}`; } console.log('Loop triggered'); const battles = await getBattles(); const results = await Promise.all(battles.map(hasLoveBoost)); const boostedBattles = results.map((val, index) => { if (val) { return battles[index]; } return val; }) .filter(it => it) .map(printLinks); if (boostedBattles.length > 0) { location.replace(boostedBattles[0]); } console.lo
version: '3.1'
services:
db:
image: bitnami/postgresql:12.2.0
restart: always
environment:
POSTGRESQL_USERNAME: admin
POSTGRESQL_PASSWORD: admin123
POSTGRESQL_DATABASE: admin