Skip to content

Instantly share code, notes, and snippets.

View kiraind's full-sized avatar
🐽
strādāju

Alexei Paksevatkin kiraind

🐽
strādāju
  • Russia, Moscow
View GitHub Profile
@kiraind
kiraind / convertNEF.js
Last active January 19, 2021 13:24
Nikon RAW files converted to JPEG using mogrify with 'multithreading'
const fs = require('fs')
const cp = require('child_process')
const vamuved = require('vamuved')
function exec (command) {
return new Promise((resolve, reject) => {
cp.exec(command, (error, stdout, stderr) => {
if (error) {
reject(error.message)
#include <SoftwareSerial.h>
#include <SimpleTimer.h>
#define LED 13
#define BT_POWER 12
#define BT_RX 11
#define BT_TX 10
SoftwareSerial bluetoothPort(BT_TX, BT_RX);
SimpleTimer timer;
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_'
export default function randomBase64(length) {
let str = ''
for(let i = 0; i < length; i += 1) {
str += alphabet[
Math.floor(
Math.random() * alphabet.length
)
@kiraind
kiraind / immutate.js
Created July 22, 2019 06:49
Immutable state mutation patterns
setState({
...state,
array: [
...state.array.slice(0, i),
newArrayI,
...state.array.slice(i + 1),
]
})
@kiraind
kiraind / server2.js
Created June 5, 2019 09:41
Static&Post Node.js template
const http = require('http')
const url = require('url')
const path = require('path')
const fs = require('fs')
const port = process.argv[2] || 8888
http.createServer(function (request, response) {
if(request.method === 'GET') {
handleGet(request, response)
АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ
абвгдеёжзийклмнопрстуфхцчшщъыьэюя
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
@kiraind
kiraind / server.js
Last active October 20, 2019 01:02
Static Node.js HTTP-server with mime-type support
const http = require('http')
const url = require('url')
const path = require('path')
const fs = require('fs')
if(!process.argv[2]) {
throw new Error('please specify port as argumnet')
}
const port = parseInt(process.argv[2], 10)
@kiraind
kiraind / newcomp.sh
Created November 25, 2018 23:41
Create new react component
mkdir "src/components/$1"
echo "import React from 'react'
import './$1.css'
export default class $1 extends React.Component {
render() {
return (
<div className=\"$1\">
.model small
.stack 100h
.data
.code
start:
mov ax, @data
mov ds, ax
@kiraind
kiraind / static_server.js
Last active August 20, 2018 10:41 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
const http = require("http")
const url = require("url")
const path = require("path")
const fs = require("fs")
const port = process.argv[2] || 8888
http.createServer(function(request, response) {
const uri = url.parse(request.url).pathname
let filename = path.join(process.cwd(), 'static', uri)