Skip to content

Instantly share code, notes, and snippets.

@artturik
artturik / Security.php
Last active September 23, 2018 18:45 — forked from iangcarroll/Security.php
Expose (a PHPIDS fork) middleware for Laravel. Assumes it's already included via composer.
<?php
namespace App\Http\Middleware;
use Closure;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Log;
class Security {
@artturik
artturik / DumpObject.php
Created August 30, 2016 13:14
Dump object to array; convert all object accessible and non-accessible variables to array (public, protected, private, static properties and constants)
<?php
/*
Returns array with object properties, static properties and constants
Can be used for:
* Object to array conversion
* Get all properties (protected and private) list outside the class
* Get protected property value outside the class
* Get private property value outside the class
@artturik
artturik / translate.html
Created April 4, 2016 09:09
Forced Google Translate (also can be used as April Fools Day joke)
<!--
This code will translate page contents automatically (without user input)
Settings located at line 9, current script will translate english to estonian
-->
<style>#google_translate_element,.skiptranslate{display:none;}body{top:0!important;}</style>
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'et', autoDisplay: false}, 'google_translate_element');
var a = document.querySelector("#google_translate_element select");
@artturik
artturik / gist:a15d890dcfedfe8af813
Last active August 14, 2022 13:38
Convert PhantomJs cookies to NetScape HTTP cookie file format
// Convert PhantomJs cookies to NetScape HTTP cookie file format
// NOTE: It dose not create NetScape HTTP cookie file, this function return only cookie file contents
// NOTE: PhantomJs do not store "host only" cookie param, all cookies will have "host only" param set to false (line 15)
// I use this function to export PhantomJs cookies to CURL cookiejar file
// This is modified version of EditThisCookie cookie_helpers.js cookiesToString function
// USAGE: phantomJsCookiesToNetScapeString(phantom.cookies);
var phantomJsCookiesToNetScapeString = function(cookies) {
var string = "";
string += "# Netscape HTTP Cookie File\n";