Skip to content

Instantly share code, notes, and snippets.

View Eraden's full-sized avatar
🔧
I may be slow to respond.

Adrian Woźniak Eraden

🔧
I may be slow to respond.
View GitHub Profile
function leftPad(str, len, ch) {
ch = !ch || ch !== 0 ? ' ' : ch;
for (let i = 0; i < len - str.length; i++) str = ch + str;
return str;
}
function leftPad2(str, len, ch) {
str = String(str);
let i = -1;
if (!ch || ch !== 0) ch = ' ';
cmake_minimum_required(VERSION 3.24)
project(studia)
set(CMAKE_CXX_STANDARD 23)
find_package(GTest REQUIRED)
enable_testing()
include_directories(${GTEST_INCLUDE_DIRS})
add_executable(studia main.cpp)
// shared/auth/src/lib.rs
// The MIT License (MIT)
// Copyright (c) 2021 Tsumanu
// Access token with Bearer
use std::future::Future;
use std::rc::Rc;
@Eraden
Eraden / config
Created August 7, 2021 19:41
Sway
# .config/sway/config
set $mod Mod4
set $left h
set $down j
set $up k
set $right l
set $term alacritty
set $menu BEMENU_BACKEND=wayland bemenu-run --fn $uifont -b -p "▶" --tf "$prompt" --hf "$highlight" --sf "$highlight" --scf "$highlight" | xargs swaymsg exec
@Eraden
Eraden / old.rs
Last active August 4, 2021 13:31
Way faster version
#![feature(test)]
extern crate test;
use std::collections::HashMap;
use std::env::args;
use std::fs::File;
use std::io::{self, BufRead};
use num_bigint::BigUint;
/* always use lodash! https://lodash.com/ */
module.exports = {
entry: {
vendor: ['react', 'react-redux', 'redux', 'moment', 'lodash'],
main: 'your-main'
},
output: {
path: path.join(root, 'dist'),
filename: '[name].[hash].js',
chunkFilename: '[id].css',
function randn_bm(min, max, skew) {
var u = 0, v = 0;
while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
while(v === 0) v = Math.random();
let num = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
num = num / 10.0 + 0.5; // Translate to 0 -> 1
if (num > 1 || num < 0) num = randn_bm(min, max, skew); // resample between 0 and 1 if out of range
num = Math.pow(num, skew); // Skew
num *= max - min; // Stretch to fill range
import { DELETE_FILE_ENTITY, GET_FILE_ENTITIES, GET_FILE_ENTITY } from "./types"; // NO!
import * as types from "./types"; // YES
// NO!
export const getFile = filename => {
const res = await axios.get(`http://localhost:8080/api/files/${filename}`);
dispatch({
type: GET_FILE_ENTITY,
payload: res.data
});
@Eraden
Eraden / fish.sh
Created January 22, 2019 09:40
Install fish
sudo apt-get install fish
curl -L https://get.oh-my.fish | fish
omf install apt bundler gem rails rustup rvm android-sdk git-status sdk