Skip to content

Instantly share code, notes, and snippets.

@pedroborges
pedroborges / blog.php
Last active December 1, 2017 23:03
Besides finding non-exact matches in your content, Fuzzy Search for @getkirby offers some neat features like the ability to search through a custom page method. https://github.com/pedroborges/kirby-fuzzy-search
<?php
// site/controllers/blog.php
return function($site, $pages, $page) {
$query = esc(get('q'));
$articles = $page->children()->visible()->flip();
if ($query) {
$articles = $articles->fuzzySearch($query, 'title|text|authorName');
}
@wottpal
wottpal / relative-time.php
Last active October 21, 2017 16:38 — forked from mtttmpl/relative-time.php
Get Relative Time in PHP (e.g. '1 hour ago', 'yesterday', 'tomorrow', 'in 2 weeks'). With the argument $max_diff you can specify the number of days from when the actual date should be returned.
<?php
/**
* Get Relative Time in PHP (e.g. '1 hour ago', 'yesterday', 'tomorrow', 'in 2 weeks').
* With the argument `$max_diff` you can specify the number of days from when the
* actual date should be returned witht the format of `$date_format`.
*
* Gist: https://gist.github.com/wottpal/61bc13425a8cedcd88666040d1449bfd
* Fork of: https://gist.github.com/mattytemple/3804571
*/
@gagarine
gagarine / install-clamav-osx.md
Last active June 7, 2023 07:54
Howto Install clamav on OSX with brew

Howto Install clamav on OSX with brew

Note: on legacy intel system the path may be /usr/local/etc/clamav instead of /opt/homebrew/etc/clamav/

$ brew install clamav
$ cd /opt/homebrew/etc/clamav/
$ cp freshclam.conf.sample freshclam.conf
@guitarrapc
guitarrapc / RecoverPSGallery.ps1
Last active June 14, 2022 01:10
Whom you miss PSGallery with Get-PSRepository!
Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -PublishLocation https://www.powershellgallery.com/api/v2/package/ -ScriptSourceLocation https://www.powershellgallery.com/api/v2/items/psscript/ -ScriptPublishLocation https://www.powershellgallery.com/api/v2/package/ -InstallationPolicy Trusted -PackageManagementProvider NuGet
@nitaku
nitaku / README.md
Last active April 15, 2024 14:22
Minimal JSON HTTP server in python

A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.

python server.py 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
@mikaelbr
mikaelbr / destructuring.js
Last active April 25, 2024 13:21
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
<?php
// dangerously simple PHP regular expression URL router
// requires a mod_rewrite like "RewriteRule . /index.php [L]"
function get($url, $callback) {
$matches = array();
if (preg_match('~' . $url . '~', $_SERVER['REQUEST_URI'], $matches)) {
echo call_user_func_array($callback, $matches);
die();
}
@xeoncross
xeoncross / ajax.js
Last active August 3, 2023 06:06
Simple, cross-browser Javascript POST/GET xhr request object. Supports request data and proper AJAX headers.
/**
* IE 5.5+, Firefox, Opera, Chrome, Safari XHR object
*
* @param string url
* @param object callback
* @param mixed data
* @param null x
*/
function ajax(url, callback, data, x) {
try {
@dave1010
dave1010 / php-regex-router.php
Created September 13, 2011 15:46
php-regex-router.php
<?php
// dangerously simple PHP regular expression URL router
// requires a mod_rewrite like "RewriteRule . /index.php [L]"
function get($url, $callback) {
$matches = array();
if (preg_match('~' . $url . '~', $_SERVER['REQUEST_URI'], $matches)) {
echo call_user_func_array($callback, $matches);
die();
}