Skip to content

Instantly share code, notes, and snippets.

View elmys's full-sized avatar

elmys elmys

  • Moscow
View GitHub Profile
@caseydunham
caseydunham / ad_unix_conversion_test.php
Created June 30, 2015 18:53
Convert Active Directory TimeStamps to and from Unix Timestamps
// based on http://stackoverflow.com/questions/15770879/unix-timestamp-to-ldap-timestamp
<?php
date_default_timezone_set('America/New_York');
// Microsoft TIMESTAMP epoch is Jan 1, 1601 http://www.selfadsi.org/deep-inside/microsoft-integer8-attributes.htm
// More Info:
// http://blogs.technet.com/b/askds/archive/2009/04/15/the-lastlogontimestamp-attribute-what-it-was-designed-for-and-how-it-works.aspx
function ldapTimeToUnixTime($ldapTime) {
$secsAfterADEpoch = $ldapTime / 10000000;
$ADToUnixConverter = ((1970 - 1601) * 365 - 3 + round((1970 - 1601) / 4)) * 86400;
@m8rge
m8rge / CantSave.php
Last active May 19, 2018 18:13
Yii2 exception for non-saved active records
<?php
namespace common\exception;
use e96\sentry\ErrorHandler;
use yii\base\Exception;
use yii\db\ActiveRecord;
class CantSave extends Exception
@mcandre
mcandre / public-trackers.md
Last active February 11, 2024 09:18
List of public BitTorrent tracker announce URLs