recentpopularlog in
« earlier   later »
In Florida Recount, Sloppy Signatures Placed Thousands of Ballots in Limbo - The New York Times
The idea that “in 2018 we are still having a conversation” about election staff members analyzing signatures, he added later, “is preposterous in a world that now includes biometrics and block chain.”
elections  voting 
november 2018
Primer on Python Decorators – Real Python |
<code class="language-python">
def repeat(_func=None, *, num_times=2):
def decorator_repeat(func):
def wrapper_repeat(*args, **kwargs):
for _ in range(num_times):
value = func(*args, **kwargs)
return value
return wrapper_repeat

if _func is None:
return decorator_repeat
return decorator_repeat(_func)
python  newbie  language  idiom  decorators  solution 
november 2018
How to pass password to mysql command line - Unix & Linux Stack Exchange |
It doesn't look like you can send a password to 'mysql' on stdin, even though that's where it seems to be expecting it from with the '-p' (no password) option.

So I ended up using the '--defaults-file' option.

Another thing to note is that if the password is blank (null), it looks like you have to use '--password=', because '-p' has no way of knowing that you are giving it a blank password (the shell eats the quoted empty string).
mysql  cli  dba  commandline  pipes  subprocess  python  workaround  solution 
november 2018
python - SQLAlchemy default DateTime - Stack Overflow |
You could use '', but that will calculate a timestamp once per transaction, which may not be what you want.

This probably works fine:

<code class="language-python">
import datetime
from sqlalchemy import Column, Integer, DateTime
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class Test(Base):
__tablename__ = 'test'

id = Column(Integer, primary_key=True)
created_date = Column(DateTime, default=datetime.datetime.utcnow)

