This file contains hidden or 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
// здесь нужна только сеть | |
const net = require("net"); | |
const client = new net.Socket(); | |
// «звоним» на номер 127.0.0.1:1234 | |
// (да, это мой номер, но для целей данной статьи подходит) | |
client.connect(1234, "127.0.0.1", () => { | |
console.log("подключаемся к серверу.."); | |
// говорим в трубку, что мы хотим сказать |
This file contains hidden or 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
const net = require("net"); // тут только сеть, работать непосредственно с файлом мы не будем | |
const socketPath = "/tmp/my_awesome.sock"; | |
const client = net.createConnection({path: socketPath}, () => { | |
console.log("подключаемся к серверу.."); | |
// пишем нашему серверу, через сеть, в его файл сокета | |
client.write("salem baurym"); // сообщение стандартизовано нашим протоколом прикладного уровня ^_^ | |
}); |
This file contains hidden or 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
#lang racket | |
; SICP exercise 1.3 (page 27) | |
; Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. | |
(define (sum-of-squares-of-two-largest-args a b c) | |
(cond ((and (< a b) (< a c)) (+ (* b b) (* c c))) | |
((and (< b a) (< b c)) (+ (* a a) (* c c))) | |
((and (< c a) (< c b)) (+ (* a a) (* b b))))) |
This file contains hidden or 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 {assertEquals} from "https://deno.land/std@0.209.0/assert/mod.ts"; | |
class LinkedList<T> { | |
#value: T; | |
#next?: LinkedList<T>; | |
constructor(value: T, next?: LinkedList<T>) { | |
this.#value = value; | |
this.#next = next; | |
} |
This file contains hidden or 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
function hexToRgb(hex) { | |
let m = hex.match(/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i); | |
let r = parseInt(m[1], 16); | |
let g = parseInt(m[2], 16); | |
let b = parseInt(m[3], 16); | |
return {r, g, b}; | |
} |
This file contains hidden or 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
class String | |
def /(s) | |
self + "/" + s | |
end | |
end | |
CWD ,= ARGV[0] | |
raise ArgumentError unless Dir.exists? CWD | |
STOP_WORDS = %w( this var let const class function true false require process ) |
This file contains hidden or 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
source "https://rubygems.org" | |
gem "whirly" | |
gem "colorize" | |
gem "tty-table" | |
gem "tty-prompt" | |
group :development do | |
gem "pry" | |
end |
This file contains hidden or 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 { User } from './User' | |
import { UserManager } from 'oidc-client' | |
const mockGetUser = jest.fn() | |
const mockSigninRedirect = jest.fn() | |
const mockSigninRedirectCallback = jest.fn() | |
const mockSignoutRedirect = jest.fn() | |
const mockSignoutRedirectCallback = jest.fn() | |
jest.mock('oidc-client', () => ({ |
This file contains hidden or 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 PouchDB from "pouchdb"; | |
import { useState, useEffect } from "react"; | |
let dbPool = new Map<string, PouchDB.Database>(); | |
let resolveOrCreateDb = <T>(dbName: string, dbPrefix = "sfpic_") => { | |
let db = dbPool.get(dbName); | |
if (db instanceof PouchDB) return db as PouchDB.Database<T>; | |
db = new PouchDB<T>(dbPrefix + dbName); | |
dbPool.set(dbName, db); |
This file contains hidden or 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
#!/usr/bin/env node | |
const fs = require('fs') | |
const { exec } = require('child_process') | |
const COMMIT_EDITMSG = process.argv[2] | |
exec('git symbolic-ref --short HEAD', (err, branch) => { | |
if (err) throw err |
NewerOlder