Skip to content

Instantly share code, notes, and snippets.

View Blackbam's full-sized avatar

David Stöckl Blackbam

View GitHub Profile
@faiyazalam
faiyazalam / raw-sql-query-pimcore-db
Created May 21, 2018 13:58
Raw sql query using Pimcore\Db class in PIMCORE 5
use Pimcore\Db;
$sql = "SELECT * from table_name where`id` = ?";
$stmt = Db::get()->prepare($sql);
$stmt->bindParam(1, 101, \PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetchAll();
@dave-kennedy
dave-kennedy / demo.html
Last active February 20, 2024 17:43
Flyout menus for Bootstrap 4
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Bootstrap flyout demo</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="flyout.css" rel="stylesheet">
</head>
<body>
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@mattclements
mattclements / function.php
Last active October 29, 2024 22:04
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@litzinger
litzinger / create-magento-user.php
Created June 4, 2015 16:57
Create a Magento user via PHP script to get into admin area.
<?php
define( 'USERNAME', 'new.user' );
define( 'PASSWORD', 'password' );
define( 'FIRSTNAME', 'Excited' );
define( 'LASTNAME', 'Croc' );
define( 'EMAIL', '[email protected]' );
include_once( 'app/Mage.php' );
Mage::app( 'admin' );
try {
@xeoncross
xeoncross / objectDump.php
Created October 3, 2014 16:16
Simple PHP object dump for those large objects with huge blobs of text or deep nested structures
<?php
/**
* Simple object dump for those large objects with huge blobs of text or deep nested structures
*/
function objectDump($object, $size = 70, $max = 5, $level = 0)
{
if($level > $max) return 'array(...MAX DEPTH REACHED...)';
$tab = str_repeat("\t", $level);
@henriquemoody
henriquemoody / http-status-codes.php
Last active July 30, 2024 10:29
List of HTTP status codes in PHP
<?php
/**
* Content from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
*
* You may also want a list of unofficial codes:
*
* 103 => 'Checkpoint',
* 218 => 'This is fine', // Apache Web Server
* 419 => 'Page Expired', // Laravel Framework
@maniaks
maniaks / add_setting_cpt.php
Created September 10, 2013 07:33
WordPress: Add Settings page to custom post type
<?php
//Example from Codex page : http://codex.wordpress.org/Function_Reference/add_submenu_page
//Add this in your functions.php file, or use it in your plugin
add_action('admin_menu', 'register_my_custom_submenu_page');
function register_my_custom_submenu_page() {
add_submenu_page( 'edit.php?post_type=book', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' );
}
@elidickinson
elidickinson / max_width_email.html
Created May 6, 2013 15:10
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
@mathewbyrne
mathewbyrne / CsvResponse.php
Created March 21, 2013 22:54
A small Symfony 2 class for returning a response as a CSV file. Based on the Symfony JsonResponse class.
<?php
namespace Jb\AdminBundle\Http;
use Symfony\Component\HttpFoundation\Response;
class CsvResponse extends Response
{
protected $data;