Skip to content

Instantly share code, notes, and snippets.

View cvsolutions's full-sized avatar
😂
Drogato di tecnologia per passione e per lavoro! :)

Concetto Vecchio cvsolutions

😂
Drogato di tecnologia per passione e per lavoro! :)
View GitHub Profile
@cvsolutions
cvsolutions / Ecco un esempio di codice di un utente che crea un redirect in base alla lingua del browser
Last active May 4, 2023 12:47
Ecco un esempio di codice di un utente che crea un redirect in base alla lingua del browser
<?php
// Funzione per ottenere la lingua del browser
function getBrowserLanguage() {
$langs = array();
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
// divide la stringa in lingue separate
$browserLanguages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
// estrae la lingua principale di ogni lingua
foreach ($browserLanguages as $language) {
@cvsolutions
cvsolutions / Scorrimento del binario infinito nel terminale
Last active February 4, 2021 13:36
Scorrimento del binario infinito nel terminale
echo -e "1"; while $t; do for i in `seq 1 30`;do r="$[($RANDOM % 2)]";h="$[($RANDOM % 4)]";if [ $h -eq 1 ]; then v="0 $r";else v="1 $r";fi;v2="$v2 $v";done;echo -e $v2;v2="";done;
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
# redirect everything to url without trailing slash
RewriteCond %{HTTPS} =on
RewriteRule ^(.+)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.+)$ - [env=ps:http]
@cvsolutions
cvsolutions / GetHourDiff
Created July 2, 2018 13:59
[Javascript] Differenza tra ore hh:mm
function GetHourDiff(pStartHour, pEndHour) {
var res = "";
var aTmp="";
//Trasformo l'orario di inizio in minuti
aTmp=pStartHour.split(":");
var nStartMin = (Number(aTmp[0]) * 60) + Number(aTmp[1]);
//Trasformo l'orario di fine in minuti
aTmp=pEndHour.split(":");
var nEndMin = (Number(aTmp[0]) * 60) + Number(aTmp[1]);
//Calcolo la differenza
@cvsolutions
cvsolutions / atom-setup
Last active April 21, 2017 07:49
Configuration, packages and settings. ⚛️
Packages make Atom do amazing things.
- https://atom.io/packages/sync-settings
- https://atom.io/themes/native-ui
- https://atom.io/packages/file-icons
- https://atom.io/packages/atom-wrap-in-tag
- https://atom.io/packages/var-that-color
- https://atom.io/packages/minimap-cursorline
- https://atom.io/packages/color-picker
@cvsolutions
cvsolutions / .git-completion.bash
Last active September 24, 2016 13:15
Completion support for core Git.
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
[alias]
# Show verbose output about tags, branches or remotes
tags = tag -l
branches = branch -a
remotes = remote -v
# Pretty log output
hist = log --graph --pretty=format:'%Cred%h%Creset %s%C(yellow)%d%Creset %Cgreen(%cr)%Creset [%an]' --abbrev-commit --date=relative
[color]
# Use colors in Git commands that are capable of colored output when outputting to the terminal
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # OS X `ls`
colorflag="-G"
fi
# List all files colorized in long format
alias ll='ls -lh'
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
# Screenshot: http://i.imgur.com/s0Blh.png
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi