Skip to content

Instantly share code, notes, and snippets.

import pandas as pd
import numpy as np
def get_dataset(size):
# Create Fake Dataset
df = pd.DataFrame()
df['size'] = np.random.choice(['big','medium','small'], size)
df['age'] = np.random.randint(1, 50, size)
df['team'] = np.random.choice(['red','blue','yellow','green'], size)
df['win'] = np.random.choice(['yes','no'], size)
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution
Last active December 3, 2024 05:15
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@Dreyer
Dreyer / database_fragmentation.sql
Created July 3, 2017 17:59
Display database fragmentation for each table.
-- USE AdventureWorks;
SELECT
s.name AS 'sys_schema',
t.name AS 'sys_table',
i.name AS 'sys_index',
x.alloc_unit_type_desc,
x.avg_fragmentation_in_percent,
x.page_count
FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL, NULL, NULL) x
INNER JOIN sys.tables t ON t.object_id = x.object_id
#!/bin/sh
PRINT=true
LOGGER=false
warning_days=30
certs_to_check='example.com:443
mail.example.com:25
wiki.example.org:443
'
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@Dreyer
Dreyer / ssl.sh
Created January 23, 2015 16:40
Shell script to make using OpenSSL a little easier.
#!/bin/bash
##
# General OpenSSL Commands
#
# These commands allow you to generate CSRs, Certificates,
# Private Keys and do other miscellaneous tasks.
##
DOMAIN_NAME=$1
@xdamman
xdamman / install_ffmpeg_ubuntu.sh
Created July 2, 2014 21:03
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
/* USAGE
var graph = new Graph(paper.get(0), 800, 500);
graph.max(maxx, maxy)
.min(minx, miny)
.ticks(4, function(x, y){
var attrs = {stroke: "#ffffff", 'stroke-width': '1'};
graph.hor(y, attrs)
.ver(x, attrs);