Skip to content

Instantly share code, notes, and snippets.

View eosvn's full-sized avatar
🎯
Focusing

Be Duc Tai eosvn

🎯
Focusing
View GitHub Profile
@eosvn
eosvn / canvas-upload.php
Created May 22, 2024 14:49 — forked from fazlurr/canvas-upload.php
Function to save base64 image to png with PHP
<?php
// requires php5
define('UPLOAD_DIR', 'images/');
$img = $_POST['img'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';
@eosvn
eosvn / php_unserialize_to_json.sql
Created March 20, 2022 16:07 — forked from storeman/php_unserialize_to_json.sql
PHP unserialize in Postgresql to json
/**
Decode a php serialized value to json. This function only supports basic
data types:
- arrays (will always become a json object)
- booleans
- integers
- floats
- strings
- NULL
The php_unserialize(text) function is a helper function which extracts the first value
@eosvn
eosvn / nginx.conf
Created September 24, 2021 09:59 — forked from ashleydw/nginx.conf
Laravel nginx conf file
server {
listen 80 default_server;
server_name example.com www.example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
root /srv/www/example.com/public;
index index.php index.html;
@eosvn
eosvn / localhost-ssl-certificate.md
Created October 3, 2020 03:34 — forked from ethicka/localhost-ssl-certificate.md
Localhost SSL Certificate on Mac OS Sierra and High Sierra

This gives you that beautiful green lock in Chrome. I'm assuming you're putting your SSL documents in /etc/ssl, but you can put them anywhere and replace the references in the following commands. Tested successfully on Mac OS Sierra and High Sierra.

Set up localhost.conf

sudo nano /etc/ssl/localhost/localhost.conf

Content:

[req]
Key Sublime Text 3.2.1 Build 3207
----- BEGIN LICENSE -----
Member J2TeaM
Single User License
EA7E-1011316
D7DA350E 1B8B0760 972F8B60 F3E64036
B9B4E234 F356F38F 0AD1E3B7 0E9C5FAD
FA0A2ABE 25F65BD8 D51458E5 3923CE80
87428428 79079A01 AA69F319 A1AF29A4
A684C2DC 0B1583D4 19CBD290 217618CD

Keybase proof

I hereby claim:

  • I am eosvn on github.
  • I am eosvn (https://keybase.io/eosvn) on keybase.
  • I have a public key ASCgowg4rtxIbPTxTta5BRw3OC9OoIoor0pBqQYJIFjLawo

To claim this, I am signing this object: