Tuesday, June 1, 2021

organize photo by date taken

 Here is a powershell script I am using, it is based on an exisitng scripts with some modification.

the original script snippet is shown below.




$src= 'D:\My Pictures'

$CharWhiteList = '[^: \w\/]'

$Shell = New-Object -ComObject shell.application

$i = 1

Get-ChildItem $src*.jpg -Recurse  | ForEach{

    $dir = $Shell.Namespace($_.DirectoryName)

    $taken = ($dir.GetDetailsOf($dir.ParseName($_.Name),12) -replace $CharWhiteList)

    #echo $taken

    if (!($taken -eq "") -and !($take -eq " "))

    {

        $datetaken = [DateTime]::ParseExact($taken,"d/MM/yyyy h:mm tt",$null)

        $path = $datetaken | Get-Date -f "yyyy-MM"

        $path = "$($src)\$($path)"


        If(!(test-path $path))

        {

             New-Item -ItemType Directory -Force -Path $path

        }

        $dest = "$($path)\$($_.Name)"

        if (!(Test-Path $dest -PathType leaf))

        {

            Move-Item -Path $_.FullName -Destination $path

        }

    }


}

Friday, May 7, 2021

What is a Lakehouse?

 

Databricks vs Synapse




https://databricks.com/blog/2020/01/30/what-is-a-data-lakehouse.html 

Monday, March 9, 2020

A useful DAX formula for calculating new work won from project variation

Below calculate newly won project work sourced from project variation, it checks a few 

things:

1. restrict the calculations to projects exists from previous month;
2. the formula can also calculate accumulated nww spanned multipel month


NWW Var :=
SUMX (
    VALUES ( DIM_Time[Calendar Month] ),
    SUMX (
        VALUES ( fact_result[project_code] ),
        IF (
            CALCULATE ( COUNTROWS ( fact_result ) ) > 0
                && CALCULATE (
                    COUNTROWS ( fact_result ),
                    PARALLELPERIOD ( DIM_Time[Date], -1, MONTH )
                ) > 0,
            CALCULATE ( SUM ( fact_result[EAC_Fees] ) )
                - CALCULATE (
                    SUM ( fact_result[EAC_Fees] ),
                    PARALLELPERIOD ( DIM_Time[Date], -1, MONTH )
                ),
            0
        )
    )
)

similary you can also derive the formula for calcualting new work won from new projects...

Wednesday, March 4, 2020

No module named PIL - when running tensorflow with databrick

Google didnt' tell me the answer directly... I have to install pillow onto the cluster and then the problem goes away.......

Tuesday, October 8, 2019

Clustered Stacked bar chart with line in secondary axis in Power BI

it looks like there is no native support for this kind of complex chart, initially I tried ggplot2 in R visual however I couldnt' get the ideal solution. finally it appears that this can be done much easier using python pandas + matplotlib.

sample code as below:

df = pd.DataFrame(dict(Subsidy=[3, 3, 3],
                       Bonus=[1, 1, 1],
                       Expense=[2, 2, 2],
                       Salary=[1, 2, 1],
                       Margin=[0.3,0.4,0.5]),
                  list('ABC'))

ax = df[['Subsidy', 'Bonus']].plot.bar(stacked=True, position=1,
                            width=.2, ylim=[0, 8], color=['orange', 'red'])
df['Margin'].plot(secondary_y=True, color='k', marker='o')
df[['Expense', 'Salary']].plot.bar(ax=ax,stacked=True, position=0,
                            width=.2, ylim=[0, 8], color=['blue', 'green'])



Disable Microsoft Defender for Cloud for Visual Studio Subscription (MSDN)

I use a visual studio pro subscription which comes with $150 azure cloud credit, for some reason Microsoft Defender for Cloud was turned on ...