Skip to content

Instantly share code, notes, and snippets.

@purpleferret
purpleferret / image-coordinates.html
Created February 7, 2023 20:32
Image coordinates in HTML/JavaScript with persisting in localStorage
<html lang="en">
<head>
<title>Image coordinates - example</title>
</head>
<body>
<style type="text/css"></style>
<h1>Image coordinates</h1>
<p id="output">Click inside the image to get coordinates</p>
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
diff --git a/node_modules/http-proxy-middleware/lib/index.js b/node_modules/http-proxy-middleware/lib/index.js
index 8da7304..dfccd86 100644
--- a/node_modules/http-proxy-middleware/lib/index.js
+++ b/node_modules/http-proxy-middleware/lib/index.js
@@ -33,6 +33,16 @@ function HttpProxyMiddleware(context, opts) {
// log errors for debug purpose
proxy.on('error', logError)
+ proxy.on('proxyReqWs',
+ (proxyReq, req, socket, options, head) => {
@purpleferret
purpleferret / filebuffer.go
Created November 21, 2019 12:15 — forked from minikomi/filebuffer.go
Read file to buffered bytes buffer in chunks.
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"os"
)
@purpleferret
purpleferret / smtp-gmail-send.go
Created August 9, 2019 06:47 — forked from jpillora/smtp-gmail-send.go
Send email using Go (Golang) via GMail with net/smtp
package main
import (
"log"
"net/smtp"
)
func main() {
send("hello there")
}

Reading data before application startup in Angular 2

In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.

This is how the demonstration will load data:

a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';

b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.

@purpleferret
purpleferret / open-source-sso.md
Created January 30, 2019 12:49 — forked from yanivmn/open-source-sso.md
Comparison of open-source SSO implementations
Aerobase Keycloak WSO2 Identity Server Gluu CAS OpenAM Shibboleth IdP
OpenID Connect/OAuth support yes yes yes yes yes yes third-party
Multi-factor authentication yes yes yes yes yes yes yes
Admin UI yes yes yes yes yes yes no
OpenJDK support yes yes yes yes no
Identity brokering yes yes yes
Middleware NGINX, Wildfly Wildfly, JBOSS WSO2 Carbon Jetty, Apache HTTPD any Java app server any Java app server Jetty, Tomc
@purpleferret
purpleferret / docker-clean.md
Last active September 17, 2018 12:32
Cleanup docker images and containers after failed builds

Cleanup docker images and containers after failed builds

Sometimes, there are some untagged images left behind after failed builds. In order to get rid of those, this script can be used.

#!/usr/bin/env bash

# delete all containers
docker rm $(docker ps -aq)
@purpleferret
purpleferret / trace.process.file.access.md
Last active September 21, 2016 13:44
Trace a process' file access (unix/linux)

Try doing this as a starter:

lsof -p <PID>

this command will list all opened files, fd, sockets...

For your special needs, see what I can offer as a solution to monitor a php script:

php foo.php & _pid=$!
lsof -r1 -p $_pid
@purpleferret
purpleferret / find.file.in.git.repo.sh
Created July 29, 2016 08:21
Find a file in a git repository (all revs)
git rev-list --all | xargs -I '{}' git ls-tree --full-tree -r '{}' | grep '.*HelloWorld\.sh$'