Skip to content

Instantly share code, notes, and snippets.

Avatar
🦏
Rushing like a rhino

Halí V. halivert

🦏
Rushing like a rhino
View GitHub Profile
@halivert
halivert / yarn.ignore
Created Sep 24, 2021
Add gitignore when using yarn berry
View yarn.ignore
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
@halivert
halivert / config
Created Sep 3, 2021
Git alias to use with jekyll
View config
# -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 Aug 22, 2021
Split in groups a JS array
View splitIn.js
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 Apr 10, 2021
Mini test framework (Tests programs with single input (stdin) and single output (stdout))
View miniTest.sh
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 Apr 11, 2021
C utilities
View intToBin.c
#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));
@halivert
halivert / hali.sh
Last active Jun 16, 2020
CentOS 8 Initial setup
View hali.sh
#! /bin/sh
sudo dnf install nginx mariadb-server -y
sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php
sudo dnf module enable php:remi-7.4
sudo dnf install php-fpm php-mysqli -y
sudo systemctl start nginx mariadb
sudo systemctl enable nginx mariadb
@halivert
halivert / HSelect.vue
Last active Nov 16, 2019
Select for use with Vue.js
View HSelect.vue
<template>
<div>
<select v-bind="$attrs" v-model="selectedId" v-on="selectListeners">
<option
v-if="$attrs.placeholder"
:value="placeholderId"
:disabled="!enablePlaceholder"
>
{{ $attrs.placeholder }}
</option>
@halivert
halivert / BField.vue
Last active Nov 16, 2019
Field to use with Bulma
View BField.vue
<script>
export default {
name: "b-field",
inheritAttrs: false,
props: {
coverErrors: Boolean,
errors: {
type: Array,
default: function() {
return [];
@halivert
halivert / app.py
Created Jan 24, 2019
Flask minimal API
View app.py
from flask import (Flask)
from flask_restplus import (Api)
import resources
app = Flask(__name__)
api = Api(app, prefix='/v1', catch_all_404s=True)
api.add_resource(resources.TasksList, '/tasks')
@halivert
halivert / exhibidores
Created Nov 25, 2018
Script that converts pdf to jpg and copy the pdf to an usb
View exhibidores
#! /bin/zsh
setopt +o nomatch
RED='\033[0;31m'
NC='\033[0m'
PDFinDownloads=$(ls ~/Descargas/Exhibidores*.pdf -t 2>/dev/null | head -1)
mv $PDFinDownloads . 2>/dev/null
if [ $? -ne 0 ]; then
echo "${RED}There's no Exhibidor files in Descargas"
fi