Skip to content

Instantly share code, notes, and snippets.

View mavelar's full-sized avatar
😎
I may be slow to respond.

Manuel Avelar mavelar

😎
I may be slow to respond.
View GitHub Profile
@mavelar
mavelar / site.conf
Last active January 8, 2020 01:29
Nginx Configuration for Docker Deployments
server {
server_name {DOMAINS};
# include snippets/security.conf;
rewrite ^/(.*)/$ /$1 permanent;
# if ($redirect_uri ) {
# return 301 $redirect_uri;
# }
@mavelar
mavelar / can-you-sort.php
Created November 23, 2019 05:53
Hackerrank Can You Sort Test
<?php
function customSort($arr) {
$keys = array_count_values($arr);
$newsort = [];
$conc = [];
$output = "";
asort($keys);
foreach($keys as $k => $v) {
@mavelar
mavelar / AccessBehavior.php
Created March 16, 2017 03:08 — forked from r3verser/AccessBehavior.php
Yii2 Redirects all users to login (or any) page if not logged in, but allow access to some pages (like signup, password recovery etc.)
<?php
/*
* In configuration file
* ...
* 'as AccessBehavior' => [
* 'class' => 'app\components\AccessBehavior',
* 'allowedRoutes' => [
* '/',
* ['/user/registration/register'],
@mavelar
mavelar / file
Last active February 18, 2017 18:40
freedom_public
{"0.8822604255837376":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgMEVP5a8Yf+2saCjROO0AtEPARapBfL6/kZ\r\nIOKM4+13G3zka3DElLhK/ZgmcWYcvN73dKNMDU2e7DZORAQm+y8XsM3/AAAACDxn\r\naXRodWI+wv8AAACOBBATCABA/wAAAAWCWKiU2v8AAAACiwn/AAAACZDUFKwQxQIN\r\nWP8AAAAFlQgJCgv/AAAABJYDAQL/AAAAApsD/wAAAAKeAQAA8FsA/R/xvIre7JBL\r\n/x3IL5Bjc0WVtsAVhg1LmLDUtyMxu1QcAP9Hag9IOBlTYM5//Zp4/DOMlZ92hSJc\r\naKp6R6gg41ACa87/AAAAVgQAAAAAEggqhkjOPQMBBwIDBCsjY3VVoK/F8mGuGtIu\r\nY7w3U5Hl5l1PTsv/ME2nnFIzm9dNYB3Qc/wyU9Cy+cF+jMRM/K30TeGKbF6MbzZZ\r\nHg0DAQgHwv8AAABtBBgTCAAf/wAAAAWCWKiU2v8AAAAJkNQUrBDFAg1Y/wAAAAKb\r\nDAAAGw4BAJjBytKi/VYMCk63lC6yXO7DSBKUJeX5kmzwjRL8tKmlAQDTB1Ib0Ava\r\n00dJbfg98Jji2bO934c6/mN4CUj0pr1d7Q==\r\n=Y6vR\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n","0.11858526110278289":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgMEVP5a8Yf+2saCjROO0AtEPARapBfL6/kZ\r\nIOKM4+13G3zka3DElLhK/ZgmcWYcvN73dKNMDU2e7DZORAQm+y8XsM3/AAAACDxn\r\naXRodWI+wv8AAACOB
<test></test>
public struct function xmlToJSON(required xml doc) {
var s = {};
var x = arguments.doc
if(xmlGetNodeType(x) == "DOCUMENT_NODE") {
s[structKeyList(x)] = xmlToJson(x[structKeyList(x)]);
} else {
if(structKeyExists(x, "xmlAttributes") && !structIsEmpty(x.xmlAttributes)) {
for(var item in x.xmlAttributes) {
s[item] = x.xmlAttributes[item];
@mavelar
mavelar / lucee_server.xml
Created July 27, 2015 14:16
Sample for Lucee server.xml virtual host configuration and Remote IP fixed
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@mavelar
mavelar / nginx_server.conf
Created July 27, 2015 14:04
Server configuration sample using railo.conf
#
# SERVER / VIRTUAL HOST
# Sample using railo.conf
#
# SERVER INSTANCE / VIRTUAL HOST
server {
listen 80;
server_name yourdomain.tld;
@mavelar
mavelar / railo.conf
Last active December 29, 2017 02:40
railo.conf, is a CFML / nginx connector, can be used by Railo or Lucee on any OS.
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
# Can put some of your own rewrite rules in here
# for example rewrite ^/~(.*)/(.*)/? /users/$1/$2 last;
rewrite ^/(.*)? /index.cfm/$1 last;
rewrite ^ /index.cfm last;
}
@mavelar
mavelar / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console