Skip to content

Instantly share code, notes, and snippets.

View calbertts's full-sized avatar

Carlos Castaño calbertts

View GitHub Profile
echo -e "\n Downloading formatcss...\n"
platform=`uname -s`
distro=`cat /etc/*-release 2>/dev/null | grep ^ID=[A-Za-z]* | sed s/ID=/-/g | sed s/\"//g`
arch=`uname -m`
curl -sL -o /usr/bin/formatcss github.com/calbertts/formatcss/releases/latest/download/formatcss-$platform$distro-$arch
chmod a+x /usr/bin/formatcss
echo -e "\n Great!, now you can run 'formatcss' from anywhere\n\n Try with:\n \e[92mformatcss --url https://www.w3schools.com/w3css/4/w3.css\n\n\e[0m"
@calbertts
calbertts / QuickJS_Process_Makefile
Created August 17, 2019 18:36
QuickJS Process Makefile
OBJDIR=.obj
CC=gcc
CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d -Wno-array-bounds
LDFLAGS=-flto
CFLAGS_OPT=$(CFLAGS) -O2 -flto
DEFINES:=-D_GNU_SOURCE
CFLAGS+=$(DEFINES)
LIBS=/usr/local/lib/quickjs/libquickjs.a
INCLUDES=-I/usr/local/include/quickjs
@calbertts
calbertts / myAsynScript.js
Created August 17, 2019 18:14
Run external process from QuickJS
import * as std from "std"
import * as os from "os"
import { open, close } from "process"
const CHUNK_SIZE = 200000 // 200KB
const fd = open('curl 2>/dev/null https://jsonplaceholder.typicode.com/users', 'r')
os.setReadHandler(fd, function() {
let readBuf = new Uint8Array(CHUNK_SIZE)
@calbertts
calbertts / process.c
Last active October 24, 2021 04:00
C Module for QuickJS
#include <quickjs/quickjs.h>
#include <errno.h>
#include <string.h>
#define countof(x) (sizeof(x) / sizeof((x)[0]))
JSValue createError(JSContext *ctx, int err) {
JSValue obj;
obj = JS_NewError(ctx);
@calbertts
calbertts / LICENSE
Created June 2, 2019 18:49
This license applies to all public gists https://gist.github.com/calbertts
MIT License
Copyright (c) 2017 Martin Buberl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
# vim:fileencoding=utf-8:ft=conf
# You can include secondary config files via the "include" directive.
# If you use a relative path for include, it is resolved with respect to the
# location of the current config file. For example:
# include other.conf
# Fonts {{{
# Font family. You can also specify different fonts for the
# bold/italic/bold-italic variants. By default they are derived automatically,
" Kepp selected test when fixing indentation
vnoremap < <gv
vnoremap > >gv
"Clipboard
set clipboard=unnamedplus
" Netwr (Explore)
let g:netrw_banner = 0
let g:netrw_liststyle = 3
@calbertts
calbertts / init.vim
Last active January 8, 2020 16:43
Neovim config
let g:loaded_youcompleteme = 1
if empty(glob('~/.vim/autoload/plug.vim'))
silent execute "!curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
" Kepp selected test when fixing indentation
vnoremap < <gv
vnoremap > >gv
function color_my_prompt {
local __user_and_host="@\u"
local __cur_location="\[\033[01;34m\]\W"
local __git_branch_color="\[\033[32m\]"
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\\(.+\)$/\\\\\\1\\ /`'
local __prompt_tail="\[\033[35m\]$"
local __last_color="\[\033[00m\]"
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
}
color_my_prompt
@calbertts
calbertts / removec.sh
Last active February 24, 2017 14:44
Removes a stopped docker container
removec() {
export FZF_DEFAULT_OPTS='--height 90% --reverse --border'
local container=$((docker ps -a --filter status=exited --format '{{.Names}} => {{.Image}} => EXITED' & docker ps -a --filter status=created --format '{{.Names}} => {{.Image}} => CREATED') | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}')
if [[ $container != '' ]]; then
echo -e "\n \033[1mDocker container:\033[0m" $container
printf " \033[1mAre you sure?: \033[0m"
local cmd=$(echo -e "No\nYes" | fzf-tmux --reverse --multi)
if [[ $cmd != '' ]]; then
if [[ $cmd == 'Yes' ]]; then
echo -e " Removing $container ...\n"