Today I Solved
parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
It works by editing the PS1 (Prompt string 1) variable.
$ git commit --amend --author="author <author@example.com>"
- name: Register what groups I am in
shell: groups
register: usergroups
- name: Show what groups I am in
debug: var=usergroups.stdout
$ npm install eslint@4.x babel-eslint@8 --save-dev
$ cp -u
t0 = performance.now();
// doSomething();
t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.");
$ nginx -t
In package.json:
"start": "concurrently \"command1 arg\" \"command2 arg\""
` shift + u + 60
‒ shift + u + 2012
✔ shift + u + 2714
á shift + u + E1
é shift + u + E9
í shift + u + ED
ó shift + u + F3
ú shift + u + FA
ñ shift + u + F1
# date -s "9:06:10"
getEventListeners(document)
$ npm install --only=production
With ansible:
- name: APP Install node_modules on the parent directory for sharing
become: yes
become_user: "{{ userweb }}"
become_method: sudo
shell: npm install {{ appdir_build }} --prefix={{ appdir_build }} --home=/opt/kanban
With the shell:
$ sudo su -s /bin/bash app-web -c 'npm install /opt/kanban/build --prefix=/opt/kanban/build --home=/opt/kanban'
(cd /var/log && cp -- *.log ~/Desktop)
<meta name="google" content="notranslate">
$ git diff HEAD:full/path/to/foo full/path/to/bar
Panes: Their position is preset, and the user can adjust their relative sizes by dragging the sash between them.
"runtimeArgs": ["--password-store=basic"]
$ aptitude install php5-pclzip zip
"\e[1;5C": forward-word
"\e[1;5D": backward-word
new URL(window.location.href).pathname.split('/').pop()
$ find . -ipath "*tasks/*.yml" -printf "\n\n\n\n%p\n" -exec cat {} \;
$ curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}'
$ sudo su -s /bin/bash -c 'psql < ~/kanban/ddl/001.0001.sql app' app-web
More examples:
$ sudo su labmin-web -c "(cd /home/labmin-web/labmin/server; psql labmin-db labmin-web < data.sql)" -s /bin/bash
$ su -s /bin/bash -c '/path/to/your/script' testuser
$ sudo su -s /bin/bash -c 'pm2 log' app-web
$ sudo -u apache whoami
$ sudo su -s /bin/bash -c 'psql app < /home/app-web/librusados/ddl/001.0001.sql' app-web
"dynamic import unexpected token"
"standard.options": {
"parser": "babel-eslint"
}
$ babel . --out-dir=../../build/dev/ --ignore='node_modules' --copy-files -w
netbeans_jdkhome="/usr/local/java/jdk1.8.0_131"
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
# this will never report 'changed' status
- shell: wall 'beep'
changed_when: False
$ npm run test -- ./path/to/the/test/file.js
$ mkdir -p
"lines-around-comment": [
"error", {
"allowBlockStart": true
}
]
$ rsync -rP ./origin/ ./destination/ --exclude=node_modules --exclude=build --exclude=.vagrant --exclude=.git
$ echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p
- template: src=/mine/sudoers dest=/etc/sudoers validate='visudo -cf %s'
$ ps aux | grep postgres | grep collector
$ git rm $(git ls-files --deleted)
$ ps aux | awk '/fileops/' | awk '{print $2}' | xargs kill
$ ssh-keygen -t ed25519 -f ./vagrant_key -C "Key for all vagrant development machines"
public static<T> void print (T arg) {
System.out.println(arg);
}
$ tree --dirsfirst -aFI "node_modules|.git|.vagrant"
Additionally, you can make an alias in .bashrcalias tree='/usr/bin/tree --dirsfirst -aFI "node_modules|.git|.vagrant"'
{
"apps" : [{
"name" : "appname",
"script" : "bin/www",
"watch" : "./",
"ignore_watch" : ["node_modules"],
"log_date_format" : "YYYY-MM-DD HH:mm Z"
}]
}
Start PM2 with:
$ pm2 start processes.json
<property name="<Super>d" type="string" value="show_desktop_key"/>
xfce4-panel --preferences
Vagrant.configure('2') do |config|
config.vm.synced_folder '.', '/vagrant', disabled: true
# ...
end
postgres=# ALTER USER postgres PASSWORD 'myPassword';
usePolling: true
$ mkdir foo && cd "$_"
root ALL = (ALL) ALL
The wheel group can execute in all terminals as all users, all commands and doesn't need a password prompt to do that%wheel ALL=(ALL) NOPASSWD: ALL
int hours = t / 60; //since both are ints, you get an int
int minutes = t % 60;
System.out.printf("%d:%02d", hours, minutes);
\dt
In all schemas\dt *.*
In a particular schema\dt public.*
ssh-copy-id -i ~/.ssh/mykey root@192.168.10.2
If you'd wish not to be asked for root's password, use vagrant's account to copy the key using sudo.cat ~/.ssh/mykey.pub | ssh vagrant@192.168.10.2 'cat | sudo tee -a /root/.ssh/authorized_keys && echo "Key copied"'
resolveLoader: {
modules: ['/path/to/node_modules'],
},
resolve: {
modules: ['/path/to/node_modules'],
}
if (req.query.filtertext) {
config.where = Sequelize.and(
Sequelize.where(Sequelize.fn('unaccent', Sequelize.col('nombre')), {
[Sequelize.Op.iLike]: Sequelize.fn('unaccent', `%${req.query.filtertext}%`)
}),
Sequelize.where(Sequelize.fn('unaccent', Sequelize.col('nombre')), {
[Sequelize.Op.iLike]: Sequelize.fn('unaccent', `%f%`)
})
);
}
- name: SUDO Create and configure /etc/sudoers.d/{{ useradmin }} file
lineinfile: dest=/etc/sudoers.d/{{ useradmin }} line="Defaults env_keep+=SSH_AUTH_SOCK" state=present create=yes owner=root group=root mode="u+rw,g-rwx,o-rwx"
- name: APP Checkout git repo
become: no
git: repo=git@github.com:oscbco/kanban.git dest=/home/app-admin/kanban update=no
~/.ssh/config
ForwardAgent yes
let db = new Dexie('fileops');
db.open().then(function () {
let windows = db.table('windows');
windows.toCollection().first().then(function (window) {
console.log(window.id);
});
});
async count () {
let count = await
appdb.count('windows');
console.log('count', count);
}
import 'whatwg-fetch';
const API_URL = '/api';
const API_HEADERS = {
'Content-Type': 'application/json'
};
window.fetch(API_URL + '/cards/', API_HEADERS)
.then((response) => response.json()) // Takes a Response stream and reads it to completion
// It returns a promise that resolves with a JSON object
.then((responseData) => {
this.setState({
cards: responseData
});
}).catch((error) => {
console.log('Error fetching and parsing data', error);
});
console.log("\nScenario 1: Modifying a referenced value (in this case an object's property):");
const obj1 = {a: "a", b: "b"}
function changeObj1 (obj) {
obj.newPropertyC = "newPropertyC";
}
changeObj1(obj1);
console.log(JSON.stringify(obj1, null, 2));
// {
// "a": "a",
// "b": "b",
// "c": "c"
// }
console.log("\nScenario 2: Replacing the referenced value with a new one:");
const obj2 = {a: "a", b: "b"}
function changeObj2 (obj) {
obj = "new string";
}
changeObj2(obj2);
console.log(JSON.stringify(obj2, null, 2));
// {
// "a": "a",
// "b": "b"
// }
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` home_app-web_kanban /home/app-web/kanban
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` home_app-web_kanban /home/app-web/kanban
The error output from the last command was:
stdin: is not a tty
/sbin/mount.vboxsf: mounting failed with the error: No such device
install vagrant vbguest plugin
Trying to read an undeclared property returns undefined
Trying to read an non-existing position at an array returns undefined
try {
elem = {
filename: newFiles[keypath[i]].filename,
hasChild: newFiles[keypath[i]].child !== null,
hasSibling: newFiles[keypath[i] + 1] !== undefined
};
newFiles = newFiles[keypath[i]].child;
} catch (e) {
elem = undefined;
break;
}
$ npm install -g npm-check-updates
To print installed and available versions$ ncu
To update your package.json$ ncu -u
command_warnings = false
These warnings can be silenced by adjusting the following setting or adding warn=yes or warn=no to the end of the command line parameter string, like so:
- name: usage of git that could be replaced with the git module
shell: git update foo warn=no
postgresql.org/docs/9.0/static/indexes-unique
So an index including name, and deletedAt wouldn't behave as expected
The solution is to add a default value to deletedAt so it's never null.
name: {
type: DataTypes.TEXT,
allowNull: false,
unique: 'name_cod_del'
},
deletedAt: {
allowNull: false,
type: DataTypes.DATE,
unique: 'name_cod_del',
defaultValue: new Date(0)
}
So even though new Date (0) *is* in the past. Rows with it in the deletedAt field wouldn't be considered deleted.
Now however, restoration of soft deleted fields becomes problematic.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "256"
end
# Application Server 1
config.vm.define "app1" do |app|
app.vm.box = "debian/jessie64"
app.vm.hostname = "orc-app1.dev"
app.vm.network "private_network", ip: "192.168.60.4"
end
# Application Server 2
config.vm.define "app2" do |app|
app.vm.box = "debian/jessie64"
app.vm.hostname = "orc-app2.dev"
app.vm.network "private_network", ip: "192.168.60.5"
end
# Database Server
config.vm.define "db" do |db|
db.vm.box = "debian/jessie64"
db.vm.hostname = "orc-db.dev"
db.vm.network "private_network", ip: "192.168.60.6"
end
end
$ openssl genpkey -algorithm RSA -out private_key.key -pkeyopt rsa_keygen_bits:2048
Viewing the generated key fileopenssl rsa -text -in private_key.key
Alternative:Generate a CSR (Certificate signing request) File
openssl req -new -key fd.key -out fd.csr
Generate the 2048 rsa key and the certficate signing request all in one go (Interactive)openssl req -new -newkey rsa:2048 -nodes -keyout oscbco.key -out oscbco.csr
Check the Certificate Signing Request
openssl req -text -in fd.csr -noout
Step 1: Write Conf File: fd.conf
[req]
default_bits = 2048
default_keyfile = privkey.pem
prompt = no
encrypt_key = no
distinguished_name = dn
req_extensions = ext
[dn]
countryName = "SV" # C=
stateOrProvinceName = "San Salvador # ST=
localityName = "Soyapango" # L=
commonName = "www.example.com" # CN=
emailAddress = "webmaster@example.com" # CN/emailAddress=
openssl req -new -config fd.conf -out oscbco.csr
req:
The req command primarily creates and processes certificate requests in PKCS#10 format. It can additionally create self-signed certificates for use as root CAs for example
-new
this option generates a new certificate request. It will prompt the user for the relevant field values. The actual fields prompted for and their maximum and minimum sizes are specified in the configuration file and any requested extensions.
If the -key option is not used it will generate a new RSA private key using information specified in the configuration file.
-config filename
this allows an alternative configuration file to be specified, this overrides the compile time filename or any
specified in the OPENSSL_CONF environment variable.
openssl req -new -config fd.conf -x509 -days 365 -out oscbco.crt
Generate a csr from a crtopenssl x509 -x509toreq -in oscbco.crt -out oscbco.csr -signkey privkey.pem
View the csropenssl req -text -in oscbco.csr -noout
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
"\e[1;5C": forward-word
"\e[1;5D": backward-word
background: transparent url("data:image/svg+xml;base64,BASE64DATA") no-repeat;
obj.person && obj.person.name
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
}
}
export let getSearchParam = function (param) {
let url = new URL(window.location);
let params = new URLSearchParams(url.search);
return params.get(param);
};
<button type=button> does not submit the form.
This is useful for modules that connect to databases, since they won't try to connect to the database everytime the module is imported.
Instead such modules return the same db connection. This is where module internal variables come into play because they behave just like private variables. The user of the module can only modify them through the module's API.
Simple demo: repl.it/@oscbco/node-module-caching
You are only supposed to define its properties with values you wish to export.
In the end it's module.exports that is exported, and is perfectly valid to ignore exports.
Step 1: Copy the following code to a index.js file
Step 2: $ node index.js
Step 3: Visit the server on http://127.0.0.1:8125
var http = require('http');
var fs = require('fs');
var path = require('path');
http.createServer(function (request, response) {
console.log('request ', request.url);
var filePath = '.' + request.url;
if (filePath == './') {
filePath = './index.html';
}
var extname = String(path.extname(filePath)).toLowerCase();
var mimeTypes = {'.html': 'text/html','.js': 'text/javascript','.css': 'text/css','.json': 'application/json','.png': 'image/png','.jpg': 'image/jpg','.gif': 'image/gif','.wav': 'audio/wav','.mp4': 'video/mp4','.woff': 'application/font-woff','.ttf': 'application/font-ttf','.eot': 'application/vnd.ms-fontobject','.otf': 'application/font-otf','.svg': 'application/image/svg+xml'};
var contentType = mimeTypes[extname] || 'application/octet-stream';
fs.readFile(filePath, function(error, content) {
if (error) {
if(error.code == 'ENOENT') {
fs.readFile('./404.html', function(error, content) {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
});
}
else {
response.writeHead(500);
response.end('Sorry, check with the site admin for error: '+error.code+' ..\n');
response.end();
}
}
else {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
}
});
}).listen(8125);
console.log('Server running at http://127.0.0.1:8125/');
$ xfdesktop
<meta name="viewport" content="width=device-width, initial-scale=1">
ctrl + alt + mouse drag
They "reduce" the amount of items from 2 (action and old state) to 1 (new state)
Think of the Array.reduce() function which takes as its first parameter a function.
This function receives the acummulator and currentValue parameters and is run through the whole array returning a single value.
On Windows: > notepad file:Zone.Identifier
If you really want to clear the screen, you can use $ tput reset
To reduce typing time you may add the $ cls alias to your bash shell, like this:
alias cls="tput reset"
export HISTIGNORE="ls:pwd:exit:htop:su:clear:fb:cls:SU:reading:mve:reset:cmd"
<path d='m0.61405 290.96 3.6193 3.6193' stroke='currentColor' />
$ i3lock -c 000000
"trim_trailing_white_space_on_save": true
git reset
sudo su service-user -c "pm2 logs" -s /bin/bash
$ sudo aptitude why libjs-jquery
i task-xfce-desktop Recommends quodlibet
i A quodlibet Depends exfalso (= 3.2.2-1)
i A exfalso Depends libjs-sphinxdoc (>= 1.0)
i A libjs-sphinxdoc Depends libjs-jquery (>= 1.4)
Exit insert mode: Esc
Go to end of file: Ctrl + _ then Ctrl + v | Alt + \
Go to beginning of file: Alt + \
cd ~/Projects/sites/@vm
Caveat: This is not advisable if you use integrated terminals like VSCode's where you expect your starting directory to be your currently opened folder. This will break that behavior.In your ~/.bashrc file:
export vm=~/Projects/sites/@vm
Then in your console, you can type:cd $vm
"terminal.integrated.cwd": "./source/server"
You'll want to change this in your workspace settings rather than in your user settings, since not all projects are the same.In your ansible.cfg file:
[ssh_connection]
pipelining=True
192.168.10.4 ansible_ssh_pipelining='yes'
{{ variable.stdout | trim }}
[user]
name = Name Surname
email = nsurname@example.com
[push]
followTags = true
(Global ansible.cfg is in /etc/ansible/ansible.cfg)
[defaults]
stdout_callback=debug
stderr_callback=debug
[colors]
error = white
\dt *.*
git config --global push.followTags true
Download from https://packages.debian.org/sid/all/fonts-symbola/download
sudo dpkg -i fonts-symbola_2.60-1_all.deb
gstreamer1.0-gtk3
sudo apt-get install xbacklight xbacklight -set 60
Debugger installation:
Install compilation dependenies and execute make and make install with USE_PGXS
$ sudo apt-get install build-essential postgresql-server-dev-12 libssl-dev libkrb5-dev
$ sudo git clone git://git.postgresql.org/git/pldebugger.git -C /usr/local/src/
$ cd /usr/local/src/pldebugger/
$ sudo USE_PGXS=1 make
$ sudo USE_PGXS=1 make install
Edit postgresql.conf. Find it with:
# SHOW config_file;
Inside of postgresql.conf, Search for 'preload' (Ctrl + W in nano), Set "shared_preload_libraries" to:shared_preload_libraries = 'plugin_debugger'
Install the extension in your database
$ sudo su - postgres
$ psql database_name
database_name=# CREATE EXTENSION pldbgapi;
Restart the server
sudo service postgresql restart
@-moz-document url-prefix() {
.class {
rule: value;
}
}
The problem lies in that the children of those second-level elements have to have a data attribute too, otherwise we won't be able to distinguish them.
e.g. menu items with svg icons with multiple paths
To access the corresponding data attribute, without adding it to the descendants directly, you can use Element.closest.
This searches up the document tree using a selector, and since the second level elements are guaranteed to have a data attribute, you can use this result and pass it to your function.
$ ls README.md -hal
Returns:
-rwSr-Sr-T 1 user user 0 Feb 14 17:52 2A2A
$ stat --printf "%a " README.md && stat -c "%a" README.md | xargs -I PERM echo "obase=2; ibase=8; PERM" | bc
Returns:
7644 111110100100
parseInt(`0${value}`, 8).toString(2)
$ echo -ne 'copy\nfile:///path/to/file.txt' '\0' | xclip -i -selection clipboard -t x-special/gnome-copied-files
$ time ./magick mogrify -path thumbnails_magick -thumbnail 100x100 originals/* -quality 50
real 1m26.212s
user 1m5.203s
sys 0m20.560s
Sharp:
$ time node thumbnails.js
real 0m1.716s
user 0m3.858s
sys 0m0.434s
"globals": {
"expect": "readonly",
"it": "readonly",
"afterEach": "readonly",
"describe": "readonly"
}
sudo apt update
sudo apt upgrade
# Locate the latest java version
sudo apt search openjdk
sudo apt-get install openjdk-11-jdk
update-alternatives --config java
sudo sh -c 'echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/" > /etc/profile.d/java.sh'
# Make it readable
sudo chmod og+r /etc/profile.d/java.sh
# Add this line to ~/bashrc
source /etc/profile.d/java.sh
# Verify it exists
echo $JAVA_HOME
# Output: /usr/lib/jvm/java-11-openjdk-amd64/
Ctrl + Shift + P -> Show run command prompt
Write "screenshot"
Select one the commands available
It's buggy, so be prepared to try several times. (Maybe try scrolling)
$ ip address show