Skip to content

Instantly share code, notes, and snippets.

View ricardov03's full-sized avatar
:octocat:
Building my future one commit at a time.

Ricardo A. Vargas R. ricardov03

:octocat:
Building my future one commit at a time.
View GitHub Profile
<?php
function memoize($target) {
static $memo = new WeakMap;
return new class ($target, $memo) {
function __construct(
protected $target,
protected &$memo,
) {}
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)
@rakibulinux
rakibulinux / UFW.sh
Created February 4, 2020 20:48
How to Configure a Firewall with UFW
What is UFW?
UFW, or uncomplicated firewall, is a frontend for managing firewall rules in Arch Linux, Debian or Ubuntu. UFW is used through the command line (although it has GUIs available), and aims to make firewall configuration easy (or, uncomplicated).
sudo apt-get update && sudo apt-get upgrade
#Install UFW
sudo apt-get install ufw
#Use UFW to Manage Firewall Rules. Set Default Rules
sudo ufw default allow outgoing

Installation

This procedure is tested on Mac OS X 10.14.0 with Xcode Developer Tools installed (xCode).

PHP 5.6, 7.0, 7.1, and 7.2 installed with Homebrew following the instructions here.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

@freekmurze
freekmurze / curry.php
Created December 17, 2016 20:51
curry.php
<?php
function curry($f, $argument)
{
return function (...$arguments) use ($f, $argument) {
return $f(...array_merge([$argument], $arguments));
};
}
function add(...$numbers)
@freekmurze
freekmurze / undot.php
Last active June 24, 2022 05:04
Undot
<?php
function undot(array $dottedArray)
{
$undottedArray = [];
foreach ($dottedArray as $key => $value) {
Arr::set($undottedArray, $key, $value);
}
@freekmurze
freekmurze / deploy.php
Last active February 5, 2021 02:43
A sample deploy.php file that can be used with Deployer (http://deployer.in)
<?php
/*
* Define the servers
*/
server('production-web', '<your server url>')
->path('<path to the project on your server>')
->user('<user on the server>')
->pubKey();
/*