Skip to content

Instantly share code, notes, and snippets.

View GianfrancoFrau's full-sized avatar
🌱
growing up

Gianfranco Frau GianfrancoFrau

🌱
growing up
View GitHub Profile
const flattenObject = (obj, final, prefix) => {
Object.keys(obj).map((prop) => {
const current = obj[prop];
const p = prefix ? prefix + '.' + prop : prop;
if (typeof current !== "object") {
final[p] = current;
} else if (Array.isArray(current)) {
final[p] = JSON.stringify(current);
} else {
return flattenObject(current, final, p);
@GianfrancoFrau
GianfrancoFrau / delete_zero_tags.php
Last active February 19, 2024 14:31
[Wordpress delete 0 tags]
<?php
function delete_zero_tags() {
$tags = get_terms( array(
'taxonomy' => 'post_tag',
'hide_empty' => false,
));
if ( !empty($tags) && !is_wp_error($tags) ) {
foreach ( $tags as $tag ) {
@GianfrancoFrau
GianfrancoFrau / msToTime.js
Last active January 25, 2024 20:12
msToTime.js
function msToTime(duration) {
var milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
@GianfrancoFrau
GianfrancoFrau / plink-plonk.js
Created February 24, 2020 12:58 — forked from tomhicks/plink-plonk.js
Listen to your web pages
@GianfrancoFrau
GianfrancoFrau / index.html
Created February 14, 2017 10:43 — forked from martinsik/index.html
Simple WebSocket server based on libwebsockets. For full description read http://martinsikora.com/libwebsockets-simple-websocket-server
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
window.WebSocket = window.WebSocket || window.MozWebSocket;
var websocket = new WebSocket('ws://127.0.0.1:9000',
@GianfrancoFrau
GianfrancoFrau / static_server.js
Created December 15, 2016 10:55 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@GianfrancoFrau
GianfrancoFrau / curl.sh
Created July 12, 2016 09:11 — forked from davimacedo/curl.sh
Example of importing data with cloud functions
curl -X POST \
-H "X-Parse-Application-Id: LL9oIdzIkmwl5xyowQQu0fTmXyUWfet9RuAzwHfj" \
-H "X-Parse-REST-API-Key: R3S8PYQKuzeV4c8MUeO5ved46C50MEp56boDHW1O" \
-H "Content-Type: application/json" \
-d @data.json \
https://parseapi.back4app.com/functions/import
var gulp = require('gulp');
var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var bases = {
app: 'app/',
@GianfrancoFrau
GianfrancoFrau / release.sh
Created April 10, 2016 22:18 — forked from edorgeville/release.sh
Creates a signed and zipaligned APK from your Ionic project
#!/bin/bash
#
# Creates a signed and zipaligned APK from your Ionic project
#
# Place your keystore in the root of your project and name it <company>.keystore
# Use this script as following :
# $ ./release.sh [company] [version]
#
# Don't forget to gitignore your key and your compiled apks.
#
@GianfrancoFrau
GianfrancoFrau / node-and-npm-in-30-seconds.sh
Last active September 21, 2015 22:44 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh