recentpopularlog in
« earlier   later »
Perl Debug session dies in |
As Professor Tennenbaum warned his Brooklyn College classes, programming languages can be every bit as silly a arbitrary as human languages.
perl  errormessage  programming  language  wisdom 
january 2018
shell - using rot13 and tr command for having an encrypted email address - Stack Overflow |
Not sure exactly how you want to use this, but here's a basic example to get you started:
<code class="language-bash">echo '' | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'</code>

To make it easier, you can alias the tr command in your .bashrc file thusly:
<code class="language-bash">
alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'"

Now you can just call:
<code class="language-bash">
echo '' | rot13

<code class="language-ruby">
$ ruby -ne 'print $ "A-Za-z", "N-ZA-Mn-za-m") ' file

<code class="language-python">
$ echo "test" | python -c 'import sys; print sy...
rot13  textprocessing  oneliner  python  tr  unix  commandline  cli  solution 
january 2018
About the security content of macOS High Sierra 10.13.2, Security Update 2017-002 Sierra, and Security Update 2017-005 El Capitan - Apple Support |

Available for: macOS High Sierra 10.13.1, macOS Sierra 10.12.6, OS X El Capitan 10.11.6

Impact: An application may be able to read kernel memory

Description: Systems with microprocessors utilizing speculative execution and indirect branch prediction may allow unauthorized disclosure of information to an attacker with local user access via a side-channel analysis of the data cache.

