recentpopularlog in

kme : dammitbrain   356

« earlier  
grub2 - How to get to the GRUB menu at boot-time? - Ask Ubuntu |
Menu will appear if you press and hold Shift during loading Grub, if you boot using BIOS. When your system boots using UEFI, press Esc.

For permanent change you'll need to edit your /etc/default/grub file -- place a "#" symbol at the start of line GRUB_HIDDEN_TIMEOUT=0.

Save changes and run sudo update-grub to apply changes.

grub  bootmanager  dammitbrain  solution 
14 days ago by kme
upstart - How to enable or disable services? - Ask Ubuntu
(FOR UPSTART) To toggle a service from starting or stopping permanently you would need to:
<code class="language-bash">echo manual | sudo tee /etc/init/SERVICE.override</code>
upstart  systemd  ubuntu  centos  linux  sysadmin  dammitbrain  solution 
4 weeks ago by kme
Creating a package.json file | npm Documentation
<code class="language-json">{
"name": "my-awesome-package",
"version": "1.0.0"

<code class="language-bash">npm init</code>
webdevel  javascript  npm  packaging  dammitbrain  solution 
5 weeks ago by kme
escaping double quotes and percent signs (%) in cron - Server Fault
You have to escape the % signs. They have a special meaning in crontabs:
cron  crontab  shellscripting  sysadmin  dammitbrain  solution 
12 weeks ago by kme
PEP 440 -- Version Identification and Dependency Specification |
For a given release identifier V.N, the compatible release clause is approximately equivalent to the pair of comparison clauses:

>= V.N, == V.*

This operator MUST NOT be used with a single segment version number such as ~=1.

For example, the following groups of version clauses are equivalent:

~= 2.2
>= 2.2, == 2.*

~= 1.4.5
>= 1.4.5, == 1.4.*
python  pip  semver  packaging  versionpinning  pinning  versioning  dependency  reference  dammitbrain 
october 2019 by kme
Getting Started With setuptools and — an_example_pypi_project v0.0.5 documentation
<code class="language-python">import os
from setuptools import setup

# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

name = "an_example_pypi_project",
version = "0.0.4",
author = "Andrew Carter",
author_email = "",
description = ("An demonstration of how to create, document, and publish "
"to the cheese shop a5"),
license = "BSD",
keywords = "example documentation tutorial",
url = "",
packages=['an_example_pypi_project', 'tests'],
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"License :: OSI Approved :: BSD License",
python  install  setuptools  packaging  template  dammitbrain 
october 2019 by kme
editor - Disabling swap files creation in vim - Stack Overflow
Set the following variables in .vimrc or /etc/vimrc to make vim put swap, backup and undo files in a special location instead of the working directory of the file being edited:

<code class="language-viml">set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
set undodir=~/.vim/undo//</code>

Using double trailing slashes in the path tells vim to enable a feature where it avoids name collisions. For example, if you edit a file in one location and another file in another location and both files have the same name, you don't want a name collision to occur in ~/.vim/swap/. If you specify ~/.vim/swap// with two trailing slashes vim will create swap files using the whole path of the files being edited to avoid collisions (slashes in the file's path will be replaced by percent symbol %).

For example, if you edit /path/one/foobar.txt and /path/two/foobar.txt, then you will see two swap files in ~/.vim/swap/ that are named %path%one%foobar.txt and %path%two%foobar.txt, respectively.
vim  swapfile  backupfile  settings  configfile  dammitbrain 
october 2019 by kme
What is the !! (not not) operator in JavaScript? - Stack Overflow
An easy way to describe it is: Boolean(5) === !!5; Same casting, fewer characters
devel  javascript  boolean  idiom  syntax  newbie  dammitbrain 
september 2019 by kme
shell - Unable to locate and replace an element with its classname using bash script? - Stack Overflow
The actual solution is
Clean it up into valid XHTML with tidy

