Skip to content

Instantly share code, notes, and snippets.

View srghma's full-sized avatar

Serhii Khoma srghma.github.io/how-life-was-created srghma

View GitHub Profile
@srghma
srghma / transmerge.sh
Created February 11, 2024 13:47 — forked from bathtime/transmerge.sh
A simple Linux shell script for translating an .srt file into another language and merging both languages into an .ass file
#!/bin/sh
#
# This program takes an .srt file, translates it, and merges both translations into a .ass file with the user's selected
# language on top of the screen and the other language at the bottom.
#
# Usage: ./transmerge.sh [source language] [target language] [language on top (en|fri|...)] [source .srt] [target .ass (optional)]
#
# ex., $ ./transmerge.sh en fr en movie.srt
#
@srghma
srghma / 1.Как стать программистом.md
Last active January 6, 2024 06:31
как стать программистом

fix function - https://github.com/NixOS/nixpkgs/blob/9f087964709174424bca681b600af8ee8e763df5/lib/fixed-points.nix#L19 , https://en.m.wikipedia.org/wiki/Fixed_point_(mathematics) , point where x = f(x) = f(f(f(f....f(x)....)))

rec { a = 1; b = a + 1; } is the same as fix (self: { a = 1; b = self.a + 1; })

builtins.trace - https://github.com/NixOS/nixpkgs/blob/9f087964709174424bca681b600af8ee8e763df5/lib/debug.nix#L4 trace has different flavors, http://hackage.haskell.org/package/base-4.12.0.0/docs/Debug-Trace.html#v:trace all lazy languages have trace

builtins.seq - in lazy languages data is represented as thunks (IF data has not been yet evaluated THEN it's pointer on function that should produce this data ELSE it's pointer on data), builtins.seq forces first layer of data to evaluate (evaluates it to WHNF?), builtins.deepSeq is recursive variant of seq, it forces whole data to evaluate (evaluates it to NF?), (more https://wiki.haskell.org/Seq, https://www.google.com/amp/s/amp.reddit.

import * as React from 'react'
import { useState } from 'react'
import ReactDOM from 'react-dom'
import { StyledEngineProvider } from '@mui/material/styles'
import * as R from 'ramda'
import * as RA from 'ramda-adjunct'
import { useMIDI, useMIDIOutput } from '@react-midi/hooks'
// import { Pcset } from "@tonaljs/tonal"
//
// TODO: calculate Forte number
// ==UserScript==
// @name etimologias.dechile.net
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://etimologias.dechile.net/?huella
// @icon https://www.google.com/s2/favicons?sz=64&domain=dechile.net
// @grant GM_addStyle
@srghma
srghma / MindTrash.md
Last active October 10, 2022 09:54
MindTrash

How to debug sublime plugins:

  • install rpdb through pip
  • import rpdb; rpdb.set_trace()
  • telnet 127.0.0.1 4444

Разница между CSRF (Cross-Site Request Forgery) и XSS (Cross-Site Scripting)

Оба - атака на пользователя, в отличие от SQL Injection (атака на сервер)

XSS:
  • цель - заставить браузер жертв(ы) исполнить код

run geth using

geth --datadir ./myDataDir --dev --http --http.api web3,eth,debug,personal,net --http.corsdomain "https://remix.ethereum.org,http://remix.ethereum.org" --vmdebug

in https://remix.ethereum.org deploy contract

contract MyContract {
delete require.cache['/home/srghma/.node_modules/lib/node_modules/ebook-convert/index.js']
convert = require('/home/srghma/.node_modules/lib/node_modules/ebook-convert')
async function convertAsync(options) {
return new Promise((resolve, reject) => {
convert(options, function (error) {
if (error) { return reject(error) }
return resolve()
})
})
}
var R = require('ramda')
console.log(R.sortBy(R.prop(1), Object.entries(require('fs').constants)).map(([key, value]) => `${value.toString(2).padStart(21, '~')} ${key}`).join('\n'))
~~~~~~~~~~~~~~~~~~~~0 O_RDONLY
~~~~~~~~~~~~~~~~~~~~0 UV_DIRENT_UNKNOWN
~~~~~~~~~~~~~~~~~~~~0 UV_FS_O_FILEMAP
~~~~~~~~~~~~~~~~~~~~0 F_OK
~~~~~~~~~~~~~~~~~~~~1 UV_FS_SYMLINK_DIR
@srghma
srghma / test.purs
Last active February 25, 2022 17:05
purescript-coroutines
-- | 'guy state (start): { state: 0 }'
-- | 'appleTree state (start): { state: 0 }'
-- | 'appleTree state (1 put): { state: 1 }'
-- | 'guy awaitInput (1 await): { output: 1 }'
-- | 'guy state (1 get): { state: 1 }'
-- | 'appleTree state (1 emit): { state: 1 }'
-- | 'appleTree state (2 put): { state: 2 }'
-- | 'guy awaitInput (2 await): { output: 2 }'
-- | 'guy state (2 get): { state: 2 }'
-- | '(Tuple unit { state: 2 })'