Skip to content

Instantly share code, notes, and snippets.

@sv99
sv99 / How can I replace a newline (\n) using sed.md
Last active May 10, 2024 07:56
How can I replace a newline (\n) using sed?

stackoverflow (hdorio)

Fast answer:

sed ':a;N;$!ba;s/\n/ /g' file
  1. :a create a label 'a'
  2. N append the next line to the pattern space
  3. $! if not the last line, ba branch (go to) label 'a'
  4. s substitute, /\n/ regex for new line, / / by a space, /g global match (as many times as it can)
@sv99
sv99 / readme.md
Last active February 12, 2023 21:45
OSX Regenerate text-based stub file for remove ld: warning: text-based stub file

Regenerate text-based stub files for frameworks

Example ld:warning

ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd
and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync.
Falling back to library file for linking.

Need "stubify" libs with utility tapi from default toolchain.

@sv99
sv99 / macvim-pyenv.md
Last active August 18, 2020 10:11
build macvim with python from env
@sv99
sv99 / index.html
Created February 13, 2020 20:04 — forked from jdrew1303/index.html
CSS brushed metal
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CSS brushed metal by Simurai &middot; CodePen</title>
<!--
Copyright (c) 2012 Hugo Giraudel, http://codepen.io/HugoGiraudel
Permission is hereby granted, free of charge, to any person obtaining
@sv99
sv99 / pyenv-install-osx.sh
Created November 17, 2017 19:17 — forked from mtchavez/pyenv-install-osx.sh
Using pyenv to install python on OS X with homebrew dependencies
# 2.7
CFLAGS="-I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include -I/usr/local/opt/zlib/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib -L/usr/local/opt/sqlite/lib -L/usr/local/opt/zlib/lib" \
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" \
pyenv install -v 2.7.12 --force
# 3.x
CFLAGS="-I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib -L/usr/local/opt/sqlite/lib" \
pyenv install -v 3.3.6
@sv99
sv99 / upgrade_packages.R
Last active May 14, 2017 10:20 — forked from bearloga/upgrade_packages.R
The script can be used to re-install packages after upgrading R (on Linux or Mac), since libraries cannot be reused between different minor versions (e.g. when upgrading 3.2.3 to 3.3.2). It detects when a package was installed from CRAN vs GitHub/Git and re-installs it using the appropriate func. Usage: `Rscript upgrade_packages.R`
# General use:
message("Checking for a personal library...")
if (!dir.exists(Sys.getenv("R_LIBS_USER"))) {
warning("Personal library not found, creating one...")
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
message("Registering newly created personal library...")
.libPaths(Sys.getenv("R_LIBS_USER"))
} else {
message("Personal library found.")
}
@sv99
sv99 / Immediately eval lines from file.md
Last active October 22, 2015 10:55
eval loaded from file lines in the gnu make

Gnu make shell command replace \n with space in the result.

Trick - replace \n in the file with replacer and after loading subst revert \n befor eval.

define newline


endef
@sv99
sv99 / add_ldap_user.sh
Created October 9, 2015 19:21
add user with UID
#!/bin/sh
#
# add user with UID
# <> user password "fullname" gid
#
if (( $# != 3 ))
then
echo Error. Need 3 arguments.
echo Usage: add_ldap_user.sh user password "fullname"
else
@sv99
sv99 / make_homedir.sh
Created October 9, 2015 19:19
создание домашнего каталога пользователя для работы с почтой
#!/bin/sh
#
# make home dir for user
# используется для создания домашнего каталога пользователя для работы с почтой
# устанавливает правильные разрешения на домашний каталог
#
# Изменен: 18.07.2008
if [ -z "$1" ] ; then
echo "Usage: $0 user_name"
@sv99
sv99 / opencv.md
Last active August 29, 2015 14:27
OPenCV 3.0 RPi

OPenCV 3.0 RPi

sudo apt-get install -t jessie cmake git pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -t jessie python-dev python-numpy libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get install -t jessie libgtk2.0-dev 

wget https://github.com/Itseez/opencv/archive/3.0.0.zip
unzip 3.0.0.zip
cd opencv-3.0.0

mkdir release