This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tells you how long ago was `inputDate` in "x days/weeks/months ago" format using `Intl` | |
* ({@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl docs}). | |
* Automatically changes the resolution from days, to weeks, to months, to keeps things readable. | |
* Returns the exact date if the `inputDate` happened very long time ago. | |
* | |
* Dates only, time is ignored. | |
* | |
* You can use `forcedLocale` to get the string in a specific locale, otherwise a browser locale | |
* is used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Group elements in `xyz` array in `groupSize`-length arrays | |
const xyz = ['a','b','c','d','e','f','g','h','i']; | |
const groupSize = 3; | |
xyz.reduce<string[][]>((result, item, idx) => | |
new Boolean((idx % groupSize | |
? result[result.length-1].push(item) | |
: result.push([item]))) | |
&& result, | |
[]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For this trick you'll need: | |
// | |
// $ node --experimental-repl-await | |
// | |
// If you happen to use Typescript alias paths, you'll also want to install `tsconfig-paths` | |
// and actually run the node REPL with: | |
// | |
// $ TS_NODE_PROJECT=path/to/tsconfig.json node -r tsconfig-paths/register --experimental-repl-await | |
// | |
// All the statements need to be input inside REPL. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from pprint import pprint | |
base_url = 'https://polona.pl/api/' | |
entities = 'entities/?format=json' | |
filters = '&filters=category:serials+public:1+has_text_content:1+language:polski' | |
seed = '&seed=8' | |
size = '&size=45' | |
resp = requests.get(base_url + entities + size + seed + filters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
import qrcode | |
from PIL import Image | |
from bs4 import BeautifulSoup | |
BASE_URL = 'https://easyweb.workshop.codisec.com' | |
TEMPLATE_IMG = 'template.png' | |
USER = 'andrzej' | |
PASSWORD = 'andrzej' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AbstractSdmFactory { | |
private final String url | |
private final long rfcId | |
private final long reqId | |
public Ticket createTicket(long issueTypeId, LinkedHashMap attributes) { | |
if (this.rfcId == issueTypeId) { | |
return new Rfc('attributes': attributes) | |
} else if (this.reqId == issueTypeId) { | |
return new Request('attributes': attributes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Tuple<Point, Point> FindClosestPoints(List<Point> points, out double minDistance) | |
{ | |
var minDist = double.PositiveInfinity; | |
int lastDeleted = 0; | |
Point a = new Point(); | |
Point b = new Point(); | |
SortedSet<Point> tree = new SortedSet<Point>(new ByY()); | |
var pointsArray = points.ToArray(); | |
Array.Sort(pointsArray, new ByX()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <ctype.h> | |
#include <sys/wait.h> | |
#include <string.h> |