Skip to content

Instantly share code, notes, and snippets.

View carlosefr's full-sized avatar

Carlos Rodrigues carlosefr

View GitHub Profile
@carlosefr
carlosefr / fire.pov
Created June 11, 2024 13:21
POV-Ray scene from 1997 featuring fire effects
// File: fire.pov
// Vers: 3
// Desc: Burning cylinder with a sphere on top and toruses around
// Date: 11-05-97
// Auth: Carlos Rodrigues
#include "colors.inc"
#include "textures.inc"
#include "shapes.inc"
#include "user.inc"
@carlosefr
carlosefr / EMFDetector.ino
Last active February 17, 2023 00:36
Simple electromagnetic field detector with an Arduino
/*
* Pin A0 -> 2MΩ resistor -> GND
* Pin A0 -> antenna (a piece of wire a few centimeters long)
*
* Pin 11 -> LED -> 330KΩ resistor -> GND
*/
static const char sensorPin = 0;
static const char ledPin = 11;
@carlosefr
carlosefr / yape2.pde
Created April 15, 2022 15:54
Yet Another Plasma Effect v2.0 - 10 years later (2008)
/*
* Yet Another Plasma Effect v2.0 - 10 years later...
*
* Copyright (c) 2008 Carlos Rodrigues <cefrodrigues@gmail.com>
*
* 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
@carlosefr
carlosefr / report-despiralize.py
Last active March 23, 2020 11:11
2020-4-fragmented-ce46c1c5 (brainfuck step)
#!/usr/bin/env python3
grid = []
with open("report.txt", "r") as f:
for line in f:
grid.append([c for c in line.strip("\n")])
size = len(grid)
f=(a,g,e,b,d=(a,c)=>a>--c?c:0<a&&0|a)=>e.map((l,c)=>b.map((b,h)=>b.map((b,k)=>s+=e[d(h-1+c/3/a,g)*a*3+3*d(k-1+c/3%a,a,z+=b)+c%3]*b),s=z=0)|d(z?s/z:s,256))
@carlosefr
carlosefr / jcazevedo-start-2017.js
Last active March 25, 2019 19:59
First correct answer to the "No Wires" challenge
function f(a){a=a.split("\n");for(var g=a.length,e=a[0].length,l=[[-1,-1],[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1]],b="",d=0;d<g;d++){for(var h=0;h<e;h++){var c=a[d].length<e?" ":a[d][h];if(" "==c)b+=" ";else if("H"==c)b+="t";else if("t"==c)b+=".";else if("."==c){for(var k=c=0;8>k;k++){var m=(d+g+l[k][0])%g;"H"==(a[m].length<e?" ":a[m][(h+e+l[k][1])%e])&&c++}b=1<=c&&2>=c?b+"H":b+"."}}d+1<g&&(b+="\n")}return b};
@carlosefr
carlosefr / jcazevedo-finish-2017.js
Last active March 25, 2019 19:59
Winning answer to the "No Wires" challenge
f=(b,c=j=(l=b.replace(/\n/g,r='')).length)=>[...b].map(d=>{for(a=t=9;a;)t-='H'!=l[(0|j-1+(--a%3-1)*b.search`
`+a/3)%c];j+=`
`!=d,r+={H:'t',t:'.','.':t&&3>t&&'H'}[d]||d})&&r
@carlosefr
carlosefr / RPi2c.ino
Last active December 4, 2020 18:18
Raspberry Pi to Arduino communication using I2C and interrupts.
/*
* RPi2c - test i2c communication between an Arduino and a Raspberry Pi.
*
* Copyright (c) 2013 Carlos Rodrigues <cefrodrigues@gmail.com>
*
* 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