Skip to content

Instantly share code, notes, and snippets.

View ChristianOellers's full-sized avatar
🇨🇾

Christian Oellers ChristianOellers

🇨🇾
View GitHub Profile
@ChristianOellers
ChristianOellers / PreventCopyPaste-FormFields.js
Created April 26, 2019 12:05
HTML form elements - Prevent copy & paste keyboard events + Custom UI behaviour example
/**
* Prevent use of 'CTRL+v' or 'CTRL+V' in form fields that must not be copied.
* This doesn't prevent browser native auto complete (e.g. double-clicking into a field) or vendor specific mobile device features.
*
* Example use case: Repeating fields for email, or password.
*
* @param {object} event Keydown event.
*/
function preventCopyPaste (event) {
'use strict';
@ChristianOellers
ChristianOellers / Flash-GameEngineHelper.as
Created April 26, 2019 12:06
Flash - Game engine helpers - Calculations + Stage handling
/**
* General game engine helper and basic math functionality.
* Set a stage object reference before using any of the methods.
*/
package com
{
import flash.display.MovieClip;
import flash.display.Stage;
public class $
@ChristianOellers
ChristianOellers / Contao-CMS-GetGlobalsByType.php
Created April 26, 2019 12:09
Contao CMS - Get global variables by type - Prevent memory allocation error - Workaround
<?php
/**
* Return parts of the $GLOBALS array sorted by type.
* It's recommended to not return all at once as this might run out of memory.
*/
foreach (array_keys($GLOBALS) as $key) {
switch (gettype($GLOBALS[$key])) {
case 'array': {
debug(array_keys($GLOBALS[$key]));
@ChristianOellers
ChristianOellers / Contao-CMS-ResetChmod.php
Created April 26, 2019 12:10
Contao CMS - Reset directory CHMOD recursively to defaults
<?php
/**
* Set default CHMOD if you completely messed up a setup.
* By default the Contao CMS setup should reset the CHMOD.
*
* Copy to web root and run from a webbrowser.
*
* @param string $dir Base directory
* @param octal $dirModes Directory CHMOD
* @param octal $fileModes File CHMOD
@ChristianOellers
ChristianOellers / Magento-Ecommerce-CE-ResetChmod.sh
Created April 26, 2019 12:11
Magento E-Commerce CE - Reset directory CHMOD recursively to defaults
#!/bin/sh
# Repair or restore Magento shop CHMOD settings.
# There are some custom files and issue fixes incorporated.
#
# Tested with Magento CE 1.5.1.0 - 1.6.1.0.
# Run this script with 'chmod o+x' applied.
# -------------------------------------------------------------------------------------------------------------- Select folder, Startup info
@ChristianOellers
ChristianOellers / Magento-Ecommerce-CE-Debugging.php
Last active September 29, 2020 19:38
Magento E-Commerce CE - Native debugging options
<?php
/**
* A few different ways to do debugging and logging in Magento.
* The output is spare - specific extensions are recommended.
*/
# -------------------------------------------------------------------------------------------------------------------------------- Debugging
// \app\code\core\Mage\Core\functions.php
mageDebugBacktrace(false, true, true);
@ChristianOellers
ChristianOellers / Magento-Ecommerce-CE-UpdateStoreURLs.sql
Created April 26, 2019 12:14
Magento E-Commerce CE - Store + Cookie URL update script - Helper to synchronise DB environments
-- Fast switch all store URLs and cookie settings.
--
-- Useful to synchronize a live DB to a DEV environment.
-- Make sure to change multi-store URLs manually after applying this script.
--
-- Tested with:
-- Magento CE 1.4 - 1.6
-- ------------------------------------------------------------------------------------------------------------------------------ Store URLs
@ChristianOellers
ChristianOellers / Debug-Backtrace-Helper.php
Created April 26, 2019 12:43
PHP - Debug backtrace helper tool - Specify output details
<?php
/**
* Reformat debug backtrace messages to a more simple and readable format.
* Output only the required information (setup as needed).
*/
class Debug_Backtrace_Helper
{
/**
* Run method on class instance call.
*
@ChristianOellers
ChristianOellers / .bash_aliases
Last active June 11, 2023 15:01
Bash aliases - Git + Docker - Advanced snippets + Concepts
#!/bin/bash
# - Angular
# - Apache
# - Composer
# - Docker
# - Git
# - Keys
# - MySQL
# - PHP
@ChristianOellers
ChristianOellers / Magento-Ecommerce-CE-BashSnippets.sh
Created April 26, 2019 14:38
Magento E-Commerce CE - Bash snippets for searching through folders, file content and logs
------------------------------------------------------------------------------------------------------------------------------------ General
# Recursively search through all folders and file contents.
# Note: It also searches in binary files. Change the command or limit it to code folders.
grep -lir 'example' .
# Limit search to PHP files only.
grep --include '*.php' -lir 'example' .