Skip to content

Instantly share code, notes, and snippets.

View dvinciguerra's full-sized avatar
:octocat:
Bite my shine metal class!!!

Daniel Vinciguerra dvinciguerra

:octocat:
Bite my shine metal class!!!
View GitHub Profile
@dvinciguerra
dvinciguerra / uptime_parser.rb
Created May 24, 2024 21:53
Ruby uptime cli stdout parsing
# getting uptime stdout
str = `uptime`
pp(str);
# parsing uptime
str.match(
/^(?<current>\d+:\d+)\s+(?<message>up (?<amount>\d+) (?<unit>days|minutes|seconds)),\s+(?<boot_at>\d+:\d+),\s+(?<users>(?<user_count>\d+) user|users),\s+(?<load_avgs>.*)\s$/
)
@dvinciguerra
dvinciguerra / gist:700682c7755ad14ad774d425141a662b
Created April 9, 2024 16:22 — forked from pulcheri/gist:2498951
Perl one-liner strings replace
first=$1
second=$2

# Replace
find -name *.cpp -or -name *.h | xargs grep "$first" -l  | xargs perl -pi -e "s/$first/$second/g"

a=getDefaultIncludes; b=get_include_dirs_def; find -name "*.py" -or -name "SC*" | xargs grep "$a" -l  | xargs perl -pi -e "s/$a/$b/g"

a=abc; b=def; find -name "*.cpp" -or -name "*.h" | xargs grep "$a" -l | xargs perl -pi -e "s/$a/$b/g"
@dvinciguerra
dvinciguerra / settings.json
Created January 17, 2024 12:25 — forked from diego3g/settings.json
VSCode Settings (Updated)
{
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 14,
"editor.lineHeight": 1.8,
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.rulers": [80, 120],
"extensions.ignoreRecommendations": true,
"typescript.tsserver.log": "off",
"files.associations": {
@dvinciguerra
dvinciguerra / bot
Last active November 10, 2023 02:12
Ruby ChatGPT CLI to ask things without leave terminal
#!/usr/bin/env ruby
# _ _
# | |__ ___| |_
# | '_ \ _ \ _|
# |_.__\___/\__|
# Ruby ChatGPT CLI to ask things without leave terminal
# by dvinciguerra
require 'bundler/inline'
@dvinciguerra
dvinciguerra / twitch_channel_current_in_live.rb
Last active September 26, 2023 21:44
Twitch cli to check if channel is online without accessing browser or receive a push notification
# frozen_string_literal: true
require 'faraday'
require 'json'
require 'logger'
require 'oga'
require 'pastel'
module Twitch
module PageLoader
@dvinciguerra
dvinciguerra / custom.css
Created August 15, 2023 21:36
My personal Logseq Dracula theme customizations (based on oficial dracula theme)
@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&display=swap');
:root {
--background: #282a36;
--light-background: #343746;
--lighter-background: #424450;
--dark-background: #21222c;
--darker-background: #191a21;
--foreground: #f8f8f2;
--current-line: #44475a;
@dvinciguerra
dvinciguerra / nvim-tree.lua
Created August 14, 2023 20:02
Fix Dracula and Dracula Pro themes for Neovim using NvimTree
-- fix dracula theme
local color = vim.g.current_colorscheme
if color == "dracula" or color == "dracula_pro" then
vim.cmd("hi link VertSplit DraculaBgDarker")
vim.cmd("hi link NvimTreeNormal DraculaBgDarker")
vim.cmd("hi link NvimTreeVertSplit DraculaBgDarker")
vim.cmd("hi link NvimTreeStatusLine DraculaBgDarker")
vim.cmd("hi link NvimTreeWinSeparator DraculaBg")
vim.cmd("hi link BufferCurrentMod DraculaError")

FWIW: I (@Rondy) am not the author of the content presented here, which is an outline from Edmond Lau's book. I've just copy-pasted it from somewhere and saved as a personal gist, before it got popular on newsnews.ycombinator.com. I don't remember where exactly the original source is from and neither could find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

@dvinciguerra
dvinciguerra / grav-cms-change-editor.js
Created December 26, 2022 16:53
Grav CMS editor hack (change to a wysiwyg)
// prepare editor resources
editor = {
script: '<script src="https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js"></script>',
style: '<link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />',
}
// inject editor source in grav webpage
body = document.querySelector('body')
body.insertAdjacentHTML('beforeend', editor.style)
body.insertAdjacentHTML('beforeend', editor.script)
@dvinciguerra
dvinciguerra / esp8266.h
Created July 24, 2022 18:19
ESP8266 pin mapping
/**
* Reference:
* https://randomnerdtutorials.com/esp8266-pinout-reference-gpios
*/
// esp8266-01
// #define GPIO0 00
// #define GPIO1 01
// #define GPIO2 02
// #define GPIO3 03