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 / main.js
Created December 10, 2014 10:10
Stream data with php
<script>
try {
var source = new EventSource('/stream');
source.addEventListener('tick', function ( evt ) {
console.log(evt.data);
});
}
catch ( e ) {
@nxvhm
nxvhm / Hasher.php
Created January 30, 2015 18:03
Password Hash
<?php
class Hasher
{
private static $_pepper = 'Bh7ly%NX*3OY12%zd50amb$bizad%pxln*3a5q';
/**
* @param plain pass | string generated from bcrypt_salt() method
* @return string
*/
@nxvhm
nxvhm / Utils.php
Last active June 12, 2017 09:37
openssl functions(encrypt, decrypt, random string)
<?php
namespace Utils;
use Config;
class SecurityUtils {
/**
* @param string $string: string to encrypt or decrypt
@nxvhm
nxvhm / ContextParser.php
Created February 12, 2018 05:52
Handlebars php parser
<?php
// uncomment the following two lines, if you don't use composer
require 'vendor/handlebars.php-0.10.4/src/Handlebars/Autoloader.php';
// require 'vendor/handlebars.php-master/src/Handlebars/Autoloader.php';
Handlebars\Autoloader::register();
use Handlebars\Handlebars;
@nxvhm
nxvhm / contenxt.html
Last active April 10, 2018 18:03
macros-extra-contents
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="macro-1">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
{{extra_contents}}
@nxvhm
nxvhm / HttpRequest.php
Created August 3, 2018 09:52
class for Http Requests
<?php
require_once('HttpResponse.php');
class HttpRequest {
/**
* The url which will be requested
* @var string
*/
@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;
@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 / 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 / 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 => {