Skip to content

Instantly share code, notes, and snippets.

@pniaps
pniaps / jquery.exists.js
Created December 29, 2015 08:20
jQuery run code if element exists
/**
* Tiny jQuery Plugin
* by Chris Goodchild
* https://css-tricks.com/snippets/jquery/check-if-element-exists/
*
*/
$.fn.exists = function(callback) {
if (this.length) {
var args = [].slice.call(arguments, 1);
callback.call(this, args);
@pniaps
pniaps / index.php
Created January 29, 2016 08:43
Replace domain in wordpress configuration
//Insert here serialized string from wp_options table
$str = '';
function change(&$data)
{
if(is_string($data) && json_decode($data)){
$json = json_decode($data);
if(is_array($json) || is_object($json)){
foreach($json as &$jsonvalue){
change($jsonvalue);
@pniaps
pniaps / validate.js
Created November 25, 2016 13:51
Jquery Validate with suppor to array of fields
if ($.validator) {
//returns all elements, even with the same name (default returns only the first element for each name)
$.validator.prototype.elements = function() {
var validator = this;
// select all valid inputs inside the form (no submit or reset buttons)
return $( this.currentForm )
.find( "input, select, textarea" )
.not( ":submit, :reset, :image, [disabled], [readonly]" )
.not( this.settings.ignore )
@pniaps
pniaps / README.md
Created June 14, 2017 08:39 — forked from mindplay-dk/README.md
ISO 3166-2 Country and State/Region Tables for MySQL
@pniaps
pniaps / TwigRenderer.php
Created July 14, 2017 12:54 — forked from stof/TwigRenderer.php
Rendering twig blocks directly from outside a twig render call, for email purpose
<?php
namespace Incenteev\MailerBundle\Mailer;
class TwigRenderer implements RendererInterface
{
private $twig;
private $styleInliner;
/**
@pniaps
pniaps / setup_server.sh
Last active March 5, 2018 09:04
CentOS 7 httpd - php7 - MariaDB 10.2
yum -y install httpd mod_ssl
systemctl start httpd.service
systemctl enable httpd.service
yum -y install epel-release yum-utils
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php72
yum -y install php php-fpm php-mysql php-mbstring php-dom php-xml php-gd
cat << EOF > /etc/yum.repos.d/MariaDB.repo
@pniaps
pniaps / install_git.sh
Created March 12, 2018 02:34
Install GIT Centos 7
#install git with user
yum install git
adduser git
passwd git
su git
cd
#add public keys to folder and generate autorized keys
mkdir /home/git/.ssh
chmod 700 /home/git/.ssh
cat << 'EOF' > /etc/uci-defaults/reset_wan
#!/bin/sh
(crontab -l ; echo "*/5 * * * * sh /usr/bin/reset_wan") | sort | uniq | crontab -
/etc/init.d/cron start
/etc/init.d/cron enable
exit 0
EOF
chmod +x /etc/uci-defaults/reset_wan
cat << 'EOF' > /usr/bin/reset_wan
@pniaps
pniaps / pc componentes
Last active October 20, 2020 17:41
Ordenar ofertas de pccomponentes por descuento
//https://stackoverflow.com/questions/282670/easiest-way-to-sort-dom-nodes
var list = document.querySelectorAll('.row.page-0');
var items = list[0].childNodes;
var itemsArr = [];
for (var i in items) {
if (items[i].nodeType == 1) { // get rid of the whitespace text nodes
itemsArr.push(items[i]);
}