Skip to content

Instantly share code, notes, and snippets.

View 1int's full-sized avatar

Pavel Lint 1int

  • Spain
View GitHub Profile
@1int
1int / Laravel add error to session (view $errors array)
Last active November 30, 2018 16:30
A function to add errors to Laravel session $errors array
/**
* Takes six lines to correctly add an error to Laravel session errors array.
* On the brign side, these errors are directly accessible from views by the name of $errors.
* Ref: https://gist.github.com/1int/a1c7162dfeb6014ee26eeda0af5b862f
*
* @var string $key
* @var string $message
*/
function flashError($key, $message) {
$session = session();
@1int
1int / wp_move.sql
Created May 30, 2018 20:08
Move wordpress to another domain
/* Just set these 2 variables to change wordpress domain in the db */
SET @old_site_domain = 'catsvsdogs.com';
SET @new_site_domain = 'catsvsdogs.dv';
UPDATE wp_options SET option_value = replace(option_value, @old_site_domain, @new_site_domain) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, @old_site_domain, @new_site_domain);
UPDATE wp_posts SET post_content = replace(post_content, @old_site_domain, @new_site_domain);
UPDATE wp_postmeta SET meta_value = replace(meta_value, @old_site_domain, @new_site_domain);
@1int
1int / stockfish.sh
Created May 28, 2018 13:02
Run stockfish from shell
#!/bin/sh
#
# Assuming you have stockfish binary in your PATH, this is the way to invoke it
#
(
echo "position fen r1bq1r2/pp3pk1/5Npp/5n2/3Q4/3B2PP/PP4PK/2R2R2 w - -" ;
echo "go depth 15" ;
sleep 1
) | stockfish