Skip to content

Instantly share code, notes, and snippets.

@infloop
infloop / trampoline.ts
Created March 31, 2023 01:05 — forked from tusharmath/trampoline.ts
Trampolining in Typescript
// stub for typescript
declare function BigInt(n: number): number
abstract class Trampoline<A> {
abstract map<B>(ab: (a: A) => B): Trampoline<B>
abstract flatMap<B>(ab: (a: A) => Trampoline<B>): Trampoline<B>
zip<B>(tb: Trampoline<B>): Trampoline<[A, B]> {
const ta = this
return ta.flatMap(a => tb.map(b => [a, b] as [A, B]))
@infloop
infloop / dhcp-leases-to-dns.rsc
Created March 24, 2020 15:52 — forked from SmartFinn/dhcp-leases-to-dns.rsc
MikroTik (RouterOS) script for automatically setting DNS records for clients when they obtain a DHCP lease
# MikroTik (RouterOS) script for automatically setting DNS records
# for clients when they obtain a DHCP lease.
#
# author SmartFinn <https://gist.github.com/SmartFinn>
# based on https://github.com/karrots/ROS-DDNS
:local domain;
:local fqdn;
:local hostname;
:local safeHostname;
@infloop
infloop / Task01.js
Last active September 14, 2019 18:30
Задания по JS
// 1.1 Вывести на экран сумму переменных a + b
let a = 1;
let b = 20;
console.log(?);
// 1.2 Вывести на экран разницу переменных b - a
// Пример: 4
console.log(?);
@infloop
infloop / yandexTest.js
Created September 12, 2019 10:38
Yandex click on all links
const {Builder, By, until} = require('selenium-webdriver');
(async function yandexTest() {
let driver = await new Builder().forBrowser('chrome').build();
try {
await driver.get('http://yandex.ru');
// индекс текущей ссылки
let currentLinkIndex = 0;
@infloop
infloop / createInterface.ts
Last active August 16, 2018 13:30
instanceOf Typescript
import {isImplements} from '../index';
export type InterfaceTag<T> = ({ new (...args: any[]): T, readonly id: symbol });
export function createInterface<I>(name: string): InterfaceTag<I>{
let id = Symbol.for(name);
let interfaceTag = (class {
private static readonly identifier: symbol = id;
static [Symbol.hasInstance](instance) {
@infloop
infloop / assign.ts
Created August 9, 2018 11:10
Assign with type checking (typescript)
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
type Omit<T, K extends keyof T> = Pick<T, ({ [P in keyof T]: P } & { [P in K]: never } & { [x: string]: never })[keyof T]>;
export function assign<T extends NonFunctionProperties<Omit<S, K>>, S extends Object, K extends keyof S>(target: T, source: S, exclude?: K[]): void {
Object.keys(source).forEach(key => {
// exclude Object methods
if (typeof source[key] === 'function') {
@infloop
infloop / nightmare-on-amazon-linux.MD
Created July 30, 2017 22:16 — forked from dimkir/nightmare-on-amazon-linux.MD
How to run nightmare on Amazon Linux

Running nightmare on Amazon Linux

You may have thought of running nightmare on AWS Lambda. But before we can run it on Lambda, we need first to make it run on Amazon Linux.

Provision instance which replicates Lambda environment

According to AWS Documentation on Lambda Execution Environment and available Libraries we would need this AMI image with this alias amzn-ami-hvm-2016.03.3.x86_64-gp2. Keep in mind that AMI-image-id for this instance would be different in different regions (eg):

  • In eu-west-1 - ami-f9dd458a
  • In us-east-1 - ami-6869aa05
@infloop
infloop / nightmare-on-amazon-linux.MD
Created July 30, 2017 22:16 — forked from dimkir/nightmare-on-amazon-linux.MD
How to run nightmare on Amazon Linux

Running nightmare on Amazon Linux

You may have thought of running nightmare on AWS Lambda. But before we can run it on Lambda, we need first to make it run on Amazon Linux.

Provision instance which replicates Lambda environment

According to AWS Documentation on Lambda Execution Environment and available Libraries we would need this AMI image with this alias amzn-ami-hvm-2016.03.3.x86_64-gp2. Keep in mind that AMI-image-id for this instance would be different in different regions (eg):

  • In eu-west-1 - ami-f9dd458a
  • In us-east-1 - ami-6869aa05
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats