recentpopularlog in
« earlier   later »
Perl Debug session dies in Heavy.pm | http://forums.devshed.com/
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 | https://stackoverflow.com/
Not sure exactly how you want to use this, but here's a basic example to get you started:
<code class="language-bash">echo 'fooman@example.com' | 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]'"
</code>

Now you can just call:
<code class="language-bash">
echo 'fooman@example.com' | rot13
</code>

Ruby(1.9+)
<code class="language-ruby">
$ ruby -ne 'print $_.tr( "A-Za-z", "N-ZA-Mn-za-m") ' file
</code>

Python
<code class="language-python">
$ echo "test" | python -c 'import sys; print sy...
</code>
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 | https://support.apple.com/
Kernel

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 | https://stackoverflow.com/
I ran into this problem with Flask-Admin (https://github.com/flask-admin/flask-admin/issues/1583) 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 | https://linode.com/
If you try to install 'mysql-server' you'll get this error:
Transaction check error:
file /usr/lib64/mysql/plugin/dialog.so from install of mariadb-galera-server-1:5.5.37-2.el7.x86_64 conflicts with file from package mariadb-libs
-1:5.5.56-2.el7.x86_64
file /usr/lib64/mysql/plugin/mysql_clear_password.so 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 | https://github.com/
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: https://github.com/mrjoes/flask-admin/blob/master/flask_admin/model/base.py#L570

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 | https://help.libreoffice.org/
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 | https://unix.stackexchange.com/
usually use the column program for this, it's in a package called bsdmainutils on Debian:
<code class="language-bash">
column -t foo
</code>

Output:
<code>

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
</code>

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 | Python.org
See also: https://docs.python.org/3/using/windows.html#launcher

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 | https://stackoverflow.com/
You can use prepared statements, for example -

<code class="language-sql">
CREATE `VSK_Comments_UpdateAction`(IN FieldName varchar(30),IN FieldValue tinyint,CID bigint)
BEGIN
SET @query = CONCAT('Update comments Set ', FieldName, '=? WHERE commentid=?');
PREPARE stmt FROM @query;
SET @FieldValue = FieldValue;
SET @CID = CID;
EXECUTE stmt USING @FieldValue, @CID;
DEALLOCATE PREPARE stmt;
END;
</code>
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. | https://bugs.mysql.com/
How to fix.

In file: /usr/lib/mysql-workbench/modules/wb_utils_grt.py
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 | https://dba.stackexchange.com/
So after a bit of research, I found this link (http://datacharmer.blogspot.com/2011/03/hidden-options-file-trick.html) and came up with the following ~/.my.cnf that worked for me:

<code>
[clientdbid]
password = mypass
database = dbname
host = server.location.com
</code>

and the command that reads it:

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

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 | https://stackoverflow.com/
Yes there is:
<code class="language-bash">
ARRAY=()
ARRAY+=('foo')
ARRAY+=('bar')
</code>

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[@]}
7
$ echo ${array[${#array[@]}]}
h
</code>

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
42
</code>

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

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}
i
</code>
bash  array  subscript  syntax  newbie  solution  dammitbrain 
december 2017
perlfaq5 - Files and Formats - metacpan.org | https://metacpan.org/

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;
</code>

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>;
}
</code>

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> };
</code>
perl  filehandle  inputoutput  newbie  dammitbrain  solution 
december 2017
python - Getting the docstring from a function - Stack Overflow | https://stackoverflow.com/
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