Skip to content

Instantly share code, notes, and snippets.

View zbicin's full-sized avatar
🏝️

Krzysztof Zbiciński zbicin

🏝️
View GitHub Profile

OwnCloud on Proxmox in local network 101

Create OwnCloud container from template

https://pve.proxmox.com/wiki/Linux_Container

tldr: In your proxmox instance:

pveam update
pveam available | grep cloud
# find owncloud template name and download it
const http = require('http');
const requestListener = function (req, res) {
res.writeHead(200);
res.end(JSON.stringify({ headers: req.headers, cookies: req.cookies }));
}
const server = http.createServer(requestListener);
const port = process.env.ECHO_SERVER_PORT || 8080;
server.listen(port, '0.0.0.0', () => {
@zbicin
zbicin / counting-sort-alternative.js
Last active October 8, 2021 16:24
Counting Sort implementation in JavaScript
function countingSort(inputArray) {
const max = Math.max(...inputArray);
const counters = new Array(max+1).fill(0); // or Int32Array without fill
// count
inputArray.forEach(inputValue => {
counters[inputValue]++;
});
// accumulate
for(let i = 1; i<counters.length; i++) {
counters[i] = counters[i] + counters[i-1];
@zbicin
zbicin / binary-search.js
Last active November 17, 2021 17:20
Binary Search implementation in JavaScript
function binarySearch(arr, value, start = 0, end = arr.length - 1) {
if (start > end) {
return -1;
}
const middleElementIndex = Math.floor((end - start) / 2) + start;
const middleElementValue = arr[middleElementIndex];
if (value === middleElementValue) {
return middleElementIndex;
}
@zbicin
zbicin / quick-sort.js
Last active October 7, 2021 17:09
QuickSort implementation in JavaScript
function quickSort(arr, start = 0, end = arr.length - 1) {
if (start < end) {
const sortedIndex = partition(arr, start, end);
quickSort(arr, start, sortedIndex-1);
quickSort(arr, sortedIndex+1, end);
}
}
function swap(arr, a, b) {
@zbicin
zbicin / sds011_dht11_blynk.cpp
Created December 9, 2020 16:52
SDS011 dust sensor + DHT11 + Blynk
#include <Arduino.h>
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "SdsDustSensor.h"
#include "DHT.h"
#define DHTPIN D7
@zbicin
zbicin / GetOptimizationStatus.md
Created October 15, 2020 12:30 — forked from naugtur/GetOptimizationStatus.md
V8 %GetOptimizationStatus

%GetOptimizationStatus return a set of bitwise flags instead of a single value, to access the value, you need to take the binary representation of the returned value. Now, for example, if 65 is returned, the binary representation is the following:

(65).toString(2).padStart(12, '0');
// 000001000001

Each binary digit acts as a boolean with the following meaning:

@zbicin
zbicin / README.md
Last active October 6, 2020 17:50
Shapes and IC test

Results

Each test was performed 5 times and an average time was calculated.

Optimized Size Average time [ms] Heap size [MB]
10e2 0.06158013343811035 3.1507919311523436
10e4 2.3224000930786133 10.012129211425782
10e6 246.5065408229828 487.14283142089846
✔️ 10e2 0.05734000205993652 2.86851806640625
@zbicin
zbicin / ConEmu.xml
Created September 2, 2020 15:03
ConEmu color scheme based on Horizon Default VSCode theme
<key name="Palette2" modified="2020-08-26 17:28:49" build="180206">
<value name="Name" type="string" data="Horizon"/>
<value name="ExtendColors" type="hex" data="00"/>
<value name="ExtendColorIdx" type="hex" data="0E"/>
<value name="TextColorIdx" type="hex" data="10"/>
<value name="BackColorIdx" type="hex" data="10"/>
<value name="PopTextColorIdx" type="hex" data="10"/>
<value name="PopBackColorIdx" type="hex" data="10"/>
<value name="ColorTable00" type="dword" data="00261e1c"/>
<value name="ColorTable01" type="dword" data="00d9bb26"/>
@zbicin
zbicin / .bashrc
Last active December 14, 2021 01:39
Git Bash aliases
# If __git_complete command is not found on Linux, you might need to add this line first:
# [ -f /usr/share/bash-completion/completions/git ] && . /usr/share/bash-completion/completions/git
# Source: https://stackoverflow.com/questions/9869227/git-autocomplete-in-bash-aliases#comment104140198_47496210
#
# Git Push/Pull
alias gps='git push';
__git_complete gps _git_push_
alias gpl='git pull';
__git_complete gpl _git_pull