Skip to content

Instantly share code, notes, and snippets.

View casgin's full-sized avatar

Gianfranco Castro casgin

View GitHub Profile
@casgin
casgin / index.js
Created February 2, 2018 23:09
File di Vuex store/index.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const state = {
isLogged: !!localStorage.getItem('token')
}
const mutations = {
@casgin
casgin / Login.vue
Last active February 2, 2018 23:07
Componente di Login
<template>
<!-- Form Bootstrap 4 e clic su Login -->
</template>
<script>
import router from '@/router'
import store from '@/store'
export default {
name: 'login',
@casgin
casgin / in-browser-babel.html
Created January 8, 2018 16:54
Esempio transpilazione in-browser con Babel
<!DOCTYPE html>
<html>
<head>
<!-- Includo il transpiler in-browser -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<!-- Imposto il type in "text/babel" -->
<script type="text/babel">
// === Dichiaro una funzione con inizializzazione dei parametri
@casgin
casgin / MainActivity.java
Last active October 5, 2017 12:30
Esempio di tutte le callback del ciclo di vita di una Activity
package com.gcastro.primaapplicazione;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@casgin
casgin / app.php
Last active September 27, 2017 09:51
Laravel 5.4 Multi Environment
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
@casgin
casgin / egistranuovoutente.js
Last active June 21, 2017 21:31
[Laramind:Lezione7] Codice del controller per registrare un nuovo utente
'use strict';
/**
* @ngdoc function
* @name lezione6App.controller:RegistranuovoutenteCtrl
* @description
* # RegistranuovoutenteCtrl
* Controller of the lezione6App
* Path: app/scripts/controllers/registranuovoutente.js
*/
@casgin
casgin / codemaster-javascript-base-soluzione-domanda-10.js
Created November 2, 2016 13:15
[TAG Codemaster] Modulo Javascript base: Soluzione alla domanda 10
function sommatoria(arNumeri)
{
var totale = 0;
for(var i=0; i<arNumeri.length; i++)
{
totale += arNumeri[i];
}
return totale;
}
@casgin
casgin / codemaster-javascript-base-soluzione-domanda-11.js
Created November 2, 2016 13:07
[TAG Codemaster] Modulo Javascript base: Soluzione alla domanda 11
/**
* Created by gcastro on 02/11/16.
*/
var Persona = function()
{
// --- Elenco delle proprieta
this.Nome = '';
this.Cognome = '';
@casgin
casgin / smau2016-css-lazy-loading.js
Last active October 23, 2016 14:28
Caricamento lady loading di CSS
// === Creazione del tag link
var css_tag=document.createElement("link");
css_tag.setAttribute("rel", "stylesheet");
css_tag.setAttribute("type", "text/css"); c
ss_tag.setAttribute("href", filename);
// === Inserimento nel DOM
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(css_tag);
// -------------------------------------------------------
@casgin
casgin / smau2016-javascript-lazy-loading.js
Last active October 23, 2016 14:25
Esempio caricamento asincrono di Javascript, via Javascript
// === Creo il tag script e aggiungo il file da scaricare
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src", "/js/javascript-code.js");
// === Configurazione funzione di callback di caricamento avvenuto
if (script_tag.readyState) {
script_tag.onreadystatechange = function () {
// For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {