Skip to content

Instantly share code, notes, and snippets.

@loburets
loburets / removePhpStorm.sh
Last active August 28, 2017 05:06
remove phpsotrm from osx mac
show folders:
ls ~/Library/Preferences/jetbrains.*
ls ~/Library/Preferences/PhpStorm*
ls ~/Library/Caches/PhpStorm*
ls ~/Library/Application\ Support/PhpStorm*
ls ~/Library/Logs/PhpStorm*
remove folders:
@loburets
loburets / console.log.js
Last active September 7, 2016 04:38
console.log with current statement (different ways)
console.log(JSON.parse(JSON.stringify(ojbect)));
//or
console.log(array.slice());
//or
console.group('group');
array.forEach(function(item) {
@loburets
loburets / MacMediaButtons.ahk
Created June 11, 2017 18:09
AutoHotkey script for using Mac media buttons on Windows PC with F buttons simultaneously
UseMediaButtons := true
;;;Disable using by F14 button;;;
F14::
UseMediaButtons := !UseMediaButtons
; MsgBox %UseMediaButtons%
if (!UseMediaButtons) {
Hotkey, F7, off
@loburets
loburets / mailgun.php
Last active July 6, 2017 05:32
Pagination for Mailgun events API
<?php
use Mailgun\Mailgun;
use Setting;
/**
* Pagination for Mailgun events API
* Retrieves all new (not have retrieved yet) events for each run
* See main code at processNewEvents()
*
@loburets
loburets / video.blade.php
Last active July 26, 2017 13:01
Embed video from youtube via link parsing
@if(preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $link, $match))
<iframe type="text/html"
src="https://www.youtube.com/embed/{!! $match[1] !!}?rel=0&showinfo=0&color=white&iv_load_policy=3"
frameborder="0" allowfullscreen></iframe>
@elseif (!empty($link))
<a href="{!! $link !!}">Video</a>
@endif
@loburets
loburets / mode.sql
Last active January 20, 2024 13:52
In aggregated query without GROUP BY, expression contains nonaggregated; this is incompatible with sql_mode=only_full_group_by
SET GLOBAL sql_mode = (SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
SELECT @@sql_mode;
@loburets
loburets / chunk.php
Created September 22, 2017 12:35
Different chunks for DB navigation
<?php
/**
* Special implementation of chunk
* Used in case when records' count depends on dynamic condition and decreases during performing to zero
* In this way default chunk of query builder can't work correctly
* @param $query
* @param $callback
*/
private function chunkForDecreasesCollection($query, $callback)
@loburets
loburets / removePhpStorm.sh
Last active June 22, 2022 17:09
remove phpsotrm from osx mac or other utils (КриптоПро CSP)
rm -rf /Applications/PhpStorm.*
rm -rf ~/Library/Preferences/jetbrains.*
rm -rf ~/Library/Logs/JetBrains/PhpStorm*
rm -rf ~/Library/Caches/PhpStorm*
rm -rf ~/Library/Caches/JetBrains/PhpStorm*
rm -rf ~/Library/Application\ Support/PhpStorm*
rm -rf ~/Library/Application\ Support/JetBrains*
rm -rf ~/Library/ApplicationSupport/PhpStorm*
rm -rf ~/Library/ApplicationSupport/JetBrains*
@loburets
loburets / ES5_js_inheritance_example.js
Last active October 24, 2018 15:42
ES5 js multiple inheritance example
function Machine() {
this._enabled = false;
this.enable = function() {
this._enabled = true;
};
this.disable = function() {
this._enabled = false;
};
}
@loburets
loburets / laravel_full_mysql_query.php
Last active April 9, 2021 08:53
To get mysql query from laravel with embed parameters of the binding
<?php
// Use your query before you make get(), first() etc
$query = \Model::where()->join()->etc();
$sql = $query->toSql();
$sql = str_replace('"', '`', $sql);
// just for the raw queries too look normal in the console:
$sql = str_replace("\n", ' ', $sql);
$sql = str_replace("\t", ' ', $sql);
foreach ($query->getBindings() as $binding) {