Skip to content

Instantly share code, notes, and snippets.

@joaopcnogueira
joaopcnogueira / backward_elimination.py
Last active December 18, 2023 14:58
Feature selection by Backward Elimination using p-value
import numpy as np
import statsmodels.formula.api as sm
def backward_elimination(X, y, sl):
"""
X: the data matrix with the independent variables (predictors)
y: the matrix of the dependent variable (target)
sl: statistical level, by default the user should add 0.05 (5%)
"""
X = np.append(arr=np.ones((len(X),1)).astype(int), values=X, axis=1)
while(True):
@lefred
lefred / check_async_mysql.sh
Last active February 19, 2023 11:24
Consul Asynchronous Slave Check
# script used in consul to check if mysql is primary master and asynchronous slave
# v.0.1 - lefred 2018-02-16
SLAVEOFDC="dc2"
SLAVEUSER="async_repl"
SLAVEPWD="asyncpwd"
# check if we are the primary one
ROLE=$(mysql -h 127.0.0.1 -BNe "select MEMBER_ROLE from performance_schema.replication_group_members where MEMBER_HOST=@@hostname")
@manusa
manusa / CustomJpaConfiguration.java
Created December 8, 2015 18:07
Configuration file for Spring-Boot which enables EclipseLink as the default JPA provider and uses Tomcat's DataSourceFactory to create a connection pooled DataSource.
import com.marcnuri.transporte.rest.service.CriteriaJpaRepositoryFactoryBean;
import org.eclipse.persistence.config.BatchWriting;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.logging.SessionLog;
import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
@staltz
staltz / introrx.md
Last active June 6, 2025 03:30
The introduction to Reactive Programming you've been missing
@maxim
maxim / rails_load_path_tips.md
Last active January 9, 2025 00:59
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

require 'eventmachine'
require 'socket'
require 'kgio'
server = Kgio::TCPServer.new('0.0.0.0', 4242)
module Dispatch
def notify_readable
io = @io.kgio_tryaccept or return
EventMachine.attach(io, Server)