Skip to content

Instantly share code, notes, and snippets.

View bernard-ng's full-sized avatar
🏠
Working from home

Bernard Ngandu bernard-ng

🏠
Working from home
View GitHub Profile
@bernard-ng
bernard-ng / mimes.json
Created July 28, 2019 01:05 — forked from shurup14/mimes.json
Mimes types
{
"text/vnd.wap.wmlscript": "Wireless Markup Language Script (WMLScript)",
"application/cu-seeme": "CU-SeeMe",
"application/vnd.mobius.plc": "Mobius Management Systems - Policy Definition Language File",
"application/vnd.dna": "New Moon Liftoff/DNA",
"application/mathml+xml": "Mathematical Markup Language",
"image/x-cmx": "Corel Metafile Exchange (CMX)",
"application/vnd.oasis.opendocument.text": "OpenDocument Text",
"application/vnd.ezpix-album": "EZPix Secure Photo Album",
"application/xslt+xml": "XML Transformations",
@bernard-ng
bernard-ng / websiteupdate.sh
Created October 9, 2019 20:09
update a website after a github commit
#!/bin/sh
set -e
if [ ! -f /var/www/html/public/doDeploy ]; then
exit;
fi
rm /var/www/html/public/doDeploy
STAMP=$(date +%s)
WORKDIR=/tmp/$STAMP
NEWDIR=$WORKDIR/new
@bernard-ng
bernard-ng / .htaccess
Last active February 10, 2024 02:26
basic root htaccess config
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
<IfModule mod_rewrite.c >
RewriteEngine on
RewriteOptions inherit
@bernard-ng
bernard-ng / rdc-interactive-map.svg
Created December 11, 2019 14:37
Congo DR interactive SVG map
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
DirectoryIndex disabled
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:3000/ [P,L]
RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L]
<?php
$initialState = [
'count' => [
'count' => 1
],
];
<?php
$initialState['count']['count'] +=1
<?php
const INCREMENT_ACTION = 'INCREMENT';
const DECREMENT_ACTION = 'DECREMENT';
$actions = [
'increment' => [
'type' => INCREMENT_ACTION
],
'decrement' => [
'type' => DECREMENT_ACTION
<?php
function countReducer(array $state, $action) {
switch($action['type']) {
case INCREMENT_ACTION:
return array_replace([], $state, ['count' => $state['count'] + 1]);
case DECREMENT_ACTION:
return array_replace([], $state, ['count' => $state['count'] - 1]);
default:
return $state;
}
<?php
class Store
{
protected array $state;
protected Closure $reducer;
public function __construct(callable $reducer, array $initialState)
{
$this->state = $initialState;
$this->reducer = Closure::fromCallable($reducer);
}