-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andres Hermosilla
committed
Jul 19, 2017
1 parent
c7aa8c0
commit b6ba1b5
Showing
6 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#!/usr/bin/perl | ||
|
||
# cpan modules were installed say a year ago. If you | ||
# cpan install that same module on another system it | ||
# will be a different version. With cpanm/cpanfile | ||
# you can specify a version. This tool allows you | ||
# to dump a cpanfile compatible formatted output of | ||
# the current environments module versions. | ||
# | ||
# @example output | ||
# requires 'Proc::Daemon', '== 0.14'; | ||
# | ||
# @usage | ||
# To see all modules with version | ||
# ./list_modules.pl | ||
# | ||
# To see a filtered down list | ||
# ./list_modules.pl MongoDB,Beanstalkd,Dumper | ||
# | ||
# @notes | ||
# - use cpanminus! | ||
# `curl -L https://cpanmin.us | perl - --sudo App::cpanminus` | ||
# `cpanm --installdeps .` | ||
# - Another way to see installed modules perldoc perllocal | ||
|
||
use strict; | ||
use ExtUtils::Installed; | ||
|
||
my @filtered = map {split(/,/, $_)} @ARGV; | ||
my $filter_count = scalar @filtered; | ||
|
||
my $inst = ExtUtils::Installed->new(); | ||
my @modules = $inst->modules(); | ||
my %modules_map = map { $_ => 1 } @modules; | ||
|
||
my $file = ''; | ||
my $files; | ||
my $version; | ||
my @matched = (); | ||
|
||
sub add_module_info { | ||
my $module_name = shift; | ||
$version = $inst->version($module_name); | ||
push @matched, "requires '$module_name', '== $version';"; | ||
} | ||
|
||
sub print_list { | ||
my $list_ref = shift; | ||
my @list = sort @{$list_ref}; | ||
|
||
foreach my $match (@list) { | ||
print "$match\n"; | ||
} | ||
} | ||
|
||
sub already_matched { | ||
my $module_name = shift; | ||
my @found = grep(/$module_name/, @matched); | ||
my $matched_x = scalar @found; | ||
return ($matched_x ne 0); | ||
} | ||
|
||
sub is_in_filter { | ||
my $module_name = shift; | ||
foreach my $filter (@filtered) { | ||
if (index($module_name, $filter) != -1) { | ||
return 1; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
foreach my $module (@modules) { | ||
# Checking for filter matches | ||
if ($filter_count gt 0) { | ||
if (!is_in_filter($module)) { | ||
next; | ||
} | ||
} | ||
|
||
add_module_info($module); | ||
} | ||
|
||
# Checking for filter matches | ||
if ($filter_count eq 0) { | ||
print_list(\@matched); | ||
exit 0; | ||
} | ||
|
||
my @missing = (); | ||
|
||
# Post process and make sure to check each module | ||
# name explicitly provided | ||
foreach my $filter (@filtered) { | ||
if (already_matched($filter)) { | ||
next; | ||
} | ||
|
||
my ($module_ns, $submodule) = split(/::/, $filter); | ||
|
||
if (already_matched($module_ns)) { | ||
next; | ||
} | ||
|
||
if(exists($modules_map{$module_ns})) { | ||
add_module_info($module_ns); | ||
} else { | ||
push @missing, "# Missing: requires '$filter', '== x.y.z';"; | ||
} | ||
} | ||
|
||
print_list(\@matched); | ||
print_list(\@missing); | ||
exit 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# git | ||
|
||
- Files changes in a commit | ||
`git diff-tree --no-commit-id --name-only -r c06d5186ed7` | ||
- Last commit files changes | ||
`git rev-parse HEAD | xargs -I {} git diff-tree --no-commit-id --name-only -r {}` | ||
- Current files | ||
`git status -s | grep php | sed 's/^ *//' | cut -d' ' -f2` | ||
- Pipe to lint quickly | ||
`xargs -I {} php -l {}` | ||
`git rev-parse HEAD | xargs -I {} git diff-tree --no-commit-id --name-only -r {} | xargs -I {} php -l {}` | ||
- Php file changes in a merge | ||
`git log -1 --name-only | grep '.php' | xargs -I{} php -l {}` | ||
- Show files changes between branches | ||
`git diff remotes/origin/master remotes/origin/security-tweak --name-only` | ||
- Git show pending merges | ||
`git show-ref | grep merge | cut -d' ' -f1 | xargs -I{} git show {}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# MySql | ||
|
||
**Flags to provide password in file** | ||
`--defaults-file=user_pass.cnf` | ||
`--login-path` | ||
|
||
## Links | ||
- https://speakerdeck.com/samlambert/the-mysql-ecosystem-at-github-2015 | ||
- https://www.percona.com/blog/2017/03/06/mysql-i-am-a-dummy/ | ||
- https://twindb.com/use-proxysql-tools/ | ||
- http://code.openark.org/blog/mysql/whats-so-complicated-about-a-master-failover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# PHP | ||
|
||
|
||
## Code Standards | ||
```shell | ||
composer global require phpmd/phpmd | ||
composer global require "squizlabs/php_codesniffer=*" | ||
phpcs --config-set default_standard PSR | ||
|
||
filename=test.php | ||
|
||
# Use mess detector! | ||
phpmd ${filename} text codesize,unusedcode,naming,design | ||
|
||
# Use Code style checker | ||
phpcs ${filename}` | ||
# To fix fails phpcbf is your friend! | ||
phpcbf ${filename} | ||
``` |