Skip to content

Instantly share code, notes, and snippets.

View iglesias's full-sized avatar
😊

Fernando J. Iglesias García iglesias

😊
View GitHub Profile
@iglesias
iglesias / .ycm_extra_conf.py
Last active June 16, 2024 20:30
codeweekend.dev
def Settings( **kwargs ):
return {
'flags': [ '-x', 'c++', '-Wall', '-Wextra', '-Werror', '-std=c++23'],
}
@iglesias
iglesias / state_manager.py
Last active March 31, 2024 06:15
Porting Deep Symbolic Optimization to a Python version > 3.7
from abc import ABC, abstractmethod
import torch
from torch.nn.functional import one_hot
from dso.program import Program
class StateManager(ABC):
"""
@iglesias
iglesias / tdk.cpp
Created February 27, 2024 07:53
Rewiring your brain with test driven thinking in C++ - Phil Nash - Meeting C++ 2023
#include <string>
#include <string_view>
#include <catch2/catch_test_macros.hpp>
std::string left_pad(std::string_view str, std::size_t min_len) {
auto const pad_len = std::max<int>(0, min_len-str.length());
return std::string(pad_len, ' ') + std::string(str);
}
TEST_CASE("left_pad") {
@iglesias
iglesias / unicode.c
Created February 21, 2024 15:54
unicode.c
#include<stdlib.h>
#include<stdio.h>
int
main ()
{
int i;
char *str = getenv ("LANG");
for (i = 0; str[i + 2] != 00; i++)
@iglesias
iglesias / sv.sql
Last active February 20, 2024 11:02
Throwback to year 2012 at university, SQL exercise
/*****************
* INICIALIZATION *
******************/
DROP TABLE IMPARTE;
DROP TABLE CALIFICACION;
DROP TABLE USUARIO;
DROP TABLE ALUMNO;
DROP TABLE ASIGNATURA;
DROP TABLE MASTER;
@iglesias
iglesias / Makefile
Created December 18, 2023 15:05
FTXUI
include = -IFTXUI/include
CXXFLAGS = -Wall -Wextra -pedantic -std=c++20 $(include)
LDFLAGS = -LFTXUI/build
LDLIBS = -lftxui-component -lftxui-dom -lftxui-screen
TARGET = learn_ftxui
all: $(TARGET)
import random
import numpy
import numpy.matlib
N = 10
S = 3
Omega = random.sample(range(N), S)
s = numpy.matlib.randn(S,1)
@iglesias
iglesias / aoc_day15_sensors.cpp
Created December 16, 2022 18:54
Advent of Code 2022 Day 15
#include <bits/stdc++.h>
struct p {int x, y; p(int ax, int ay) : x(ax), y(ay) {} p() : x(0), y(0) {} bool operator!=(const p &o) { return x != o.x || y != o.y; } };
std::vector<std::pair<p, int>> read_input();
int distance(p p1, p p2);
int main()
{
auto sensors_and_distances = read_input();
@iglesias
iglesias / aoc_day13_packets.py
Created December 16, 2022 10:16
Advent of Code 2022 - Day 13
import functools
import sys
def compare(lleft, lright):
print(">> ", end='')
print(lleft)
print(">> ", end='')
print(lright)
lleftc = lleft.copy()
@iglesias
iglesias / gist:7725ae653748e7c6a329247e4f2206a0
Created October 1, 2022 10:07
GSP Demixing - HeatKernel with brains
HeatKernel
>> brain_bss_logdet_S_numGraphs
L2 S1 numGraphs2: success=9.900000e-01 time=4.414525e+01
Uniform
>> brain_bss_logdet_S_numGraphs
L2 S1 numGraphs2: success=7.800000e-01 time=1.089144e+02
L3 S1 numGraphs2: success=9.000000e-01 time=1.573157e+02
L4 S1 numGraphs2: success=9.300000e-01 time=1.831644e+02
L5 S1 numGraphs2: success=8.500000e-01 time=2.888297e+02