Skip to content

Instantly share code, notes, and snippets.

@xelaz
xelaz / Module.php
Last active August 29, 2015 14:09 — forked from noopable/Module.php
<?php
namespace Application;
use Locale;
use Zend\EventManager\Event;
use Zend\ModuleManager\Feature;
class Module implements
Feature\BootstrapListenerInterface
{
@xelaz
xelaz / dev.conf
Created January 21, 2016 22:30 — forked from scragg0x/dev.conf
Nginx proxy for Vagrant 80 to 8080
server {
listen 80;
server_name *.dev;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 150;
@xelaz
xelaz / vagrant-clean.sh
Created January 28, 2016 15:08 — forked from jdowning/vagrant-clean.sh
Script to clean up Ubuntu Vagrant box before packaging
#!/bin/bash
# This script zeroes out any space not needed for packaging a new Ubuntu Vagrant base box.
# Run the following command in a root shell:
#
# bash <(curl -s https://gist.github.com/justindowning/5670884/raw/vagrant-clean.sh)
function print_green {
echo -e "\e[32m${1}\e[0m"
}
@xelaz
xelaz / javascript-canvas-sharpen.js
Created March 1, 2018 17:09 — forked from mikecao/javascript-canvas-sharpen.js
Javascript function for sharpening images.
function sharpen(ctx, w, h, mix) {
var x, sx, sy, r, g, b, a, dstOff, srcOff, wt, cx, cy, scy, scx,
weights = [0, -1, 0, -1, 5, -1, 0, -1, 0],
katet = Math.round(Math.sqrt(weights.length)),
half = (katet * 0.5) | 0,
dstData = ctx.createImageData(w, h),
dstBuff = dstData.data,
srcBuff = ctx.getImageData(0, 0, w, h).data,
y = h;
@xelaz
xelaz / resize_preview.html
Created March 2, 2018 17:03 — forked from mfyz/resize_preview.html
HTML5 FileReader + canvas resizer to resize & preview before upload an image using jquery.
<!DOCTYPE html>
<html>
<head>
<title>Angular HTML5 Preview, Crop And Upload</title>
<style>
body {
padding: 50px;
font: 16px Helvetica;
}
@xelaz
xelaz / ElastisearchIngestExample.md
Created May 8, 2018 09:31 — forked from qoomon/ElastisearchIngestExample.md
Elasticsearch auto generated timestamps

PUT _ingest/pipeline/timestamp

{
    "description": "Adds a timestamp field at the current time",
    "processors": [
        {
            "set": {
                "field": "@timestamp",
                "value": "{{_ingest.timestamp}}",
 "override": false
@xelaz
xelaz / imageUpload.js
Created June 5, 2018 10:43 — forked from richardzcode/imageUpload.js
Upload image file from Node.js
/**
* Example of simulating file upload post form from node.js
*
* Set your own file and server options.
*/
var img = require('fs').readFileSync('./sample.png');
var options = { host: '...'
, port: ...
// Wifi Credentials
const WIFI_NAME = "YOURSSID";
const WIFI_PASS = "YOURPASS";
// Your location latitude and longitude
const lat = 'YOURLAT';
const lon = 'YOURLON';
// Required libs
@xelaz
xelaz / default HTTP
Created November 17, 2022 20:31 — forked from iam-hussain/default HTTP
Serve nextJS app from a port through NGINX reverse proxy HTTP and HTTPS
# Serve nextJS app from a port through NGINX reverse proxy (HTTP)
# Path: /etc/nginx/sites-available/default
# Default server configuration for HTTP
server {
server_name www.DOMAINNAME.com DOMAINNAME.com;
# Serve any static assets with NGINX
location /_next/static {
alias /home/ubuntu/PROJECT_FOLDER/.next/static;