Skip to content

Instantly share code, notes, and snippets.

@rolandinsh
rolandinsh / gist:3259435
Created August 4, 2012 19:14
calculate date from day of year in php
<?php $todayid = date("z"); // to get today's day of year
function dayofyear2date( $tDay, $tFormat = 'd-m-Y' ) {
$day = intval( $tDay );
$day = ( $day == 0 ) ? $day : $day - 1;
$offset = intval( intval( $tDay ) * 86400 );
$str = date( $tFormat, strtotime( 'Jan 1, ' . date( 'Y' ) ) + $offset );
return( $str );
}
@iandundas
iandundas / new_gist_file
Created May 20, 2013 04:39
PHP: Relay POST and GET requests to a new URL, and output the result
<?php
// was used when API address moved but apps were live on app store.
$ch = curl_init();
$path = $_SERVER['REQUEST_URI'];
$path = str_replace('/api/index.php','',$path);
$path = str_replace('/api/','/',$path);
@tascrafts
tascrafts / simple_sma.php
Created May 24, 2018 14:55
Simple Moving Average function for PHP
<?php
// Example
$sma_array = simple_sma(array(3,10,11,19,18,12,6,5,9,0), 5);
print_r($sma_array); // Outputs 8, 13.3333, 16, 16.3333, 12, 7.6667, 6.6667, 4.6667
function simple_sma($array, $days) {
if($days < 0) die("Days have to be higher than 0 in the simple_sma function.");
$array = array_values($array);
@tascrafts
tascrafts / Show Wi-Fi Passwords.ps
Last active August 20, 2024 12:14
Lists all saved wi-fi networks and passwords on Windows 10
(netsh wlan show profiles) | Select-String “\:(.+)$” | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name=”$name” key=clear)} | Select-String “Key Content\W+\:(.+)$” | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize
pause
@tascrafts
tascrafts / certificate_checker.php
Created May 17, 2023 11:07
A PHP script to check and display SSL certificate expiration in Google and .ical calendars
<?php
$urls[] = array(
"name" => "Domain 1 Name",
"url" => "https://domain.com"
);
$urls[] = array(
"name" => "Domain 2 Name",
"url" => "https://subdomain.domain.org"