Skip to content

Instantly share code, notes, and snippets.

View nicopenaredondo's full-sized avatar

Nico R. Penaredondo nicopenaredondo

View GitHub Profile
FROM php:7.3-fpm-alpine
# Install dev dependencies
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
curl-dev \
imagemagick-dev \
libjpeg-turbo \
libjpeg-turbo-dev \
libjpeg \
@nicopenaredondo
nicopenaredondo / distance-sample.php
Created April 13, 2020 09:31 — forked from LucaRosaldi/distance-sample.php
PHP: Get Distance Between two Geolocated Points (lat/lon)
<?php
/* These are two points in New York City */
$point1 = array('lat' => 40.770623, 'long' => -73.964367);
$point2 = array('lat' => 40.758224, 'long' => -73.917404);
$distance = getDistanceBetweenPoints($point1['lat'], $point1['long'], $point2['lat'], $point2['long']);
foreach ($distance as $unit => $value) {
echo $unit.': '.number_format($value,4).'<br />';
}
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"MobileAppVersion": {
".read": "true"
},
"queue": {
".read": "true",
"tasks": {
{
"editor.multiCursorModifier": "ctrlCmd",
"editor.snippetSuggestions": "top",
"editor.formatOnPaste": true,
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"emmet.triggerExpansionOnTab": true,
"php.suggest.basic": false,
"editor.autoIndent": true,
"emmet.includeLanguages": {
private function csvToArray($filename='', $delimiter=',')
{
$rows = array_map('str_getcsv', file($filename));
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {
if(count($row) != count($header)) {
dd($row);
}
private function csvToArray($filename='', $delimiter=',')
{
$rows = array_map('str_getcsv', file($filename));
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {
if(count($row) != count($header)) {
dd($row);
}
_processInstructionItems(employerId, programs)
{
return new Promise((resolve, reject) => {
let self = this;
let listOfPrograms = [];
_.forEach(programs, item => {
Program.find(item.id).then(programData => {
this._processProgramItemCode(employerId, item, programData).then(programItem => {
listOfPrograms.push(programItem)
})
@nicopenaredondo
nicopenaredondo / node_crypto.js
Created July 16, 2016 14:01 — forked from rojan/node_crypto.js
Encrypt in nodejs and decrypt in php or vice versa
var crypto = require('crypto');
var key = 'MySecretKey12345';
var iv = '1234567890123456';
var cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
var decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);
var text = 'plain text';
var encrypted = cipher.update(text, 'utf8', 'binary');
encrypted += cipher.final('binary');
hexVal = new Buffer(encrypted, 'binary');
@nicopenaredondo
nicopenaredondo / serve.sh
Created May 11, 2016 02:16
NGINX Subdomain generator
#!/usr/bin/env bash
if [ -z $1 ]
then
echo "serve www.domain.com /path"
exit 1
fi
if [ -z $2 ]
then
<?php
function codeGenerator($length)
{
$az = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZMULTIPAY';
$azr = rand(0, 51);
$azs = substr($az, $azr, 10);
$stamp = hash('sha256', time());
$mt = hash('sha256', mt_rand(5, 20));
$alpha = hash('sha256', $azs);