Skip to content

Instantly share code, notes, and snippets.

View joram77's full-sized avatar

Joram Declerck joram77

View GitHub Profile
SELECT * FROM information_schema.tables
zend_extension=xdebug
[xdebug]
xdebug.mode=debug # develop has impact on performance
xdebug.client_port = 9000
xdebug.idekey=PHPSTORM
xdebug.client_host=host.docker.internal
%div.button
= render layout: 'folder/link_layout', locals: {link: link} do
= button_contents_variable
#folder/_link_layout.html.haml contents:
%a{href: link}
= yield # contents of button_contents_variable will be nested in the %a tag
# inspired by https://stackoverflow.com/questions/35933558/unexpected-error-using-yield-in-haml-nesting
@joram77
joram77 / Makefile
Last active December 6, 2022 09:50
Xdebug makefile to quickly turn off and on xdebug extension in PHP-fpm container and reload service
DOCKER_CP_XDEBUG_ON=docker cp docker/php-fpm/docker-php-ext-xdebug-on.ini php-fpm_1:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
DOCKER_CP_XDEBUG_OFF=docker cp docker/php-fpm/docker-php-ext-xdebug.ini php-fpm_1:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
.PHONY: about xdebug-on xdebug-off
about:
echo "Xdebug Makefile https://github.com/joram77 - Joram Declerck"
echo "- Install: copy contents to Makefile in your project"
echo "- Usage: make xdebug-on or make xdebug-off"
sudo badblocks -sv /dev/sda > bad-blocks-result
sudo fsck -t ext4 -l bad-blocks-result /dev/sda1
----
sudo add-apt-repository universe
sudo apt-get install hfsprogs hfsplus
sudo fsck.hfsplus /dev/sda2
# B from C fromdomain D frompath E statuscode F to G rewriterule(formula below)
="if ($host = """&C8&""") { rewrite ^"&REGEXREPLACE(regexreplace(B8,"(.+)\?(.*)","$1"),"^(https://|http://)([^/]+)(.+)","$3")& "$ "& F8 &"? permanent; }"
# C fromdomain (formula below)
=index(split(B3,"/"),0,2)
docker cp ./.ssh/id_ed25519 container-name:/root/.ssh/id_rsa ; docker exec container-name bash -c "chmod 700 /root/.ssh/id_rsa"
# Powershell script to split large sql files to separate sql files per table - joram77
$inputFile = "c:\users\money\dumps\db_slimmed.sql"
$fileInfo = New-Object System.IO.FileInfo($inputFile)
$newDir = $fileInfo.Directory.ToString() + '\' + $fileInfo.BaseName.ToString()
New-Item -ItemType Directory -Force -Path $newDir
$outputFile = "$newDir\db_slimmed_start.sql"
$reader = New-Object System.IO.StreamReader($inputFile)
$count = 0
SELECT FIELDS(ALL) FROM Account LIMIT 200
@joram77
joram77 / jaccard_recommendation.rb
Created September 27, 2023 06:46 — forked from otobrglez/jaccard_recommendation.rb
Simple recommendation system written in Ruby based on Jaccard index.
# Simple Recommendation Engine in Ruby
# Visit: http://otobrglez.opalab.com
# Author: Oto Brglez <[email protected]>
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end