Skip to content

Instantly share code, notes, and snippets.

@fulippo
fulippo / leaders.py
Last active August 23, 2019 10:10
Find leaders in array
#!/usr/bin/env python
numbers = [16, 17, 4, 3, 5, 2]
leaders = []
for i, n in enumerate(numbers):
remaining = numbers[i+1:]
if len(remaining) == 0 or n > max(remaining):
leaders.append(n)
@fulippo
fulippo / functions.php
Created June 1, 2018 14:46
Fix Gravity Forms Captcha
// This action should be inside add_actions
/**
* Remove Gravityforms captcha action
* This is a fix to prevent interferences from commonLib.js
*/
add_action('get_footer', function(){
global $wp_filter;
foreach($wp_filter['wp_footer']->callbacks as $priority => $hooks){
foreach($hooks as $k => $hook){
@fulippo
fulippo / .htaccess
Last active September 9, 2016 13:50
Htaccess and php file to debug system variables
RewriteEngine On
RewriteBase /
RewriteRule .* - [E=INFO_API_VERSION:%{API_VERSION},NE]
RewriteRule .* - [E=INFO_AUTH_TYPE:%{AUTH_TYPE},NE]
RewriteRule .* - [E=INFO_CONTENT_LENGTH:%{CONTENT_LENGTH},NE]
RewriteRule .* - [E=INFO_CONTENT_TYPE:%{CONTENT_TYPE},NE]
RewriteRule .* - [E=INFO_DOCUMENT_ROOT:%{DOCUMENT_ROOT},NE]
RewriteRule .* - [E=INFO_GATEWAY_INTERFACE:%{GATEWAY_INTERFACE},NE]
RewriteRule .* - [E=INFO_HTTPS:%{HTTPS},NE]
RewriteRule .* - [E=INFO_HTTP_ACCEPT:%{HTTP_ACCEPT},NE]
@fulippo
fulippo / gist:7486b1c5fe7683831b0a
Created March 21, 2016 10:56
Retrieve config from AWS during deploy
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
{
"name": "company/wp-unit-tests",
"type": "wordpress-plugin",
"require": {
"phpunit/phpunit": "~5.0.6"
},
"autoload": {
"psr-4": {"company\\Tests\\": "src/"},
"files": ["src/functions.php"]
}
<!-- Start of Brightcove Player -->
<div style="display:none">
</div>
<!--
By use of this code snippet, I agree to the Brightcove Publisher T and C
found at https://accounts.brightcove.com/en/terms-and-conditions/.
-->
@fulippo
fulippo / gist:cce6ee726e68ce9b7b77
Last active August 29, 2015 14:26
Check status code of URL taken from text file
#!/bin/bash
while read LINE; do
curl -o /dev/null --silent --head --write-out '%{http_code}' "$LINE"
echo " $LINE"
done < url-list.txt
@fulippo
fulippo / gist:357bb775b676ee073e0a
Last active August 18, 2018 08:48
Convert coords from Google Maps (WGS-84) to Baidu Maps (BD-09)
/**
* Convert longitude and latitude from standard WGS-84 system
* to Baidu's BD-09
*
* @see http://stackoverflow.com/a/29512814/718811 for a detailed
* description of the problem.
*
* @param float lng Longitude
* @param float lat Latitude
* @return object Converted coords
@fulippo
fulippo / gist:8c7643670f841cc2aaca
Created April 14, 2015 11:41
Calcolo esadecimale
Valore * base^posizione da destra + Valore * base^posizione da destra ....
es. 0xAF
F * 16^0 + A * 16^1
diventa
15 * 16^0 + 10 * 16^1
diventa
15 + 160
@fulippo
fulippo / web.config
Created September 18, 2014 14:20
WordPress web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json"/>
<mimeMap fileExtension=".ejs" mimeType="application/javascript"/>
</staticContent>
<rewrite>
<rules>
<rule name="Imported Rule 1"><match url="^(.+)\.(.+)\.(js|css)$" ignoreCase="false"/>