I used
<code class="language-bash">tidy -f /dev/null -w 0 -n -q -asxhtml</code>
in a pipe to suppress all the extraneous warnings, and get XML that something like XMLStarlet could handle.
html  xhtml  xml  tidy  importexport  datamunging  solution  dammitbrain  fuckina 
september 2019 by kme
The Complete Guide to Creating Symbolic Links (aka Symlinks) on Windows
<code class="lang-batch">
:: Use /D when you want to create a soft link pointing
:: to a directory. like so:
mklink /D Link Target
symlink  junctionpoints  directoryjunction  hardlink  windows  sysadmin  cli  commandline  mklink  reference  solution  dammitbrain 
september 2019 by kme
BashFAQ/024 (Why can't I pipe data to read?) - Greg's Wiki
So when you try to pipe into 'readarray', the variable you're trying to 'readarray' *into* is created in the context of the subshell, and then deleted when the subshell terminates.
The reason for this potentially surprising behaviour, as described above, is that each SubShell introduces a new variable context and environment. The while loop above is executed in a new subshell with its own copy of the variable linecount created with the initial value of '0' taken from the parent shell. This copy then is used for counting. When the while loop is finished, the subshell copy is discarded, and the original variable linecount of the parent (whose value hasn't changed) is used in the echo command.
bash  looping  whileloop  forloop  arrays  mapfile  readarray  syntax  newbie  pitfall  dammitbrain 
august 2019 by kme
css3 - How can I transition height: 0; to height: auto; using CSS? - Stack Overflow
Use max-height in the transformation and not height. And set a value on max-height to something bigger than your box will ever get.
css  animation  css3  transitions  webdesign  dammitbrain  solution 
june 2019 by kme
'None Is' or 'None Are'? | Grammar Girl
tl;dr: Either one could be right, depending on whether you mean to say "not any of them are" (corrupted) or "not a single one of them is" (included in the cost).
grammar  english  writing  dammitbrain 
june 2019 by kme
arrays - Perl: if ( element in list ) - Stack Overflow
Here is an example which works with any searched (scalar) value, including undef:
<code class="language-perl">use List::MoreUtils qw(any);

my $value = 'test'; # or any other scalar
my @array = (1, 2, undef, 'test', 5, 6);

no warnings 'uninitialized';

if ( any { $_ eq $value } @array ) {
print "$value present\n"
perl  listmembership  lists  syntax  newbie  dammitbrain  likepython  solution 
june 2019 by kme
How to view all the content in an awk array? - Unix & Linux Stack Exchange
You can loop over the array's keys and extract the corresponding values:
<code class="language-bash">awk '{my_dict[$1] = $2} END { for (key in my_dict) { print my_dict[key] } }' zen</code>

To get output similar to that you'd get with a Python dictionary, you can print the key as well:
<code class="language-bash">awk '{my_dict[$1] = $2} END { for (key in my_dict) { print key ": " my_dict[key] } }' zen

This works regardless of the key type.
awk  array  syntax  associativearray  solution  dammitbrain 
may 2019 by kme
Bash Reference Manual |
Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard.
bash  shell  shellscripting  ansicquoting  quoting  dammitbrain  reference 
may 2019 by kme
pipe - Piping buffer to external command in Vim - Stack Overflow
You can use :w !cmd to write the current buffer to the stdin of an external command. From :help :w_c:
vim  buffers  pipes  externalcommands  textfilter  textprocessing  dammitbrain  solution 
april 2019 by kme
How effectively delete a git submodule. |
To remove a submodule you need to:

* Delete the relevant section from the .gitmodules file.
* Stage the .gitmodules changes git add .gitmodules
* Delete the relevant section from .git/config.
* Run git rm --cached path_to_submodule (no trailing slash).
* Run rm -rf .git/modules/path_to_submodule (no trailing slash).
* Commit git commit -m "Removed submodule "
* Delete the now untracked submodule files rm -rf path_to_submodule
git  submodule  dammitbrain  solution 
march 2019 by kme
use of alternation "|" in sed's regex - Super User |
<code style="language-bash">echo "blia blib bou blf" | sed 's/bl\(ia\|f\)//g'</code>
For anyone else confused by this answer \| only works in gnu sed (gsed on os x) not vanilla sed (sed on os x). – Andrew Hancox Apr 4 '12 at 14:54
sed  shellscripting  textprocessing  syntax  newbie  dammitbrain  linuxonly  solution 
march 2019 by kme
posix - How to check if stdin is from the terminal or a pipe in a shell script? - Stack Overflow |
<code class="language-bash">#!/bin/sh
if [ -t 0 ]; then
echo running interactivelly
while read -r line ; do
echo $line
bash  shellscripting  stdin  dammitbrain  solution 
march 2019 by kme
git - .gitignore exclude folder but include specific subfolder - Stack Overflow |
To do what you want, you have to “unignore” every parent directory of anything that you want to “unignore”. Usually you end up writing rules for this situation in pairs: ignore everything in a directory, but not some certain subdirectory.
<code class="language-gitignore"># you can skip this first one if it is not already excluded by prior patterns


git  gitignore  devel  annoyance  dammitbrain  solution 
march 2019 by kme
How do I tell what type of value is in a Perl variable? - Stack Overflow |

Perl provides the ref() function so that you can check the reference type before dereferencing a reference...

By using the ref() function you can protect program code that dereferences variables from producing errors when the wrong type of reference is used...
perl  devel  newbie  introspection  syntax  solution  dammitbrain 
february 2019 by kme
keyboard shortcuts - How to put current line at top/center/bottom of screen in vim? - Unix & Linux Stack Exchange |
zt puts current line to top of screen
z. or zz puts current line to center of screen
zb puts current line to bottom of screen

More info about scrolling at or in vim type :help scroll-cursor
vim  tipsandtricks  scrolling  cursormotion  solution  dammitbrain 
february 2019 by kme
How to code Adobe JavaScript, how to code PDF JavaScript - Adobe Acrobat -

This works in Chrome and Firefox's built-in PDF viewers, too.
pdf  hyperlink  url  anchor  webdevel  dammitbrain  solution 
january 2019 by kme
Ternary operation - Wikipedia |
Solution for Tcl via

<code class="language-tcl">
set x 5
set y [expr $x == 5 ? 10 : 15]
syntax  programming  dammitbrain  solution 
january 2019 by kme
Git - Rebasing |
If you're not already checked out to the "topic" branch, you can do that this way
<code class="language-bash">
git rebase master topic-branch

Just remember that the first argument is always the "onto" (base) branch.
For this example, you would check out the experiment branch, and then rebase it onto the master branch as follows:
<code class="language-bash">
git checkout experiment
git rebase master
# First, rewinding head to replay your work on top of it...
# Applying: added staged command

This operation works by going to the common ancestor of the two branches (the one you’re on and the one you’re rebasing onto), getting the diff introduced by each commit of the branch you’re on, saving those diffs to temporary files, resetting the current branch to the same commit as the branch you are rebasing onto, and finally applying each change in turn.

At this point, you can go back to the master branch and do a fast-forward merge.
<code class="language-bash">
git checkout master
git merge experiment

There is no difference in the end product of the integration, but rebasing makes for a cleaner history. If you examine the log of a rebased branch, it looks like a linear history: it appears that all the work happened in series, even when it originally happened in parallel.
git  rebase  vcs  versioncontrol  reference  newbie  dammitbrain 
december 2018 by kme
Resolving EACCES permissions errors when installing packages globally
<code class="language-bash"># create a directory for global installations:
mkdir ~/.npm-global

# Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'

# open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH

# update your system variables:
source ~/.profile

# install a package globally without using sudo:
npm install -g jshint</code>
javascript  nodejs  node  packagemanagement  errormessage  solution  annoyance  dammitbrain 
november 2018 by kme
javascript - For loop for HTMLCollection elements - Stack Overflow |
<code class="language-javascript">
var list = document.getElementsByClassName("events");
for (let item of list) {
webdevel  javascript  array  htmlcollection  iterator  annoyance  dammitbrain  solution 
november 2018 by kme
Is it possible to create a multi-line string variable in a Makefile - Stack Overflow |
This works fine, for example, to embed Python code in a Makefile; just stick to one type of quotes in the Python source, 'export' the 'define'd variable, and wrap it in the other kind of quote when you call 'python -c "$$PYSCRIPT"' from one of your recipes.
Yes, you can use the define keyword to declare a multi-line variable, like this:
<code class="language-makefile">
Version $(VERSION) of $(PACKAGE_NAME) has been released.

It can be downloaded from $(DOWNLOAD_URL).

etc, etc.

The tricky part is getting your multi-line variable back out of the makefile. If you just do the obvious thing of using "echo $(ANNOUNCE_BODY)", you'll see the result that others have posted here -- the shell tries to handle the second and subsequent lines of the variable as commands themselves.

However, you can export the variable value as-is to the shell as an environment variable, and then reference it from the shell as an environment variable (NOT a make variable). For example:
<code class="language-makefile">

make  makefile  python  quoting  shellscripting  dammitbrain  solution 
november 2018 by kme
bash - How to detect if a script is being sourced - Stack Overflow |
The answer is... it's complicated.

I ended up using this for something I *knew* would be executed with the Bash shell:
<code class="language-bash">
[ "$0" = "$BASH_SOURCE" ]
bash  shellscripting  reference  abs  dammitbrain  solution 
october 2018 by kme
bash - How do I reload .inputrc? - Super User |
Interesting, but doesn't work for me.
By default, C-x C-r is bound to re-read-init-file.

See the Bash Reference Manual for explanation.

Maybe this does:
bind -f ~/.inputrc
bash  inputrc  keyboard  readline  configfile  dammitbrain 
october 2018 by kme
cannot mount as normal user |
<code class="language-fstab">
# add an entry for /dev/sr0 to /etc/fstab with 'users' mount option
/dev/sr0 /cdrom auto ro,noauto,exec,users 0 0
unix  linux  fstab  mount  permissions  asnonadmin  dammitbrain  solution 
october 2018 by kme
How can I send POST and GET data to a Perl CGI script via the command line? - Stack Overflow |
Add 'CGI qw( -debug )'.

<code class="language-perl">#! /usr/bin/perl
use warnings;
use strict;

use CGI qw/ :standard -debug /;

print "Content-type: text/plain\n\n",
map { $_ . " => " . param($_) . "\n" }

Also interesting:
To give a cgi script post data:
<code class="language-bash">$ echo -n 'a=b;c=d' | REQUEST_METHOD=POST CONTENT_LENGTH=999 perl index.cgi</code>

To give a cgi script get data:
<code class="language-bash">
$ perl index.cgi 'a=b;c=d'</code>

Of *course* that's how CGI works, but it's easy to forget that's how it works.
perl  testing  debugging  commandline  solution  webdevel  cgi  dammitbrain 
august 2018 by kme
python - get table columns from sqlAlchemy table model - Stack Overflow |
You get all of the columns from __table__.columns:
<code class="language-python">myTable.__table__.columns</code>

<code class="language-python">myTable.__table__.c</code>

The columns would be in format myTable.col1 (table name is included). If you want just column names, get the .key for each column:
<code class="language-python">
[column.key for column in myTable.__table__.columns]
python  sqlalchemy  dba  sql  solution  reference  dammitbrain 
august 2018 by kme
How to change the remote repository for a git submodule? - Stack Overflow |
You should just be able to edit the .gitmodules file to update the URL and then run git submodule sync to reflect that change to the superproject and your working copy.

Also handy (like 'git remote -v', sort of):
<code class="language-bash">git submodule foreach -q git config remote.origin.url</code>
git  scm  versioncontrol  submodule  solution  dammitbrain 
june 2018 by kme
php - Removing X-Powered-By - Stack Overflow |

I think that is controlled by the expose_php setting in PHP.ini:
<code class="language-php">expose_php = off</code>

Decides whether PHP may expose the fact that it is installed on the server (e.g. by adding its signature to the Web server header). It is no security threat in any way, but it makes it possible to determine whether you use PHP on your server or not.

There is no direct security risk, but as David C notes, exposing an outdated (and possibly vulnerable) version of PHP may be an invitation for people to try and attack it.
php  webdevel  webmaster  security  configfile  configuration  solution  dammitbrain 
may 2018 by kme
Change Apache httpd "Server:" HTTP header - Unix & Linux Stack Exchange |
I simply changed the directives in security.conf and Apache started working as I wanted.
<code class="language-apache">
ServerTokens Prod
ServerSignature Off
webmaster  apache  httpd  config  configfile  security  configuration  solution  dammitbrain 
may 2018 by kme
shell - Redirecting stdout to a file you don't have write permission on - Unix & Linux Stack Exchange |
Yes, using tee. So echo test > /tmp/foo becomes
<code class="language-bash">echo test | sudo tee /tmp/foo</code>

You can also append (>>)
<code class="language-bash">echo test | sudo tee -a /tmp/foo</code>
bash  sudo  shellscripting  redirection  dammitbrain  solution 
may 2018 by kme
windows - Get user's non-truncated Active Directory groups from command line - Stack Overflow
GPRESULT is the right command, but it cannot be run without parameters. /v or verbose option is difficult to manage without also outputting to a text file. E.G. I recommend using
<code style="language-batch">
:: Ensure C:\Dev\me.txt exists
gpresult /user myAccount /v > C:\dev\me.txt

Another option is to display summary information only which may be entirely visible in the command window:
<code style="language-batch">gpresult /user myAccount /r</code>
windows  usermanagement  commandline  groupmembership  dammitbrain  solution 
march 2018 by kme
dual boot - How to get grub2 to remember last choice? - Ask Ubuntu -
The documentation in this case is wrong. All variables in /etc/default/grub start with GRUB_, so it's GRUB_DEFAULT=saved, not DEFAULT=saved. I've corrected the Ubuntu wiki to reflect that.

The official grub manual describes this correctly:

Put the following in /etc/default/grub:
<code class="language-bash">

Then run:
<code class="language-bash">
sudo update-grub
linux  windows  grub  grub2  dualboot  bootmanager  configfile  configsetting  dammitbrain  solution 
march 2018 by kme
What is cmake equivalent of 'configure --prefix=DIR && make all install '? - Stack Overflow |
You can pass in any CMake variable on the command line, or edit cached variables using ccmake/cmake-gui. On the command line,
<code class="language-bash">cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr . && make all install</code>

Would configure the project, build all targets and install to the /usr prefix. The type (PATH) is not strictly necessary, but would cause the Qt based cmake-gui to present the directory chooser dialog.
cmake  build  toolchain  devel  dammitbrain  solution 
march 2018 by kme
Symkat - Find a Perl Module's Path |
Archived version of page (which was offline as of 2019-09-25):

<code class="language-bash">
$ perldoc -lm List::Util

<code class="language-bash">
cpan -l | grep Package::Name

Using Perl itself (maybe `perldoc` isn't installed):
<code class="language-perl">#!/usr/bin/perl
use warnings;
use strict;

for my $module ( @ARGV ) {
my $package = $module;

# From This::That to This/
s/::/\//g, s/$/.pm/ for $module;

if ( require $module ) {
print $package . " => " . $INC{$module} . "\n";

I called this 'p5which'.
perl  devel  library  PERL5LIB  whereis  wherefrom  annoyance  dammitbrain  solution  module 
february 2018 by kme
MySQL Count distinct values from one column - Stack Overflow |
Have you tried
<code class="language-sql">SELECT COUNT(DISTINCT B) FROM mytable WHERE C = 2;</code>
dba  sql  syntax  mysql  dammitbrain  newbie  solution 
february 2018 by kme
mysql command for showing current configuration variables - Stack Overflow |
What you are looking for is this:
<code class="language-sql">SHOW VARIABLES;</code>

You can modify it further like any query:
<code class="language-sql">SHOW VARIABLES LIKE '%max%';</code>
dba  mysql  sql  syntax  newbie  dammitbrain  solution 
january 2018 by kme
scripting - The way to use `/usr/bin/env sed -f ` in shebang? - Unix & Linux Stack Exchange |
You can't use 'env', so just '#!/usr/bin/sed -f' should be OK.

The problem with that is (as mentioned in the top-rated answer), you can't include more than one argument in a shebang, so you need to use one of the alternate techniques if you want to, say, do 'sed -n 'f'.
For a long script, it may be more convenient to use a heredoc. An advantage of a heredoc is that you don't need to quote the single quotes inside, if any. A major downside is that the script is fed to sed on its standard input, with two annoying consequences. Some versions of sed require -f /dev/stdin instead of -f -, which is a problem for portability. Worse, the script can't act as a filter, because the standard input is the script and can't be the data.
<code class="language-bash">
exec sed -f - -- "$@" <<'EOF'
sed  shellscripting  shebang  solution  dammitbrain 
january 2018 by kme
shell - What's the difference between .bashrc, .bash_profile, and .environment? - Stack Overflow |
The main difference with shell config files is that some are only read by "login" shells (eg. when you login from another host, or login at the text console of a local unix machine). these are the ones called, say, .login or .profile or .zlogin (depending on which shell you're using).

Then you have config files that are read by "interactive" shells (as in, ones connected to a terminal (or pseudo-terminal in the case of, say, a terminal emulator running under a windowing system). these are the ones with names like .bashrc, .tcshrc, .zshrc, etc.

bash complicates this in that .bashrc is only read by a shell that's both interactive and non-login, so you'll find most people end up telling their .bash_profile to also read .bashrc with something like

<code class="language-bash">
[[ -r ~/.bashrc ]] && . ~/.bashrc

Other shells behave differently - eg with zsh, .zshrc is always read for an interactive shell, whether it's a login one or not.

The manual page for bash explains the circumstances under which each file is read. Yes, behaviour is generally consistent between machines.

.profile is simply the login script filename originally used by /bin/sh. bash, being generally backwards-compatible with /bin/sh, will read .profile if one exists.
unix  linux  bash  loginscripts  dotfiles  newbie  questions  dammitbrain 
january 2018 by kme
bash - Temporarily suspend bash_history on a given shell? - Unix & Linux Stack Exchange |
Turn Off
<code class="language-bash">
set +o history

Turn on

<code class="language-bash">
set -o history
bash  history  dammitbrain  solution 
january 2018 by kme
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 by kme
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 by kme
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 by kme
Get the name of current script with Python - Stack Overflow |
<code class="language-python">
# or
python  scripting  dammitbrain  solution 
december 2017 by kme
curl - SSL CA Certificates |
Yeah, except the '--cacert pemfile.pem' option never seems to work without just resorting to '--insecure' also.
If you use the 'openssl' tool, this is one way to get extract the CA cert for a particular server:
<code class="language-bash">openssl s_client -showcerts -servername server -connect server:443 > cacert.pem</code>
- type "quit", followed by the "ENTER" key
- The certificate will have "BEGIN CERTIFICATE" and "END CERTIFICATE" markers.
- If you want to see the data in the certificate, you can do: "openssl x509 -inform PEM -in certfile -text -out certdata" where certfile is the cert you extracted from logfile. Look in certdata.
- If you want to trust the certificate, you can add it to your CA certificate store or use it stand-alone as described. Just remember that the security is no better than the way you obtained the certificate.

Convert from crt (IE / Windows, DER format) to PEM format:
<code class="language-bash">openssl x509 -inform DES -in yourdownloaded.crt -out outcert.pem -text</code>
webdevel  debugging  curl  ssl  certs  ca  security  dammitbrain  reference 
december 2017 by kme
A Helpful Mnemonic for 'git rebase' Arguments // Think Like (a) Git
This is helpful:
So when I use git rebase, I (almost) always give it two arguments: the name of the place I want to start from, and the name of the place I want to end up. Or, to put it another way, I tell rebase the sequence of events I want it to create, from left to right: git rebase first_this then_this

But this section of the 'git-rebase' manual page is equally helpful:
Assume the following history exists and the current branch is "topic":

A---B---C topic
D---E---F---G master

From this point, the result of either of the following commands:

git rebase master
git rebase master topic

would be:

A'--B'--C' topic
D---E---F---G master
git  rebase  git-rebase  mnemonic  dammitbrain  reference  newbie 
december 2017 by kme
command line - What do the STAT column values in ps mean? - Ask Ubuntu
It's because I never think to search for "PROCESS STATE CODES" when I'm trying to find this in the manual page.
man ps has all the answers, under the "PROCESS STATE CODES" heading:

Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may be displayed:
< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group.
reference  linux  processmanagement  ps  sysadmin  dammitbrain 
december 2017 by kme
how to exit a python script in an if statement - Stack Overflow
I dunno why I always was using os.exit() back in the day. Maybe there wasn't an 'exit' in Python 2.7?
python  syntax  newbie  dammitbrain  solution 
december 2017 by kme
Uninstall a program installed with Wine - Ask Ubuntu
Type in a terminal or press Alt+F2 and type 'wine uninstaller' will give you access to the built in Add/Remove tool from wine. From there you can uninstall a program you have installed in a bottle.
wine  uninstaller  uninstall  annoyance  dammitbrain  linux  solution 
november 2017 by kme
« earlier      
per page:    204080120160

Copy this bookmark:

to read