Skip to content

Instantly share code, notes, and snippets.

View cauefcr's full-sized avatar

Cauê Felchar cauefcr

View GitHub Profile
@cauefcr
cauefcr / church_numerals.js
Created December 2, 2021 02:30
Church numerals
const R = require("ramda");
//church encoding
let _0 = fn => x => x;
let _1 = fn => x => fn(x);
let _2 = fn => x => fn(fn(x));
let _3 = fn => x => R.pipe(...R.repeat(fn,3))(x);
let _256 = [_0,_1,_2,_3,...R.range(4,256).map(z => fn => x => R.pipe(...R.repeat(fn,z))(x))];
//R.range(0,256).map(x => {
@cauefcr
cauefcr / reverse_proxy.go
Created July 26, 2021 23:32
reverse proxy i use at my raspberry pi
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
)
func makeHandler(hostTarget map[string]string) func(w http.ResponseWriter, r *http.Request) {
@cauefcr
cauefcr / index.js
Created May 16, 2021 13:35
run-time function generation in javascript, for macros
"use strict";
const beautify = require('js-beautify').js;
var toSource = require("tosource-polyfill");
// function builder, that does arbitrary out of order functionally composable api for metaprogramming
const optsJSbeautify = {
"indent_size": 4,
"indent_char": " ",
"indent_with_tabs": false,
"editorconfig": false,
"eol": "\n",
package main
import (
"fmt"
)
type CondTU []struct {
Comp func(string) bool
Ap func(string) int
}
import telebot
import requests
bot = telebot.TeleBot("telegram_bot_token_here")
@bot.message_handler(func=lambda message: True)
def echo_all(message):
response = requests.get(f"https://s.dicio.com.br/{message.text}.jpg")
bot.send_photo(message.chat.id,response.content)
@cauefcr
cauefcr / restify.js
Created December 5, 2020 21:11
restification
"use strict";
const pretty = require('js-object-pretty-print').pretty;
// Object.prototype.toString = function() { return pretty(this); };
const esprima = require('esprima');
const fs = require("fs");
const toSource = require("tosource");
const olhada = (coisa) => {
console.log(pretty(coisa));
return coisa;
@cauefcr
cauefcr / quine.js
Created December 4, 2020 17:08
javascript quine
const main = () => {
var toSource = require("tosource-polyfill");
console.log(toSource(main)+";\nmain();");
};
main();

Keybase proof

I hereby claim:

  • I am cauefcr on github.
  • I am cauefcr (https://keybase.io/cauefcr) on keybase.
  • I have a public key ASBqn10WBtpgxfG6RQSYPk9g6VhLCVCDzXpgBhrZ7VNGjwo

To claim this, I am signing this object:

package main
import "net/http"
import "os"
func main() {
fs := http.FileServer(http.Dir(os.Args[1]))
http.Handle("/", http.StripPrefix("/", fs))
http.ListenAndServe(":"+os.Args[2], nil)
@cauefcr
cauefcr / webpaper.go
Last active July 29, 2019 22:07
sets the input url as wallpaper every x seconds
package main
import (
"fmt"
"image"
"log"
"os"
"path/filepath"
"strconv"
"strings"