Skip to content

Instantly share code, notes, and snippets.

@m4rcsch
m4rcsch / WARNING.md
Last active April 25, 2021 09:00 — forked from Ambroos/WARNING.md
Remove SentinelOne agent from Mac. Because honestly, it doesn't seem to do anything at all. Run as root, best is to do this from a recovery mode, single user mode with writeable filesystem, ...

USE AT OWN RISK

This was only tested on a partial SentinelOne installation on the High Sierra beta, where SentinelOne was never allowed to enable it's kernel extension.

function gmailAutoarchive() {
var delayDays = 2; // will only impact emails more than 48h old
var maxDate = new Date();
maxDate.setDate(maxDate.getDate()-delayDays); // what was the date at that time?
// Get all the threads labelled 'autoarchive'
var label = GmailApp.getUserLabelByName("autoarchive");
var threads = label.getThreads(0, 400);
@m4rcsch
m4rcsch / .bash_profile
Last active January 16, 2017 07:32 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@m4rcsch
m4rcsch / validatorIsUnique.php
Created March 8, 2012 10:49
isUnique Validator for Lithium (li3) PHP Framework
Validator::add('isUnique', function($data, $params, $options) {
$model = $options['model'];
$field = $options['field'];
$key = $model::meta('key');
$entity = $model::first(array('conditions' => array($field => $data)));
$identifier = isset($options['values'][$key]) ? $options['values'][$key] : null;
if ($entity && $entity->data() && $identifier == (string) $entity->$key) {
@m4rcsch
m4rcsch / custom_save.php
Created December 11, 2011 10:51
custom li3 save with validation
<?php
// ATTENTION: this is pseudocode alike!
// witten inside the gist textbox without php validation!
/**
* This is a models vutsom save method
* The models validation rules should contain at least one 'on' => 'publish' rule!
*
* @param Object $entity
@m4rcsch
m4rcsch / default.html.php
Created November 2, 2011 13:58
boilerplated lithium layot (Boilerplate 2.0)
<?php
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2011, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
?>
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
@m4rcsch
m4rcsch / environment.php
Created November 2, 2011 12:23
Environment detection based on HTTP_HOST
<?php
/**
* @author 2011 weluse GmbH, Marc Schwering
*/
use lithium\core\Environment;
Environment::is(function($request) {
$http_host = $request->env('HTTP_HOST');
@m4rcsch
m4rcsch / debug.php
Created November 2, 2011 11:53
Current Weluse lithium debug
<?php
/**
* General info:
* Embed this code in your lithium (li3) app.
* At the end of the app\config\connections.php for example.
*
* Uncomment the var_dump lines OR use the lithium Logger Class
* Use/modify the first callback, if you just want to see the query array data.
* Use the second callback for dumping the raw sql data.
@m4rcsch
m4rcsch / loggerWriteFilter.php
Created October 19, 2011 09:00
Lithium (li3) Logger Helper for lazy coders..
/**
* Inspect the message, and do a string conversion via print_r
*
* @author: 2011 weluse GmbH, Marc Schwering
*/
Logger::applyFilter('write', function ($self, $params, $chain){
$var = $params['message'];
if(is_array($var) || is_object($var)){
$params['message'] = print_r($var,true);
}
@m4rcsch
m4rcsch / dump_raw_sql.php
Created October 12, 2011 12:44
Simple li3 sql statement exporter using var_dump
/**
* General info:
* Embed this code in your lithium (li3) app.
* At the end of the app\config\connections.php for example.
*
* Uncomment the var_dump lines OR use the lithium Logger Class
* Use/modify the first callback, if you just want to see the query array data.
* Use the second callback for dumping the raw sql data.
*
* @author: 2011 weluse GmbH, Marc Schwering