Skip to content

Instantly share code, notes, and snippets.

View peterdalle's full-sized avatar

Peter M. Dahlgren peterdalle

View GitHub Profile
@peterdalle
peterdalle / convertduration.vb
Created April 4, 2015 14:35
Convert ISO 8601 duration in the format PT::M::S to seconds
''' https://developers.google.com/resources/api-libraries/documentation/youtube/v3/csharp/latest/classGoogle_1_1Apis_1_1YouTube_1_1v3_1_1Data_1_1VideoContentDetails.html#a0527b84283db20cf2ef8f3de22f65606
Dim ts As TimeSpan = System.Xml.XmlConvert.ToTimeSpan(vid.ContentDetails.Duration)
Me.Length = ts.TotalSeconds()
@peterdalle
peterdalle / convertip.sql
Last active July 15, 2018 18:11
Convert IP number to IP address in MySQL
# http://lite.ip2location.com/
# http://stackoverflow.com/questions/3650006/get-country-of-ip-address-with-php
# IP Number = 16777216*w + 65536*x + 256*y + z
# where IP Address = w.x.y.z
#
# To reverse IP number to IP address,
# w = int ( IP Number / 16777216 ) % 256
# x = int ( IP Number / 65536 ) % 256
# y = int ( IP Number / 256 ) % 256