Skip to content

Instantly share code, notes, and snippets.

View yuraxdrumz's full-sized avatar

Yuri Khomyakov yuraxdrumz

View GitHub Profile
@yuraxdrumz
yuraxdrumz / sysctl.conf
Created January 11, 2020 16:25 — forked from kgriffs/sysctl.conf
Linux Web Server Kernel Tuning
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# an explanation about some of these parameters, and instructions for
# a few other tweaks outside this file.
#
# See also: https://gist.github.com/kgriffs/4027835
#
# Assumes a beefy machine with lots of network bandwidth
@yuraxdrumz
yuraxdrumz / values_pointers.go
Created November 11, 2019 14:00 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@yuraxdrumz
yuraxdrumz / network-tweak.md
Created November 2, 2019 12:39 — forked from mustafaturan/network-tweak.md
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@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: '',
@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 / 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 / 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 / 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 / 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.