Skip to content

Instantly share code, notes, and snippets.

View yuraxdrumz's full-sized avatar

Yuri Khomyakov yuraxdrumz

View GitHub Profile
@yuraxdrumz
yuraxdrumz / install-arch-v2.md
Created July 29, 2018 21:30 — forked from mjnaderi/install-arch.md
Install arch linux with full system encryption, LVM on LUKS
package regex;
import org.junit.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static regex.CronRegex.Field.*;
import static java.util.Arrays.asList;
@yuraxdrumz
yuraxdrumz / my_app.ex
Created March 23, 2019 18:36 — forked from alanpeabody/my_app.ex
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@yuraxdrumz
yuraxdrumz / redis_cheatsheet.bash
Created April 8, 2019 14:31 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@yuraxdrumz
yuraxdrumz / polling_log_reader.ex
Created April 8, 2019 17:46 — forked from kylethebaker/polling_log_reader.ex
Example polling a log file
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Log Reader - polls log file and sends new lines to channel
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
defmodule LogReader do
use GenServer
@log_file "priv/some_log.log"
@poll_interval 5 * 1000 # 5 seconds
def run_test() do
@yuraxdrumz
yuraxdrumz / toUTF8Array.js
Created October 22, 2019 14:14 — forked from joni/toUTF8Array.js
toUTF8Array: Javascript function for encoding a string in UTF8.
function toUTF8Array(str) {
var utf8 = [];
for (var i=0; i < str.length; i++) {
var charcode = str.charCodeAt(i);
if (charcode < 0x80) utf8.push(charcode);
else if (charcode < 0x800) {
utf8.push(0xc0 | (charcode >> 6),
0x80 | (charcode & 0x3f));
}
else if (charcode < 0xd800 || charcode >= 0xe000) {
@yuraxdrumz
yuraxdrumz / toUTF8Array.js
Created October 22, 2019 14:14 — forked from joni/toUTF8Array.js
toUTF8Array: Javascript function for encoding a string in UTF8.
function toUTF8Array(str) {
var utf8 = [];
for (var i=0; i < str.length; i++) {
var charcode = str.charCodeAt(i);
if (charcode < 0x80) utf8.push(charcode);
else if (charcode < 0x800) {
utf8.push(0xc0 | (charcode >> 6),
0x80 | (charcode & 0x3f));
}
else if (charcode < 0xd800 || charcode >= 0xe000) {
@yuraxdrumz
yuraxdrumz / example.js
Created October 23, 2019 13:03 — forked from heyimalex/example.js
Using mock-fs with jest
// __tests__/example.js
jest.mock('fs');
it('should serve as a nice example', () => {
const fs = require('fs')
// fs can be set up at any point by calling __configureFs.
fs.__configureFs({
'/test': {
@yuraxdrumz
yuraxdrumz / client.js
Created October 27, 2019 11:22 — forked from PaulMougel/client.js
File upload in Node.js to an Express server, using streams
// node: v0.10.21
// request: 2.27.0
var request = require('request');
var fs = require('fs');
var r = request.post("http://server.com:3000/");
// See http://nodejs.org/api/stream.html#stream_new_stream_readable_options
// for more information about the highWaterMark
// Basically, this will make the stream emit smaller chunks of data (ie. more precise upload state)
var upload = fs.createReadStream('f.jpg', { highWaterMark: 500 });
@yuraxdrumz
yuraxdrumz / s3-upload-file.js
Created October 27, 2019 12:40 — forked from osmangoninahid/s3-upload-file.js
Uploading file to Amazon S3 Bucket in NodeJS Express example
var http = require('http');
var router = require('routes')();
var Busboy = require('busboy');
var AWS = require('aws-sdk');
var inspect = require('util').inspect;
var port = 5000;
// Define s3-upload-stream with S3 credentials.
var s3Stream = require('s3-upload-stream')(new AWS.S3({
accessKeyId: '',