Skip to content

Instantly share code, notes, and snippets.

@espio999
espio999 / sudoku1.py
Created September 11, 2021 23:59
42 SILICON VALLEY Piscine 2017 Rush01 - sudoku1
def make_puzzle(args):
puzzle = []
row = []
i = 0
for c in args:
row.append(c)
if (i + 1) % 9 == 0:
puzzle.append(row)
@espio999
espio999 / sudoku2.py
Created September 12, 2021 00:03
42 SILICON VALLEY Piscine 2017 Rush01 - sudoku2
# coding: utf-8
# Your code here!
def make_puzzle(args):
puzzle = []
row = []
i = 0
for c in args:
row.append(c)
@espio999
espio999 / evalexpr.py
Created September 12, 2021 00:12
42 SILICON VALLEY Piscine 2017 - evalexpr
def is_number(val):
if val >= '0' and val <= '9':
return True
else:
return False
def my_atoi(val):
global p
local_p = 0
ret = 0
@espio999
espio999 / MountISO_ChangeDrv-Bad.ps1
Last active September 12, 2021 01:17
Mount ISO and change its drive letter with PowerShell - bad pattern
$myISO = 'E:\ISO\Microsoft Bookshelf Basic\BSBASIC2.ISO'
Mount-DiskImage $myISO
Get-DiskImage $myISO | Get-Volume
Get-DiskImage $myISO | Get-Volume | Get-Partition
@espio999
espio999 / MountISO_ChangeDrv-Good.ps1
Last active May 2, 2023 04:52
Mount ISO and change its drive letter with PowerShell - good pattern
$myISO = 'E:\ISO\Microsoft Bookshelf Basic\BSBASIC2.ISO'
Mount-DiskImage $myISO
$vol = Get-DiskImage $myISO | Get-Volume
$old_drv = $vol.DriveLetter + ':'
$new_drv = 'X:'
#WMI
#Get-WmiObject -Class Win32_Volume | Where-Object {$_.DriveLetter -eq $old_drv} | Set-WmiInstance -Arguments @{DriveLetter=$new_drv}
@espio999
espio999 / ConvertToAAC-LC.ps1
Created September 12, 2021 01:18
Convert to AAC-LC with qaac
$s_folder = "D:\temp\2020\20201204\source"
$d_folder = "D:\temp\2020\20201204\destination"
$bps = 48
$csv = import-csv -path .\test.csv
foreach ($myline in $csv){
$s_path = $s_folder + '\' + $myline.source
$d_path = $d_folder + '\' + $myline.destination
.\qaac64.exe $s_path -o $d_path -v $bps -r $myline.sampling --artist $myline.artist --album $myline.album --genre $myline.genre
@espio999
espio999 / clustering.r
Last active September 12, 2021 01:28
Clustering - identify number of clusters, analysis, and plot
library(NbClust)
library(factoextra)
library(Rmisc)
mydata = scale(LifeCycleSavings)
myAHCnum = NbClust(mydata, method = "ward.D", index = "all")
myNHCnum = NbClust(mydata, method = "kmeans", index = "alllong")
fig1 = fviz_nbclust(myAHCnum, method = "silhouette")
fig2 = fviz_nbclust(myNHCnum, method = "gap_stat", nboot = 100)
@espio999
espio999 / PCA.r
Created September 12, 2021 01:32
PCA (Principal Component Analysis) - plot, analysis, and prediction
library(FactoMineR)
library(factoextra)
library(corrplot)
mydata = LifeCycleSavings
mypca = PCA(mydata, scale.unit = TRUE, graph = FALSE)
mypca$eig
fviz_pca_var(mypca, col.var = "cos2", gradient.cols = c("blue", "red"), repel = TRUE)
@espio999
espio999 / dev-zero.ps1
Created November 7, 2021 13:24
/dev/zero with PowerShell
$size = 1024 * 128
$data = New-Object byte[] $size
Set-Content -Value $data -Encoding byte my_binary.dat
@espio999
espio999 / dev-random.ps1
Last active November 10, 2021 01:51
/dev/random with PowerShell
$size = 128 - 1
[byte[]] $data = 0..$size | %{Get-Random -Maximum $size}
Set-Content -Value $data -Encoding byte my_binary.dat