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
pip install sqlacodegen | |
pip install MySQL-python | |
sqlacodegen mysql://www:www@localhost/db_name |
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
# More information can be found; | |
# - http://dev.mysql.com/doc/refman/5.1/en/load-data.html | |
# - http://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html | |
SET autocommit=0;SET unique_checks=0;SET foreign_key_checks=0; | |
LOAD DATA INFILE IGNORE 'my_data.csv' INTO TABLE my_table | |
COMMIT;SET unique_checks=1;SET foreign_key_checks=1; |
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
#!/usr/bin/env perl | |
use strict 'vars'; | |
use feature qw/say/; | |
my $date_from = &date_to_int( 'Oct', '14', '20', '00', '00'); | |
my $date_to = &date_to_int( 'Oct', '15', '21', '00', '00'); | |
while ( <DATA> ) { | |
chomp; | |
my ($month, $day, $hour, $min, $sec, $server, $msg) = $_ =~ m/(\w+) (\d+) (\d+):(\d+):(\d+) (\w+) (.*)/; |
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
#!/bin/sh | |
# sort on perl subs, can be changed to any other token for any other language | |
TOKEN=sub | |
gsed -e ':a;N;$!ba;s/\n/__newline__/g' "$1" > "$1.out" | |
gsed -i "s/__newline__\\s*$TOKEN\W/\\nsub /g" "$1.out" | |
sort $1.out -o $1.out | |
gsed -i 's/__newline__/\n/g' $1.out |
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
use strict; | |
use feature qw/say/; | |
use POSIX qw(strftime tzset); | |
say strftime("%Y %d %m %H:%M:%S GMT", gmtime(time)); # GMT | |
say strftime("%Y %d %m %H:%M:%S %Z", localtime(time)); # Local Time | |
# Set to custom timezone | |
$ENV{TZ} = 'America/Los_Angeles'; | |
tzset; |
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
#!/usr/bin/env perl | |
use strict; | |
# import LOCK_* and SEEK_END constants | |
use Fcntl qw(:flock SEEK_END); | |
# Open the file | |
open(my $xml, ">>", "sample.xml") or die "Can't open xml $!"; | |
# Lock the file |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
# Determine Context | |
use constant IS_MOD_PERL => exists $ENV{'MOD_PERL'}; | |
use constant IS_PSGI => exists $ENV{'psgi.version'}; | |
use constant IS_CGI => IS_MOD_PERL || IS_PSGI || exists $ENV{'GATEWAY_INTERFACE'}; |
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
#!/bin/sh | |
# Replace filenames found in code and create a backup of original | |
find . -type f \( -name "*.php" -or -name "*.jpg" \) -exec bash -c 'gsed -i.bak "s/(\W`basename {}`\W/)`basename {}`/Ig"/src/ *' \; | |
######################## | |
# Explanation | |
# find | |
# . : Recursively from current directory, | |
# -type f : files only - not folders, |
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
#!/usr/bin/env perl | |
foreach $key (keys(%ENV)) { | |
printf("%-30.30s: $ENV{$key}\n", $key); | |
} |
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
#!/bin/bash | |
watch -n 1 --differences "mysql -u mon -e 'show processlist' | grep -v Sleep" |