python  sqlalchemy  sql  timeanddate  timestamp  dba  solution 
november 2018
perl - How can I set default values using Getopt::Std? - Stack Overflow |
The best thing is to use GetOpt::Long and use a hash instead of individual variables. Then you can pass default values by pre-populating the array
<code class="language-perl">
use Getopt::Long;
my %opts = (parameter => 20);
GetOptions( \%opts,
) or die "Invalid parameters!";
perl  argumentprocessing  shellscripting  getopt  solution 
november 2018
How can I tell if STDIN is connected to a terminal in Perl? - Stack Overflow |
<code class="language-perl">if (-t STDIN) {
# stdin is connected
} else {
# stdin is not connected
perl  devel  stdin  textprocessing  pipes  solution 
november 2018
MySQL :: Re: repair by sorting? |
"Repair by sorting" is MyISAM's way of updating the indexes after a bulk insert. When inserting Millions of rows of data into a MyISAM table, it is normal for the index updates to take longer than the actual inserts.
mysql  dba  errormessage  solution 
november 2018
innodb - Internal reason for killing process taking up long time in mysql - Database Administrators Stack Exchange |
Possible causes: InnoDB takes forever to roll back mass inserts. Also, innodb_buffer_pool_size might've been too small (default is only like 128 MB).
innodb  mysql  performance  optimization  errormessage  itsslow  maybesolution 
november 2018
The binning algorithm is in section 5.3 of the SAM specification (
A note on binning

For small tables like refGene, UCSC simply creates MySQL indices on the chromosomal coordinate of a record. For large tables like snp129, UCSC cacluates a bin number for each record and only indexes chromosome name and the bin number without indexing chromosomal coordinates. Doing in this way is faster than simply relying on the MySQL indices and saves disk space as well. Detailed algorithm can be found in Kent et al. (2002) or from the SAM format specification. You can also read the source code of this script to see how the bin number is calculated and used in query.
binning  mysql  ucsc  genomebrowser  dba  optimization 
november 2018
Index of /bin/linux/ubuntu |
Some people have reported difficulties using this approach. The issue is usually related to a firewall blocking port 11371. If the first gpg command fails, you may want to try (thanks to Mischan Toosarani for the tip):
<code class="language-bash">
gpg --keyserver hkp:// --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

and then feed it to apt-key with
<code class="language-bash">
gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | sudo apt-key add -

Another alternative approach is to search for the key at and copy the key to a plain text file, say key.txt. Then, feed the key to apt-key with
<code class="language-bash">
sudo apt-key add key.txt
r  installation  ubuntu  packages  keyserver  errormessage  workaround  solution 
november 2018
apt - "GPG error:The following signatures were invalid: KEYEXPIRED" - Ask Ubuntu |
That ppa has been removed and no longer exists. You must find a different source for the packages installed through the samrog131 ppa.

In the meantime, run the following commands to resolve the situation.

First, to delete the expired key:
<code class="language-bash">
sudo apt-key del 1436387333

Then, to delete the ppa:
<code class="language-bash">
sudo rm /etc/apt/sources.list.d/samrog131*
sudo apt-get clean
sudo apt-get update

If you need to add a key see here.
<code class="language-bash">
sudo apt-get upgrade

You may want to run:
<code class="language-bash">
sudo apt-get dist-upgrade

depending on your situation. If you are not sure, see here.
ubuntu  apt  packagemanagement  crypto  pubkey  errormessage  solution 
november 2018
linux - How to strip path while archiving with TAR - Stack Overflow
In your "Extraction phase" you can use the strip-components flag like
<code class="language-bash">tar xvf tarname.tar --strip-components=n</code>
tar  archive  decompression  tipsandtricks  commandline  shellscripting  solution 
november 2018
gnu make - makefile: concatenate text with infix operator - Stack Overflow |

Louis is correct: there's no magical way of doing this. But if, instead of trying to remove the last item or treat it specially, you instead treat the first item specially, the work is much simpler to understand (I think); you can create a function combine that takes two arguments: the first is the text to put between the words and the second is a space-separated list of words to combine:
<code class="language-makefile">combine = $(word 1,$2) $(foreach W,$(wordlist 2,$(words $2),$2),$1 $W)</code>

Now you can use it like this:
<code class="language-makefile">$(call combine,-o,$(EXCLUDE_LIST))</code>

to get output like:
<code class="language-">$(BASE_DIR)/aaa* -o $(BASE_DIR)/bbb*</code>
devel  build  toolchain  makefile  stringfunctions  workaround  solution 
november 2018
firebug - Access variables in jsFiddle from Javascript console? - Stack Overflow |
With Firefox (34+) and the new Firefox Developer Edition, it's possibile to do the same by enabling the Select a frame as the currently targeted document extra tool into the developer tools, then click on it and select
jsfiddle  webdevel  console  devtools  jquery  solution 
november 2018
MySQL show status: How to show open database connections | |
<code class="language-bash">
$ mysqladmin status
$ mysql dbname -e "show status like '%onn%';"
$ mysql dbname -e "show processlist;"</code>
mysql  dba  mysqladmin  admin  solution 
november 2018
installation - ImportError: module 'setuptools.dist' has no 'check_specifier' attribute - Stack Overflow |
It was due to older setuptools version. I updated setuptools as follows:
<code class="language-bash">sudo pip install setuptools --upgrade</code>

It installed setuptools-31.0.0 and that worked.
pip  python  centos6  errormessage  packaging  installation  solution 
november 2018
macos - Case-insensitive ls sorting in Mac OSX - Ask Different |
I needed sort's '-V' (version string sort) option, and here's how I got that:
Install the GNU Coreutils package:

sudo port install coreutils
sorting  textprocessing  bsd  mac  osx  shellscripting  workaround  solution 
november 2018
how to display local shell-script/s in browser/firefox? - Unix & Linux Stack Exchange |
The way data is processed in a browser depends on the MIME type declared by the server. If you want your browser to render it as html, which is most likely a terrible idea, you can change the Content-Type header the server returns so that it reflects the type of your data, which would be text/html; charset=utf-8, and the Content-Disposition header to suggest the browser what to do.

My solution was the following (in a '.htaccess'):
<code class="language-apache">
<Files *.sh>
SetEnvIf Request_URI "([^/]+\.sh)" FileName=$1

# ref:
Header set Content-Type "text/plain"

# not needed, and doesn't work alone, since the browser is configured to
# download "application/sh" rather than display it inline; just telling the
# browser it's "text/plain" is enough to achieve the aim
#Header set Content-Disposition "inline; filename=\"%{FileName}e\""
firefox  browser  mimetype  contentdisposition  webmaster  apache  configuration  solution 
november 2018
http headers - How do I force files to open in the browser instead of downloading (PDF)? - Stack Overflow |
To indicate to the browser that the file should be viewed in the browser:
Content-Type: application/pdf
Content-Disposition: inline; filename="filename.pdf"

To have the file downloaded rather than viewed:
Content-Type: application/pdf
Content-Disposition: attachment; filename="filename.pdf"

The quotes around the filename are required if the filename contains special characters such as filename[1].pdf which may otherwise break the browser's ability to handle the response.
httpd  apache  webmaster  headers  contentdisposition  sortof  solution 
november 2018
« earlier      later »
per page:    204080120160

Copy this bookmark:

to read