Skip to content

Instantly share code, notes, and snippets.

View Grabber's full-sized avatar

Luiz Vitor Martinez Cardoso Grabber

View GitHub Profile
@Grabber
Grabber / gist:3087620
Created July 11, 2012 02:44
HighChart - Best Label Angle
from datetime import timedelta
from math import ceil, fabs, acos, sqrt, degrees
import Tkinter as tk
import tkFont
import datetime
import time
from random import randint
def get_chart_segments_from_total_of_days(date_days):
if (date_days <= 31): # format x-axis daily
#include <glm/glm.hpp>
#include <glm/ext.hpp>
int main() {
auto m1 = glm::mat4(1.0f);
auto m2 = glm::mat4(2.0f);
printf("%s\n", glm::to_string(m1 * m2).c_str());
return 0;
@Grabber
Grabber / gist:de8a2b7de587cf8e58f4e3f6bb55cf23
Created January 26, 2017 02:49
calculating priori anchors with k-means
# -*- coding: utf-8 -*-
import time
import numpy as np
from random import randint
iou_vals = []
iou_count = 0
class Test:
@Grabber
Grabber / gist:a9999aa647f075bdac8ed3f79efd0513
Created July 9, 2018 02:12
DMG-6661: semi automated virtual servers remove
var rules = document.querySelectorAll('*[id^="enable_"]');
var remove_items = 100;
for (var i = rules.length; i--;) { document.getElementById(rules[i].id).checked = true; remove_items--; if (remove_items < 0) break; }
@Grabber
Grabber / zmq.go
Last active October 8, 2021 13:37
zmq / poller / proxy
poller := zmq.NewPoller()
poller.Add(frontend, zmq.POLLIN)
poller.Add(backend, zmq.POLLIN)
for {
var sockets []zmq.Polled
sockets, err := poller.Poll(-1)
if err != nil {
break
@Grabber
Grabber / sorting.py
Last active October 8, 2021 21:20
I can't believe it can sort: is this the simplest (and most surprising) sorting algorithm ever?
import random
def icantbelieveitcansort(a: list) -> tuple:
ops = 0
for i in range(0, len(a)):
for j in range(0, len(a)):
if a[i] < a[j]:
a[i], a[j] = a[j], a[i]
ops += 1
return (a, ops)
@Grabber
Grabber / vec.cpp
Last active November 13, 2021 17:20
C++: std::vector reserve
#include <vector>
#include <cstdio>
int main(int argc, char *argv[]) {
std::vector<int> x(10);
std::fprintf(stdout, "x.0: %lu\n", x.size());
x.push_back(1);
x.push_back(2);
x.push_back(3);
std::fprintf(stdout, "x.1: %lu\n", x.size());
@Grabber
Grabber / keychron_remap.md
Last active November 9, 2022 21:35
Keychron: how to remap and swap "§±" and "`~" keys on UK layout

As the Keychron K3 keyboard with UK layout has the great L-shaped ENTER key but the uncomfortable placed "§±" and "`~" keys, here is a solution to swap both keys without any third party software on OSX.

hidutil property --set '{
  "UserKeyMapping":[
    {
      "HIDKeyboardModifierMappingSrc":0x700000035,
      "HIDKeyboardModifierMappingDst":0x700000064
    },
    {
@Grabber
Grabber / RUN.md
Last active October 15, 2022 00:52
bpi m2z / eth0
sudo apt-get -f install --yes
cd /tmp
chmod a+x dtc-compile.sh
./dtc-compile.sh
dtc -I dts -O dtb -o bananapi-m2-zero-eth0.dtbo bananapi-m2-zero-eth0.dts 
sudo mkdir -p /boot/overlay-user
@Grabber
Grabber / App.jsx
Last active July 18, 2023 01:33
Experimenting React 18.2.0: Context API
import React, { useState, useReducer, useEffect, useContext } from 'react';
const Ctx = React.createContext();
const Display = () => {
return (
<Ctx.Consumer>
{ ctx => ( <span>value: {ctx.a}</span> ) }
</Ctx.Consumer>
);