Skip to content

Instantly share code, notes, and snippets.

@Veve2
Veve2 / Git push deployment in 7 easy steps.md
Created August 4, 2017 09:34 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@Veve2
Veve2 / exception_error_handler.php
Created June 14, 2017 14:41
Error to Exception error_handler for PHP
<?php
function exception_error_handler($severity, $message, $file, $line) {
if (!(error_reporting() & $severity)) {
// This error code is not included in error_reporting
return;
}
throw new ErrorException($message, 0, $severity, $file, $line);
}
set_error_handler("exception_error_handler");
@Veve2
Veve2 / tablesize.sql
Created June 14, 2017 08:53
Find MySQL table size
SELECT
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = "database"
AND table_name = "cache_form";
@Veve2
Veve2 / $realfile.php
Created June 1, 2017 13:07
Real __FILE__
<?php
$stack = debug_backtrace();
$firstFrame = $stack[count($stack) - 1];
$initialFile = $firstFrame['file'];
@Veve2
Veve2 / font-stack.css
Created May 3, 2017 14:29
Font stack moderne
body{
font: 16px/1.2 BlinkMacSystemFont, -apple-system, “Segoe UI”, Roboto, Helvetica, Arial, sans-serif;
}
@Veve2
Veve2 / detect-private-browsing.js
Created February 22, 2017 15:06 — forked from cou929/detect-private-browsing.js
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@Veve2
Veve2 / ExtraProcessor.php
Created January 9, 2017 13:30
Including extra debugging Information in Symfony error log
<?php
namespace AppBundle\Monolog;
use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @DI\Service("app.monolog.extra_processor")
* @DI\Tag("monolog.processor")
*/
@Veve2
Veve2 / fastload.sql
Last active October 24, 2022 09:36
Fast LOAD DATA INFILE with MySQL
SET FOREIGN_KEY_CHECKS = 0;
SET UNIQUE_CHECKS = 0;
SET SESSION tx_isolation='READ-UNCOMMITTED';
SET sql_log_bin = 0;
#LOAD DATA LOCAL INFILE....
SET UNIQUE_CHECKS = 1;
SET FOREIGN_KEY_CHECKS = 1;
SET SESSION tx_isolation='READ-REPEATABLE';
@Veve2
Veve2 / Controller.php
Last active November 22, 2016 13:13
Symfony - AJAX delete action
<?php
/**
* @Route("category/delete/{id}", name="category_delete")
* @Method({"GET", "DELETE"})
*/
public function deleteAction(Request $request, $id)
{
/*
* Check Permission.
*/
@Veve2
Veve2 / style.css
Created October 19, 2016 07:42
Font stack from Worpress
body {
font-family: -apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen-Sans,
Ubuntu,
Cantarell,
"Helvetica Neue",
sans-serif;