Skip to content

Instantly share code, notes, and snippets.

View halivert's full-sized avatar
🦏
Rushing like a rhino

Halí V. halivert

🦏
Rushing like a rhino
View GitHub Profile
@halivert
halivert / index.html
Created September 21, 2023 21:04
Split paragraph in lines
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et.</p>
@halivert
halivert / count.py
Created September 28, 2022 13:42
Count participants of csv zoom meeting report in python
import csv
import sys
def readCSV(file_name):
with open(file_name, newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='|')
return [row[0] for row in reader]
@halivert
halivert / tsconfig.json
Last active April 28, 2022 11:07
Vite app with Typescript
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
@halivert
halivert / useFetch.js
Last active April 20, 2022 17:16
My own useFetch composable/hook
const parseOptions = (options) => {
if (typeof options === "string") return parseOptions({ endpoint: options })
if (!Array.isArray(options)) {
return { endpoint: "", method: "GET", data: null, opts: {}, ...options }
}
if (options.length > 1) {
const [endpoint = "", method = "GET", data = null, opts = {}] = options
return { endpoint, method, data, opts }
@halivert
halivert / AppServiceProvider.php
Created December 11, 2021 21:08
Set query grammar to support timestamps of n precision
<?php
namespace App\Providers;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Query\Grammars\MySqlGrammar;
class AppServiceProvider extends ServiceProvider
{
@halivert
halivert / yarn.ignore
Created September 24, 2021 19:48
Add gitignore when using yarn berry
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
@halivert
halivert / config
Created September 3, 2021 22:35
Git alias to use with jekyll
# -w Enable auto regeneration
# -o Open the site in the URL
# -l Live reload
# -H Hostname
# -P Port
serve = "!bundler exec jekyll serve -wol -H localhost -P 4000"
@halivert
halivert / splitIn.js
Created August 22, 2021 18:41
Split in groups a JS array
const splitIn = (elements, groups) => {
return elements.reduce((result, val, _, elements) => {
let lastItem = result[result.length - 1];
if (lastItem.length === Math.ceil(elements.length / groups)) result.push([val]);
else lastItem.push(val);
return result;
}, [[]]);
}
@halivert
halivert / miniTest.sh
Created April 10, 2021 06:11
Mini test framework (Tests programs with single input (stdin) and single output (stdout))
EXEC="./$1"
function test() {
if [ "$1" $2 "$3" ]; then
echo -e "\e[32mPASS\e[0m"
else
echo -e "\e[31mNOT PASS - $1 $4 $3 \e[0m"
fi
}
@halivert
halivert / intToBin.c
Last active April 11, 2021 17:14
C utilities
#include <stdlib.h>
char *intToBin(int num) {
int bits = (num == 0);
int cp = num;
for (cp = num; cp > 0; cp >>= 1) bits++;
char *result = (char *)malloc(bits * sizeof(char));