Skip to content

Instantly share code, notes, and snippets.

View rianby64's full-sized avatar
🐋
Let's GO

Andres Rios rianby64

🐋
Let's GO
  • 02:19 (UTC +03:00)
View GitHub Profile
@rianby64
rianby64 / readStream.go
Created September 14, 2019 17:29
Reader for io.ReadCloser
// Nice reader for request.Body
func readStream(stream io.ReadCloser) (string, error) {
defer stream.Close()
body := ""
buffer := make([]byte, 4)
for {
n, err := stream.Read(buffer)
if err != nil {
if err == io.EOF {
@rianby64
rianby64 / test-connection.sh
Created September 11, 2019 20:02
Esperar una conexion
#!/bin/bash
i=0
while [ true ]
do
echo "testing connection localhost:2345"
(echo >/dev/tcp/localhost/2345) &>/dev/null && i=0 || i=-1
if [ $i -eq 0 ]; then
echo "ready"
@rianby64
rianby64 / start.tcl
Last active January 10, 2018 14:41
TCL SQL notify listen
package require Pgtcl
proc notification { d } {
puts "notification from SQL: $d"
# Here I expect to see
# notification from SQL: this is a payload
}
set db [pg_connect -conninfo \
[list host=localhost user=test dbname=test password=test]]
@rianby64
rianby64 / mycetmpl.html
Last active March 14, 2017 11:37
A simple template
<!doctype html>
<div>
Here's the template for my-custom-element
</div>
<script>
fetch('https://gist.githubusercontent.com/rianby64/e2a3ebad701b12552938b649655567f8/raw/myjson.json').then(response => response.json()).then(json => {
console.log(json);
});
</script>
@rianby64
rianby64 / windowError.html
Created October 7, 2016 12:54
A simple demo that shows how to catch all errors through the window.onerror (via addEventListener)
<!doctype html>
<html>
<body>
<button>Fire error</button>
<script>
'use script';
window.addEventListener('error', e => {
console.error('catch error', e);
});
@rianby64
rianby64 / select-region.html
Created September 30, 2016 10:59
An example about how to draw a region by using mouse gestures
<!doctype html>
<html>
<head>
<style>
.fullwindow {
position: absolute;
height: 100%;
width: 100%;
top: 0px;
left: 0px;
@rianby64
rianby64 / .vimrc
Last active December 7, 2016 06:29
My Vim RC
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'airblade/vim-gitgutter'
Plugin 'othree/yajs.vim'
Plugin 'othree/html5.vim'
@rianby64
rianby64 / .bashrc
Created April 3, 2016 16:07
My Bash RC
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
alias nave='~/.nave/nave.sh'
alias nstable='nave use stable'
'use strict';
window.feature = apolog.feature;
window.scenario = apolog.scenario;
window.step = apolog.step;
window.given = apolog.given;
window.when = apolog.when;
window.then = apolog.then;
window.but = apolog.but;
window.and = apolog.and;
@rianby64
rianby64 / .gitconfig
Last active April 3, 2016 16:10
My gitconfig
[user]
name = Andres Rios
email = rianby64@gmail.com
[push]
default = matching
[core]
editor = vim
[color]
ui = true
[alias]