Skip to content

Instantly share code, notes, and snippets.

View sentenza's full-sized avatar

Alfredo Torre sentenza

View GitHub Profile
@sentenza
sentenza / scala-2.11-8_sbt-13.15.sh
Last active August 30, 2018 02:15 — forked from nmfzone/gist:2dc02fb73f30c47faf39005bd21d6331
Install Scala 2.12.2 and sbt 0.13.15 - Ubuntu 16.10 Yakkety
# Scala Installation
wget https://downloads.lightbend.com/scala/2.12.2/scala-2.12.2.deb
sudo dpkg -i scala-2.12.2.deb
# sbt Installation
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get install sbt
@sentenza
sentenza / sequence-increment.scala
Created February 26, 2017 00:24
A recursive way to increment a sequence of Integers - which are in fact Digits [0 ... 9].
/** Given a Sequence of Integers Seq(2, 3, 4) - which represents the number 234 base 10 - increments
* by one without converting types.
*
* @param s Seq[Int] The original sequence representation of the number
* @return The incremented by one Sequence
*/
def sequenceIncrement(s: Seq[Int]): Seq[Int] = {
sequenceIncrementRec(s.reverse, Seq.empty, carry = true).reverse
}
#Module dependencies
# mod_rewrite
# mod_ssl
# This section is only needed if you want to redirect http traffic to https.
# You can live without it but clients will have to type in https:// to reach gitlab.
<VirtualHost *:80>
ServerName domain.com
ServerSignature Off
@sentenza
sentenza / networkmanager-wifi-powersave.md
Created January 22, 2017 10:01 — forked from jcberthon/networkmanager-wifi-powersave.md
NetworkManager Wi-Fi powersaving configuration

NetworkManager WiFi Power Saving

NetworkManager supports WiFi powersaving but the function is rather undocumented.

From the source code: wifi.powersave can have the following value:

  • NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
  • NM_SETTING_WIRELESS_POWERSAVE_IGNORE (1): don't touch existing setting
  • NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
@sentenza
sentenza / symfony3_upgrade.md
Last active January 23, 2017 15:13
How to upgrade from Symfony2 to Symfony3

Before updating to Symfony 3

General fixes

You need to launch this Symfony2 version fixer.

Security context fix

Then you have to change every occurrency of security.context with security.token_storage (see also this SO answer http://stackoverflow.com/a/29672308/1977778). You must update your codebase to match the security component improvements of version 2.6, as described here.

@sentenza
sentenza / symfony_doctrine_merge.md
Last active June 28, 2020 14:07
How to deal with Symfony and doctrine merge

You should use merge operation on entities which are in detached state and you want to put them to managed state.

Merging should be done like this $entity = $em->merge($detachedEntity). After that $entity refers to the fully managed copy returned by the merge operation. Therefore if your $form contains detached entities, you should adjust your code like this:

$doctrineManager = $this->getDoctrine()->getManager();
foreach ($form->getData()->getEntities() as $detachedEntity) {
    $entity = $doctrineManager->merge($detachedEntity);  
    $doctrineManager->remove($entity);
}

$doctrineManager->flush();

@sentenza
sentenza / KeyConcepts.md
Created December 7, 2016 08:12
Progressive Web Apps (PWA)

What's a Progressive Web App?

  • Obviously, no install required
  • It loads quickly, even on flaky networks
  • Can send push notifications
  • May have an icon on the home screen (loading as a top-level)
  • Should support full-screen mode

Key features

@sentenza
sentenza / StartWithReactJS.md
Last active October 26, 2016 14:51
All the information that really matters to learn and user ReactJS at glance

React logo

Fundamental concepts

  • JSX: Allows us to write HTML like syntax which gets transpiled to lightweight JavaScript objects, thus being much more concise than pure old JS
  • Virtual DOM: A JavaScript representation of the actual DOM
  • React.createClass(): The way in which you create a new component
  • render(): Each component has to have this method in order to be rendered
  • ReactDOM.render: Renders a React component to a DOM node.
  • state: The internal data store (object) of a component. Each component has the ability to manage its own state and pass its state down to child components if needed.

Firebase transactions: the state of the art

Let's start sayng that Firebase «has always supported updating multiple children of a node atomically», as described in [1]. But, what happens when you have two sibling nodes to update and you want to be absolutely sure of the atomicity of the writing process.

The ACID problem stands in front of you, little padawan

A common problem is to be ACID in a World of Key-values NoSQL.

@sentenza
sentenza / 00_Symfony_DoctrineExtensions_Translation.md
Last active January 22, 2017 10:01
Symfony and StofDoctrineExtensionsBundle - Gedmo Translatable

How to translate with Symfony in the safest way

  1. Follow the installation guide reported here: https://symfony.com/doc/master/bundles/StofDoctrineExtensionsBundle/index.html
  2. Further information about the installation of the base library (Gedmo) https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/symfony2.md
  3. Configuring the Translatable extension: https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/translatable.md

And then you need to configure per bundle extension adding the neeeded schema on database as reported in create_ext_translations_postgres.sql.

Enabling Gedmo per mapping inside config.yml