Skip to content

Instantly share code, notes, and snippets.

View napolux's full-sized avatar
🇮🇹
Hello from Italy!

Francesco Napoletano napolux

🇮🇹
Hello from Italy!
View GitHub Profile
@napolux
napolux / darkmode.js
Created January 3, 2021 17:15
LinkedIn (and all the other websites) dark mode bookmarklet
javascript:(d=>{var css=`:root{background-color:#fefefe;filter:invert(100%)}*{background-color:inherit}img:not([src*=".svg"]),video{filter:%20invert(100%)}`,style,id="dark-theme-snippet",ee=d.getElementById(id);if(null!=ee)ee.parentNode.removeChild(ee);else%20{style%20=%20d.createElement('style');style.type="text/css";style.id=id;if(style.styleSheet)style.styleSheet.cssText=css;else%20style.appendChild(d.createTextNode(css));(d.head||d.querySelector('head')).appendChild(style)}})(document)
@napolux
napolux / server.ts
Created June 11, 2020 16:33
Deno server example
import { serve } from "https://deno.land/std@0.56.0/http/server.ts";
const PORT = 8000;
const s = serve({ port: PORT });
console.log(`Listening @ http://localhost:${PORT}`);
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
@napolux
napolux / gist:7eddbf88334d3030cb55ddc4ad292baf
Created May 17, 2020 16:17
Real git log from a side-project of mine
ab7ac74864f5738482b4a1c899007ce8792da4c3 Update
8eea721f09ba78fdd1cde05c72676c15f89f373f Update
fc1c0a15d66bb197d625acfc9ea1da98f34dd7b3 Update
6d62fc4fb9f4ad8b326fa6900303567411d0c37f update
99557cb9b8e3b2b3c6f30c8e11574926aeb82492 UPdate
d7bf450410e8e563d0aff41d3e037f34b7526947 Update
1023d7d1c7cbf1dca50338d75e26c9f8603b62c1 Update
cdbe4512edf73fb38bbd31f55e14f2a760f15e3b Update
47e3bba33f2c9b9e20b1389aaa5c0a0820ed3f38 Update
d3a762ca74c48fc2e6002b8d7d678d337dfd656d Update
@napolux
napolux / transport.go
Created April 15, 2019 19:40
transport.go
package napodate
import (
"context"
"encoding/json"
"net/http"
)
// In the first part of the file we are mapping requests and responses to their JSON payload.
type getRequest struct{}
@napolux
napolux / service_test.go
Created April 15, 2019 19:39
service_test.go
package napodate
import (
"context"
"testing"
"time"
)
func TestStatus(t *testing.T) {
srv, ctx := setup()
@napolux
napolux / service.go
Created April 15, 2019 19:38
service.go
type dateService struct{}
// NewService makes a new Service.
func NewService() Service {
return dateService{}
}
// Status only tell us that our service is ok!
func (dateService) Status(ctx context.Context) (string, error) {
return "ok", nil
@napolux
napolux / service.go
Created April 15, 2019 19:36
service.go
package napodate
import "context"
// Service provides some "date capabilities" to your application
type Service interface {
Status(ctx context.Context) (string, error)
Get(ctx context.Context) (string, error)
Validate(ctx context.Context, date string) (bool, error)
}
@napolux
napolux / package.json
Created February 15, 2019 10:45
How to add comments to your package.json (see at the end of the file)
{
"name": "napolux-frontend",
"version": "1.0.0",
"description": "it's a test",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
@napolux
napolux / status.sh
Last active August 30, 2018 18:30
Print the size of redis keys in a readable way (I use it for sets)
#!/bin/sh
for SET in `redis-cli --scan --pattern 'set:*'`
do
printf "%s\t%s\n" $SET `redis-cli SCARD $SET`
done
# example output
# set:2454148031 33
# set:1497228031 1932
# set:524015031 418
<?php
namespace API\Middleware;
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
/**
* Class AmazonMiddleware
* @package API\Middleware
*/
class AmazonMiddleware