Skip to content

Instantly share code, notes, and snippets.

@xralphack
xralphack / machine.js
Last active February 25, 2021 04:18
Generated by XState Viz: https://xstate.js.org/viz
const fetchDeviceState = () => Promise.resolve({
'online': true,
'isWatering': Math.random() > 0.1,
'isFirmwareUpdating': false
})
const yardianStateMachine = Machine({
id: 'yardian-state-machine',
initial: 'fetchingDeviceState',
context: {
@xralphack
xralphack / machine.js
Created April 6, 2020 06:59
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'SWAPI',
initial: 'idle',
context: {
user: null
},
states: {
idle: {
on: {
FETCH: 'loading'
@xralphack
xralphack / gist:a0077d3667cea2541db18ecf6e5819da
Created September 1, 2017 07:09
phpmyadmin config for nginx
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
function getScriptNameFromPath($path)
{
$pathElements = explode('/', $path);
$scriptName = end($pathElements);
reset($pathElements);
return $scriptName;
}
@xralphack
xralphack / laravel.conf
Created April 26, 2017 07:14
nginx conf for laravel
# the following directive in your site configuration will direct all requests to the index.php front controller
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# use phpfpm to process .php files
@xralphack
xralphack / nginx whitelist for facebook
Created July 14, 2016 09:33
Force auth in nginx except for facebooks crawler.
server{
satisfy any;
# https://developers.facebook.com/docs/ApplicationSecurity/#facebook_scraper
allow 31.13.24.0/21;
allow 31.13.64.0/18;
allow 66.220.144.0/20;
allow 69.63.176.0/20;
allow 69.171.224.0/19;
allow 74.119.76.0/22;