Skip to content

Instantly share code, notes, and snippets.

Fernando Basso FernandoBasso

Block or report user

Report or block FernandoBasso

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rodolfobandeira
rodolfobandeira / to_bool.md
Created Apr 7, 2019
Convert string to boolean in Ruby
View to_bool.md
  def to_bool(string)
    if string == true || string == 1 || string =~ (/(true|1)$/i)
      true
    else
      false
    end
  end
@cheungnj
cheungnj / script.sh
Last active Aug 13, 2019
Convert asciidoc to Github Flavored Markdown
View script.sh
# Adapted from https://tinyapps.org/blog/nix/201701240700_convert_asciidoc_to_markdown.html
# Using asciidoctor 1.5.6.1 and pandoc 2.0.0.1
# Install pandoc and asciidoctor
$ sudo apt install asciidoctor
$ sudo wget https://github.com/jgm/pandoc/releases/download/2.0.0.1/pandoc-2.0.0.1-1-amd64.deb
$ sudo dpkg -i pandoc-2.0.0.1-1-amd64.deb
# Convert asciidoc to docbook using asciidoctor
@bisqwit
bisqwit / textbox.hh
Last active Apr 1, 2019
Abstraction for 2-dimensional text strings with VT100 linedrawing support; and a tree structure visualizer function
View textbox.hh
#include <string>
#include <vector>
#include <algorithm>
/* textbox: Abstraction for 2-dimensional text strings, with VT100 linedrawing support */
/* Copyright (c) 2017 Joel Yliluoma - http://iki.fi/bisqwit/ */
/* License: MIT */
/* Requires a C++17 capable compiler and standard library. */
struct textbox
{
View tsfaq.md

Pseudo-Variadic arguments aka How do I change the return type of a function?

Until https://github.com/Microsoft/TypeScript/issues/5453 is implemented, you'll need to create multiple overloads, one for each number of arguments. For example, this is the type definition of a function which takes a function and returns a function with the same arguments but the result wrapped in a Promise.

declare function wrapPromise<R>(f: () => R): () => Promise<R> 
declare function wrapPromise<A1, R>(f: (a1: A1) => R): (a1: A1) => Promise<R>
declare function wrapPromise<A1, A2, R>(f: (a1: A1, a2: A2) => R): (a1: A1, a2: A2) => Promise<R>
declare function wrapPromise<A1, A2, A3, R>(f: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => Promise<R>
declare function wrapPromise<A1, A2, A3, A4, R>(f: (a1: A1, a2: A2, a3: A3, a4: A4) => R): (a1: A1, a2: A2, a3: A3, a4: A4) => Promise<R>
// etc. 8 arguments should be enough for everyone :-P
@joyrexus
joyrexus / README.md
Last active Aug 15, 2019
collapsible markdown
View README.md

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
View formiga.md

A Parábola da demissão da formiga desmotivada

"Todos os dias, uma formiga chegava cedinho ao escritório e pegava duro no trabalho. A formiga era produtiva e feliz.

O gerente marimbondo estranhou a formiga trabalhar sem supervisão. Se ela era produtiva sem supervisão, seria ainda mais se fosse supervisionada. E colocou uma barata, que preparava belíssimos relatórios e tinha muita experiência, como supervisora.

A primeira preocupação da barata foi a de padronizar o horário de entrada e saída da formiga. Logo, a barata precisou de uma secretária para ajudar a preparar os relatórios e contratou também uma aranha para organizar os arquivos e controlar as ligações telefônicas.

O marimbondo ficou encantado com os relatórios da barata e pediu também gráficos com indicadores e análise das tendências que eram mostradas em reuniões. A barata, então, contratou uma mosca, e comprou um computador com impressora colorida. Logo, a formiga produtiva e feliz, começou a se lamentar de toda aquela movimentação de papéis e re

@k-takata
k-takata / bash-completion-slowness-on-msys2.md
Created May 13, 2015
Bash-completion is very slow on MSYS2
View bash-completion-slowness-on-msys2.md

Bash-completion is very slow on MSYS2

Bash-completion is very slow on MSYS2 when the current user is a domain user. This describes the cause and the solutions.

Cause

Expansion of ~* is very slow when you use a domain user. For example:

@lolzballs
lolzballs / HelloWorld.java
Created Mar 22, 2015
Hello World Enterprise Edition
View HelloWorld.java
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@rain1024
rain1024 / tut.md
Last active Aug 15, 2019
Install pdflatex ubuntu
View tut.md

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
@eltonmesquita
eltonmesquita / onViewport.js
Last active May 4, 2019
A simple jQuery function that adds a class when the target(s) is in the viewport
View onViewport.js
function onViewport(el, elClass, offset, callback) {
/*** Based on http://ejohn.org/blog/learning-from-twitter/ ***/
var didScroll = false;
var this_top;
var height;
var top;
if(!offset) { var offset = 0; }
$(window).scroll(function() {
You can’t perform that action at this time.