CVE-2017-5754: Jann Horn of Google Project Zero, Werner Haas and Thomas Prescher of Cyberus T...
macos  kernel  security  update  meltdown 
january 2018
python - 'too many values to unpack', iterating over a dict. key=>string, value=>list - Stack Overflow |
I ran into this problem with Flask-Admin ( and the issue was some breaking change in some API in SQLAlchemy 1.2.0 that returned a 3-element instead of a two-element tuple.
python  errormessage  dictionary  syntax  maybesolution 
january 2018
How to Install MariaDB on CentOS 7 |
If you try to install 'mysql-server' you'll get this error:
Transaction check error:
file /usr/lib64/mysql/plugin/ from install of mariadb-galera-server-1:5.5.37-2.el7.x86_64 conflicts with file from package mariadb-libs
file /usr/lib64/mysql/plugin/ from install of mariadb-galera-server-1:5.5.37-2.el7.x86_64 conflicts with file from packag
e mariadb-libs-1:5.5.56-2.el7.x86_64

The solution is to just install 'mariadb-server' right off the bat.
mysql  mariadb  dba  installation  howto  centos  centos7  sysadmin  errormessage  solution 
january 2018
primary key is not shown in ModelView · Issue #52 · flask-admin/flask-admin |
Need to find a way of making a primary key field *optional*, and making it non-editable in the "edit" form.

This works to hide it from the create / edit forms entirely (making it non-required upon form submission):
Flask-Admin manages create and edit forms separately.

You can override get_edit_form:

And do something like:
<code class="language-python">
class MyView(ModelView):
def get_edit_form(s...
flask-admin  watchthisspace  maybesolution  needshelp 
january 2018
Freezing Rows or Columns as Headers - LibreOffice Help |
Select the row below, or the column to the right of the row or column that you want to be in the frozen region. All rows above, or all columns to the left of the selection are frozen.
annoyance  libreoffice  spreadsheet  calc  solution 
january 2018
shell - Is there a simple command for outputting tab-delimited columns? - Unix & Linux Stack Exchange |
usually use the column program for this, it's in a package called bsdmainutils on Debian:
<code class="language-bash">
column -t foo


case elems meshing nlsys
uniform 2350 0.076662 2.78
non-conformal 348 0.013332 0.55
scale 318 0.013333 0.44
smarter 504 0.016666 0.64
submodel 360 .009999 0.40
unstruct-quad 640 0.019999 0.80
unstruct-tri 1484 0.01 0.88

Excerpt from column(1) on my system:


-t Determine the number of columns the input contains and create a
table. Columns are delimited with whitespace, by default, or
with the characters supplied using the -s option. Useful for
pretty-printing displays.

shellscripting  tabdelimited  tsv  delmiited  textprocessing  dammitbrain 
december 2017
PEP 397 -- Python launcher for Windows |
See also:

Basically: put the Python interpreter version in the shebang to specify which version your scripts need, and you can run 'py -2' to get the Python 2.x version if you have both installed.
python  windows  fileassociations  shebang  scripting 
december 2017
Passing FieldName as Parameter in MySQL Stored Procedure - Stack Overflow |
You can use prepared statements, for example -

<code class="language-sql">
CREATE `VSK_Comments_UpdateAction`(IN FieldName varchar(30),IN FieldValue tinyint,CID bigint)
SET @query = CONCAT('Update comments Set ', FieldName, '=? WHERE commentid=?');
PREPARE stmt FROM @query;
SET @FieldValue = FieldValue;
EXECUTE stmt USING @FieldValue, @CID;
sql  mysql  procedure  syntax  dba  solution 
december 2017
How can I shortern my command line prompt's current directory?
It doesn't work on OSX with bash as shipped from Apple (I'm on Mountain Lion). The shipped version is 3.2.48(1)-release. If you install the latest bash using something like Homebrew, you'll get something in the neighborhood of 4.2.45(2)-release, which does support PROMPT_DIRTRIM.
Downside: It depends on the directory level, not the length of the path, which you might not want.

Upside: It's very simple. Just add export PROMPT_DIRTRIM=2 to your .bashrc.
bash  promptstring  bashrc  configfile  tipsandtricks  movein  solution 
december 2017
MySQL Bugs: #72663: MySQL Workbench 6.1.4 error when open MySQL Utilities. |
How to fix.

In file: /usr/lib/mysql-workbench/modules/
should replace line:
for term in ["gnome-terminal", "konsole", "xterm", "rxvt"]:
to line:
for term in ["gnome-terminal", "konsole", "xterm", "rxvt", "xfce4-terminal"]:
mysql  workbench  bug  ubuntu  16.04  elementaryos  loki  solution 
december 2017
mysql - Why don't my .my.cnf settings work? - Database Administrators Stack Exchange |
So after a bit of research, I found this link ( and came up with the following ~/.my.cnf that worked for me:

password = mypass
database = dbname
host =

and the command that reads it:

<code class="language-bash">
mysql --defaults-group-suffix=dbid

A couple things to point out (highlights from the article linked):

* group has to be preceded by 'client' to be read by mysql

* has to go after any [client] groups, otherwise it will be overridden
dba  mysql  configfile  tipsandtricks 
december 2017
Add a new element to an array without specifying the index in Bash - Stack Overflow |
Yes there is:
<code class="language-bash">

Bash Reference Manual:

In the context where an assignment statement is assigning a value to a shell variable or array index (see Arrays), the += operator can be used to append to or add to the variable's previous value.

Note that this only works with sequential indices, though...
it's important to note whether the array starts at zero and is sequential. Since you can make assignments to and unset non-contiguous indices ${#array[@]} is not always the next item at the end of the array.
<code class="language-bash">
$ array=(a b c d e f g h)
$ array[42]="i"
$ unset array[2]
$ unset array[3]
$ declare -p array # dump the array so we can see what it contains
declare -a array='([0]="a" [1]="b" [4]="e" [5]="f" [6]="g" [7]="h" [42]="i")'
$ echo ${#array[@]}
$ echo ${array[${#array[@]}]}

Here's how to get the last index:
<code class="language-bash">
$ end=(${!array[@]}) # put all the indices in an array
$ end=${end[@]: -1} # get the last one
$ echo $end

That illustrates how to get the last element of an array. You'll often see this:
<code class="language-bash">
$ echo ${array[${#array[@]} - 1]}

As you can see, because we're dealing with a sparse array, this isn't the last element. This works on both sparse and contiguous arrays, though:
<code class="language-bash">
$ echo ${array[@]: -1}
bash  array  subscript  syntax  newbie  solution  dammitbrain 
december 2017
perlfaq5 - Files and Formats - |

Whenever you see someone do this:
<code class="language-perl">my @lines = <INPUT>;</code>

You should think long and hard about why you need everything loaded at once. It's just not a scalable solution.

If you "mmap" the file with the File::Map module from CPAN, you can virtually load the entire file into a string without actually storing it in memory:
<code class="language-perl">
use File::Map qw(map_file);
map_file my $string, $filename;

Or you can read the entire file contents into a scalar like this:
<code class="language-perl">
my $var;
local $/;
open my $fh, '<', $file or die "can't open $file: $!";
$var = <$fh>;

That temporarily undefs your record separator, and will automatically close the file at block exit. If the file is already open, just use this:
<code class="language-perl">
my $var = do { local $/; <$fh> };
perl  filehandle  inputoutput  newbie  dammitbrain  solution 
december 2017
python - Getting the docstring from a function - Stack Overflow |
For me, I think I was looking for '__module__.__doc__.strip()', which does about the same as below, without an extra import.
You can also use inspect.getdoc. It cleans up the __doc__ by normalizing tabs to spaces and left shifting the doc body to remove common leading spaces.
python  docstring  documentation  tipsandtricks  solution 
december 2017
« earlier      later »
per page:    204080120160

Copy this bookmark:

to read