Skip to content

Instantly share code, notes, and snippets.

@micperr
micperr / phpstorm-auto-semicolon-macro.txt
Created July 12, 2018 19:14 — forked from umidjons/phpstorm-auto-semicolon-macro.txt
PhpStorm: Record Auto semicolon macro and bind shortcut to it
Record Auto semicolon macro and bind shortcut to it:
1. Edit -> Macros -> Start Macro Recording
2. In the editor go to the end of line by pressing End
3. put semicolon ';'
4. Edit -> Macros -> Stop Macro Recording
5. Give a name, for example 'Auto semicolon'
6. Open settings (Ctrl + Alt + s), select Keymap
7. Expand Macros node
8. Select 'Auto semicolon', in the context menu choose Add Keyboard Shortcut
9. Set Ctrl + ; as First keystroke
@micperr
micperr / class-to-array.php
Created March 15, 2018 23:43
Class properties to array dynamically
public function toArray()
{
$reflectionClass = new \ReflectionClass(get_class($this));
$array = [];
foreach ($reflectionClass->getProperties() as $property) {
$property->setAccessible(true);
$array[$property->getName()] = $property->getValue($this);
$property->setAccessible(false);
}
@micperr
micperr / airports.json
Created March 12, 2018 17:20 — forked from tdreyno/airports.json
JSON data for airports and their locations
This file has been truncated, but you can view the full file.
[
{
"code": "AAA",
"lat": "-17.3595",
"lon": "-145.494",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotu-Gambier",
"country": "French Polynesia",
@micperr
micperr / helpers.php
Last active September 19, 2019 06:42
PHP
function generateToken()
{
return bin2hex(openssl_random_pseudo_bytes(16));
}
function getUrl()
{
$url = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] : 'https://'.$_SERVER["SERVER_NAME"];
$url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
$url .= $_SERVER["REQUEST_URI"];