Skip to content

Instantly share code, notes, and snippets.

View florentdestremau's full-sized avatar

Florent Destremau florentdestremau

View GitHub Profile
@florentdestremau
florentdestremau / git-aliases-for-bash.sh
Created July 3, 2024 07:30
The list of git alises from Oh My Zsh but ported to bash. You can paste this in your .bashrc or include it from elsewhere
function _omb_prompt_git {
command git "$@"
}
function _omb_prompt_git_status_enabled {
[[ $(_omb_prompt_git config --get-regexp '^(oh-my-zsh|bash-it|oh-my-bash)\.hide-status$' |
awk '$2== "1" {hide_status = 1;} END { print hide_status; }') != "1" ]]
}
# # Note: The same name of a functionis defined in omb-prompt-base. We comment
@florentdestremau
florentdestremau / post-omakub-install.sh
Last active May 14, 2025 10:38
custom omakub version
# shell
sudo apt -y install libnss3-tools
# Adding aliases if they don't already exist
grep -q "alias s=" ~/.bashrc || echo 'alias s="symfony"' >> ~/.bashrc
grep -q "alias sc=" ~/.bashrc || echo 'alias sf="symfony console"' >> ~/.bashrc
grep -q "alias mi=" ~/.bashrc || echo 'alias mi="sf doctrine:migrations:migrate -n"' >> ~/.bashrc
grep -q "alias cc=" ~/.bashrc || echo 'alias cc="sf cache:clear"' >> ~/.bashrc
grep -q "alias st=" ~/.bashrc || echo 'alias st="git status"' >> ~/.bashrc
grep -q "alias t=" ~/.bashrc || echo 'alias t="lazygit"' >> ~/.bashrc
# for framework
sudo apt update && sudo apt upgrade -y && sudo snap refresh && echo "options snd-hda-intel model=dell-headset-multi" | sudo tee -a /etc/modprobe.d/alsa-base.conf && gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']" && sudo sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT.*/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash module_blacklist=hid_sensor_hub nvme.noacpi=1"/g' /etc/default/grub && sudo update-grub && echo "[connection]" | sudo tee /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf && echo "wifi.powersave = 2" | sudo tee -a /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
# start clean
sudo apt update && sudo apt -y upgrade && sudo apt -y dist-upgrade
# Basics
sudo apt -y install \
git zsh automake docker.io ca-certificates curl
@florentdestremau
florentdestremau / i18n.js
Created February 18, 2020 15:32
Simple conversion script to import a Symfony-Yaml file into a React-i18n project
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import frYaml from 'js-yaml-loader!../translations/messages.fr.yml';
import enYaml from 'js-yaml-loader!../translations/messages.en.yml';
const splitPlurals = (object) => {
const newObject = {};
Object.keys(object).forEach((key) => {
let elem = object[key];
if (typeof elem === 'object') {
@florentdestremau
florentdestremau / NewPasswordType.php
Last active January 5, 2025 11:57
A simple User authentication setup to copy & paste into your Symfony 3.4 install
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
@florentdestremau
florentdestremau / createswap.sh
Created March 15, 2018 10:45
Create annd activate a 1G swap file on a Digital Ocean ubuntu 16.04
sudo swapon --show
free -h
sudo fallocate -l 1G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
free -h
@florentdestremau
florentdestremau / boxfile.yml
Last active March 9, 2018 11:33
Sample nanobox configuration for a PHP symfony website with node dependencies
run.config:
cache_dirs:
- vendor
- node_modules
engine: php
engine.config:
runtime: php-7.1
extensions:
- pdo_pgsql
- bcmath
@florentdestremau
florentdestremau / install.sh
Last active September 7, 2018 10:19
Initial setup on a thinkpad X260. Manually installing Chrome and Phpstorm aside. Download and run
sudo apt-get update
sudo apt-get upgrade
sudo apt-get -y install git zsh tig curl vim htop vlc tlp tlp-rdw build-essential automake
# Battery management
sudo tlp start
# install node js
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
@florentdestremau
florentdestremau / command.php
Created February 17, 2017 13:58
Simple symfony command to read a csv file in project root
<?php
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$file = $input->getArgument('file');
@florentdestremau
florentdestremau / button.html
Last active January 4, 2017 11:55
Bootstrap hack to make a Confirm / Cancel button group. See the width: 4% -> 4 times the width of the first one
<div class="btn-group btn-group-justified" role="group">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-lg">
&times;
</button>
</div>
<div class="btn-group" role="group" style="width: 4%;">
<button type="button" class="btn btn-success btn-lg btn-block">
Confirm ?
</button>