Skip to content

Instantly share code, notes, and snippets.

View darkmavis1980's full-sized avatar
🎯
Focusing

Alessio Michelini darkmavis1980

🎯
Focusing
View GitHub Profile
@darkmavis1980
darkmavis1980 / purge_files_from_history
Created May 23, 2018 11:41
Remove node_modules folder from git
# Found it here: https://stackoverflow.com/questions/10067848/remove-folder-and-its-contents-from-git-githubs-history
# Saved this gist as some people really don't understand that you don't have to put node_modules in your bloody repository
git filter-branch --tree-filter 'rm -rf node_modules' --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
echo node_modules/ >> .gitignore
git add .gitignore
git commit -m 'Removing node_modules from git history'
git gc
git push origin master --force
@darkmavis1980
darkmavis1980 / composer-install
Created May 11, 2018 10:56
Composer Install with no platform requirements
composer install --ignore-platform-reqs
@darkmavis1980
darkmavis1980 / git-aliases
Created April 25, 2018 22:27
Git aliases
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd)%Creset %C(bold blue)<%an>%Creset' --date=relative"
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br "branch -vv"
git config --global alias.fa "fetch --all -p"
@darkmavis1980
darkmavis1980 / squashgit
Last active November 28, 2018 14:36
Squash commits
// Squash the number of commits you want, 6 in this example
git reset --mixed HEAD~6
// Stage all the files
git add -A
// Commit the staged files
git commit -m "Your message"
// Then update the remote using --force
git push --force origin <YOUR-BRANCH-NAME>
// Or use rebase
@darkmavis1980
darkmavis1980 / hextorgb.js
Last active April 4, 2018 08:48
HexToRGB in Javascript
// Converts any given HEX color to the relative RGB value
const HexToRGB = hex => hex.match(hex.length === 6 ? /.{2}/g : /.{1}/g).map(color => {
color = hex.length === 3 ? color + color : color;
return parseInt(color, 16);
});
console.log(HexToRGB('FFA955')); //[ 255, 169, 85 ]
console.log(HexToRGB('000000')); //[ 0, 0, 0 ]
console.log(HexToRGB('F00')); //[ 255, 0, 0 ]
@darkmavis1980
darkmavis1980 / confirm_ngClick.txt
Last active August 29, 2015 14:09
Confirm before ng-Click
.directive('ngConfirmClick', [
function(){
return {
priority: -1,
restrict: 'A',
link: function(scope, element, attrs){
element.bind('click', function(e){
var message = attrs.ngConfirmClick;
if(message && !confirm(message)){
e.stopImmediatePropagation();
@darkmavis1980
darkmavis1980 / linuxmount.MD
Last active August 29, 2015 14:07
How to automount partitions on linux

The first thing to do is to get the UUID of the hard drive, just type:

sudo blkid

This will return you a list of your hard drives with the UUID for each ones

/dev/sda1: UUID="206f61f1-a465-4240-935b-eea3c7c10cd9" TYPE="ext4" /dev/sda2: LABEL="Mimas" UUID="1569a3fe-65f0-4641-8eab-7c1f1affb5c2" TYPE="ext4" /dev/sda3: LABEL="Iapetus" UUID="d74de2c8-bc98-4032-8854-901d41f4b1b1" TYPE="ext4" /dev/sda5: UUID="7a375655-f71b-4686-8ac2-c0a260302165" TYPE="swap"

@darkmavis1980
darkmavis1980 / VagrantWindows
Created September 29, 2014 15:59
Vagrant SSH on windows 8
if vagrant ssh doesn't want to work on windows, just type on the terminal
set PATH=%PATH%;C:\Program Files (x86)\Git\bin
and then "vagrant ssh"
@darkmavis1980
darkmavis1980 / jquery.each
Last active August 29, 2015 14:06
Example of the use of .each in jQuery
var $a = [1,2,3,4];
function parseNumber($data){
$.each($data,function(index, value){
console.log(index + ' ' +value);
});
}
parseNumber($a);
/* It will print:
@darkmavis1980
darkmavis1980 / ssl_on_zpanel.txt
Last active July 31, 2017 19:19
SSL on ZPanel
Source from http://blog.arnas.web.id/?p=145 with edits
The following is an simplified how to install SSL Certificate on zPanel. You can use a self-signed SSL Certificate or buy.
First create ssl directory to easy maintain:
$ mkdir /var/zpanel/hostdata/zadmin/ssl
Then go to ssl directory: