Skip to content

Instantly share code, notes, and snippets.

View vcwild's full-sized avatar
📖
Learning is an exercise in humility

Victor Wildner vcwild

📖
Learning is an exercise in humility
View GitHub Profile
@vcwild
vcwild / builder.c
Last active August 23, 2023 20:16
The Builder pattern writing UI components in C
#include <stdio.h>
#include <stdlib.h>
typedef enum {
BUTTON,
LABEL,
PANEL
} UIComponentType;
typedef struct {
@vcwild
vcwild / proxy.c
Created August 23, 2023 01:13
C proxy with constructor and destructor
#include <stdio.h>
#include <stdlib.h>
typedef struct {
void (*request)(void *self);
} Subject;
typedef struct {
Subject subject;
} RealSubject;
@vcwild
vcwild / rush.c
Last active August 21, 2023 14:02
#include <limits.h>
#include <unistd.h>
void ft_putchar(char c)
{
write(1, &c, 1);
}
static int raises_error(long int x, long int y)
{
@vcwild
vcwild / coro.py
Created August 17, 2023 23:55
python coro example
from typing import Any, Generator
from iqe_tasks.constants import HostTypes
import asyncio
import concurrent.futures
from iqe_tasks import TasksApp
from fabric import Connection
class EvokeFirstIterationMeta(type):
"""Force evoking the first iteration of a generator object."""
@vcwild
vcwild / app.py
Created April 5, 2022 13:53
Flask + SQLAlchemy + Dataclasses
from dataclasses import dataclass
from datetime import datetime
from flask import Flask, jsonify
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
@vcwild
vcwild / bq_easy.py
Last active March 22, 2021 15:45 — forked from korakot/bq_easy.py
Using bigquery easily in Google Colab. Focus on a single table.
import re
import pandas as pd
from google.cloud import bigquery
from google.colab import auth
PROJECT_ID = 'sql-hunt' # change to your own project
class BqTable:
def __init__(self, table, dataset='samples', active_project='bigquery-public-data', client=None):
@vcwild
vcwild / kaggle.ipynb
Last active October 25, 2023 20:05
Import dataset from Kaggle
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# run 00_data_split
from sklearn.feature_selection import SelectFromModel
from sklearn.linear_model import Lasso
from sklearn.ensemble import RandomForestRegressor
selector_model = Lasso(alpha=1.,normalize=True)
selector = SelectFromModel(selector_model, max_features=5, threshold=-np.inf)
selector.fit(Xtrain, ytrain)
from sklearn.feature_selection import SelectFromModel
from sklearn.metrics import mean_squared_error
from sklearn.linear_model import LinearRegression, Ridge, Lasso
from sklearn.ensemble import RandomForestRegressor
# Feature Selection
k_vs_score=[]
seed = 42
for k in range(2, X_train.shape[1], 2):
@vcwild
vcwild / filter_feature_selection.py
Last active November 22, 2020 23:35
feature selection
from sklearn.feature_selection import SelectKBest, f_regression
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error
k_vs_score = []
initial_features = 2
max_n_features = len(X.columns)
step = 2