Skip to content

Instantly share code, notes, and snippets.

View Mte90's full-sized avatar
🎯
Creating new open source stuff that you will like

Daniele Scasciafratte Mte90

🎯
Creating new open source stuff that you will like
View GitHub Profile
@Mte90
Mte90 / gist:4117ec381a577df04793
Last active August 29, 2015 14:01
Modal in javascript vanilla
View gist:4117ec381a577df04793
//Based on http://jsfiddle.net/i_like_robots/W2DA8/
(function(name, context, definition) {
if (typeof define === 'function' && define.amd) {
define(definition);
}
else if (typeof module !== 'undefined' && module.exports) {
module.exports = definition();
}
else {
@Mte90
Mte90 / script.php
Last active May 21, 2016 22:42
Table from array in PHP
View script.php
<?php
function table_from_array( $cols, $tableclass = 'info' ) {
$content = "<table class=\"" . $tableclass . "\">\n";
$i = 1;
foreach ( $cols as $key => $value ) {
if ( !empty( $value ) ) {
$i++;
if ( $i % 2 === 0 ) {
$content .= "<tr>";
}
@Mte90
Mte90 / ff-check.js
Last active March 23, 2017 12:43
Check if Firefox/Firefox OS/Firefox for Android
View ff-check.js
//With locationbar.visible check if not in a webview (like an open web app)
if (locationbar.visible) {
//mozApps used for the open web app and with the user agent check if have MObile (used in Firefox OS)
if (navigator.userAgent.indexOf('Firefox') > -1 && navigator.userAgent.indexOf("Mobile") > -1) {
//Check Firefox OS
} else if (navigator.userAgent.indexOf('Firefox') > -1 && navigator.userAgent.indexOf("Android") > -1) {
//Check Firefox for Android
} else if (navigator.userAgent.indexOf("Firefox") > -1) {
//Check Firefox Desktop
}
@Mte90
Mte90 / snippet.php
Last active May 22, 2017 13:57
Order array multidimensional using a reference array
View snippet.php
<?php
function sortArrayByArray( $array, $orderArray ) {
$order = array();
foreach ( array_keys( $array ) as $index ) {
foreach ( array_keys( $orderArray ) as $key ) {
$order[ $index ][ $key ] = $array[ $index ][ $key ];
}
}
return $order;
@Mte90
Mte90 / TBTW.csv
Last active January 15, 2018 21:55
PDF Certificate Generator with a csv file
View TBTW.csv
Name Surname email1@email.tld
Name Surname email2@email.tld
Name Surname email3@email.tld
Name Surname email4@email.tld
@Mte90
Mte90 / freemius.php
Created February 21, 2018 13:28
Freemius integration for OpenSupports
View freemius.php
<?php
echo "Parsing Freemius Webhook";
// Get Freemius data
$json = file_get_contents('php://input');
$data = json_decode($json, true);
if( isset($data['objects']['user']) ) {
// Let's call our opensupports instance
$name = $data['objects']['user']['first'] . ' ' . $data['objects']['user']['last'];
@Mte90
Mte90 / Readme.md
Last active June 26, 2018 22:02
Common Voice scripts for italian
View Readme.md

This set of script is used to manipulate the stuff to upload on common voice.

Usually the procedure is to check the sentences, later with prepare_for_pipe.sh is added the pipe for newlines, create_pipe.sh add the pipes and made a counter of the actual status of this strings.

With only_italian.py instead we extract only the sentences for italian to manipulate later after a manual check of every line as example for links.

@Mte90
Mte90 / ffos-check
Last active July 13, 2018 20:45
Check Firefox OS version
View ffos-check
function getVersion() {
if (navigator.userAgent.match(/(mobile|tablet)/i)) {
var ffVersionArray = (navigator.userAgent.match(/Firefox\/([\d]+\.[\w]?\.?[\w]+)/));
if (ffVersionArray.length === 2) {
//Check with the gecko version the Firefox OS version
//Table https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
var hashVersion = {
'18.0': '1.0.1',
'18.1': '1.1',
'26.0': '1.2',
@Mte90
Mte90 / replace-po-wp-to-cp.sh
Last active December 17, 2018 14:49
ClassicPress i18n
View replace-po-wp-to-cp.sh
#!/bin/bash
locale=$1
function replace() {
sed -i.bak s#https://"$1".wordpress.org/forums/#https://forums.classicpress.net/c/support#g /tmp/"$1"-"$2".po
sed -i.bak s/WordPress.org/ClassicPress.net/g /tmp/"$1"-"$2".po
sed -i.bak s/WordPress/ClassicPress/g /tmp/"$1"-"$2".po
}
@Mte90
Mte90 / freemius-to-slack.php
Last active May 31, 2019 01:15
Freemius to slack notification
View freemius-to-slack.php
<?php
// Get Freemius data
$json = file_get_contents('php://input');
$data = json_decode($json, true);
if( isset( $data['objects'] ) ) {
slack($data);
}
function slack($data) {