Skip to content

Instantly share code, notes, and snippets.

View Zyndoras's full-sized avatar
💭
🐧

Alex Sella Zyndoras

💭
🐧
View GitHub Profile
@Zyndoras
Zyndoras / cpu_cores.rb
Last active June 23, 2021 23:27
Log CPU usage percentage per core
#!/usr/bin/env ruby
$stdout.sync = true
cpu_last = {}
cpu_last_sum = {}
loop do
cpus = IO.readlines('/proc/stat').select { |line| line.start_with?('cpu') }
@Zyndoras
Zyndoras / rotate.js
Last active April 29, 2024 11:41
Rotate base64 image (Javascript)
function rotate(srcBase64, degrees, callback) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const image = new Image();
image.onload = function () {
canvas.width = degrees % 180 === 0 ? image.width : image.height;
canvas.height = degrees % 180 === 0 ? image.height : image.width;
ctx.translate(canvas.width / 2, canvas.height / 2);