Skip to content

Instantly share code, notes, and snippets.

View nxvhm's full-sized avatar
🍒

Antoan Partadzhiev nxvhm

🍒
  • Plovdiv, Bulgaria
View GitHub Profile
@nxvhm
nxvhm / PostgreEnum.php
Last active October 16, 2025 19:52
PostgreSQL Enum Helper class for Laravel
<?php
declare(strict_types=1);
namespace App\Lib\Helpers;
use Illuminate\Support\Facades\DB;
class PostgreEnum {
@nxvhm
nxvhm / ffmpeg.md
Created May 29, 2025 04:27 — forked from steven2358/ffmpeg.md
FFmpeg cheat sheet
@nxvhm
nxvhm / explode-opvn.sh
Created September 18, 2023 19:05 — forked from dleonard00/explode-opvn.sh
extract the certificate and key from an .ovpn file
#!/bin/bash
# This script will extract the certificate and key from an .ovpn file
# into their own files, which makes it possible to use them to configure
# the VPN using Ubuntu's network manager
# Usage example:
# >> ovpnconvert username.dev.ovpn
# You can keep following these instructions here:
@nxvhm
nxvhm / example.js
Created January 12, 2022 14:03
Order array of urls of images by their dimensions
let orderbyDimensions = images => {
let promises = [];
// console.log('to order by dimensions', images);
images.forEach(imgUrl => {
let img= new Image;
img.src = imgUrl;
let promise = new Promise( (resolve, reject) => {
img.onload=function(){
resolve({with: this.width, h:this.height, max: this.width*this.height, url: imgUrl});
@nxvhm
nxvhm / NaturalLanguageProcessingApi.php
Created August 26, 2021 17:58
Class to communicate with IBM Watson NLP Service
<?php
namespace App\Library\IbmApi;
use App\Library\IbmApi\Exceptions\IbmException;
use Log;
/**
* Natural language processing for advanced text analysis
*/
class NaturalLanguageProcessingApi {
@nxvhm
nxvhm / tiles-downloader.php
Created July 16, 2020 09:58
Replace tiles set with the default openstreetmap tiles , download openstreet map tiles
<?php
# Folder in which current tiles reside
$currentTilesFolder = 'tiles';
# Timeout between requests so script doesnt get blocked
$timeout = 1;
# Init recusrive iterator
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($currentTilesFolder));
@nxvhm
nxvhm / browserConsole.js
Created June 9, 2020 11:16
POST request with fetch
fetch('http://mydomain.local/api/photo', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({'lat': 12121, lng: 1212121, title: 'dasdasdsa', 'image': 'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg=='})
}).then(res => {
console.log('res', res);
}).catch(err => {
@nxvhm
nxvhm / style.css
Created March 13, 2020 12:44
fix select2 height when using with form-control bootstrap class
.select2-selection__rendered {
line-height: 31px !important;
}
.select2-container .select2-selection--single {
height: 35px !important;
}
.select2-selection__arrow {
height: 34px !important;
@nxvhm
nxvhm / send_msg.php
Created March 2, 2019 18:34
PHP to SocketIO or any WAMP Socket Server
<?php
# Note that 8080 is the port to my Node.js server - you may want to change.
function sio_message($message, $data) {
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$result = socket_connect($socket, '127.0.0.1', 8080);
if(!$result) {
die('cannot connect '.socket_strerror(socket_last_error()).PHP_EOL);
}
$bytes = socket_write($socket, json_encode(Array("msg" => $message, "data" => $data)));
@nxvhm
nxvhm / laravel.nginx.conf
Created February 16, 2019 09:48
nginx fpm vhost configs for laravel/phpmyadmin for local dev
server {
listen 80;
server_name laravel-project.local;
root /vagrant/code/laravel-project/public;
index index.php index.html;