Skip to content

Instantly share code, notes, and snippets.

View tagplus5's full-sized avatar
🎯
Focusing

Andrii Yuriev tagplus5

🎯
Focusing
View GitHub Profile
@rantav
rantav / README.md
Created June 27, 2012 05:18
MongoDB increment or insert

In mongodb it's easy to make at upsert, meaning update-or-insert by calling

db.collection.update({criteria}, {updated fields}, true)

The third parameter means - insert a new document if the document doesn't exist yet. So, for example, the following will insert a new document for the user if there's no document for that user yet, and will update it if it already exists:

 db.users.update({user_id: '1234'}, {user_id: '1234', name: 'Ran'}, true)
@simonlk
simonlk / Woocommerce - output product variations in tab
Last active February 21, 2022 20:27
Output Woocommerce product variations as a table within a tab on the single product page
// Add to functions.php
/*===================================================
Created by sk from Renegade Empire with help
from these sources:
http://docs.woothemes.com/document/editing-product-data-tabs/
http://www.sean-barton.co.uk/2013/03/remove-woocommerce-20-reviews-tab/#.UYnWe7XfB6N
http://www.sean-barton.co.uk/2013/03/sb-add-woocommerce-tabs-wordpress-plugin/#.UYrYL7XfB6M
@anildigital
anildigital / gist:862675ec1b7bccabc311
Created July 26, 2014 18:27
Remove dangling docker images
docker rmi $(docker images -q -f dangling=true)
@erickoledadevrel
erickoledadevrel / xmlToJson.js
Created December 1, 2014 14:30
A function to convert an XML string to a JSON object in Apps Script, using logic similar to the sunset method Xml.parse().
/**
* Converts an XML string to a JSON object, using logic similar to the
* sunset method Xml.parse().
* @param {string} xml The XML to parse.
* @returns {Object} The parsed XML.
*/
function xmlToJson(xml) {
var doc = XmlService.parse(xml);
var result = {};
var root = doc.getRootElement();
@skrajewski
skrajewski / backup.sh
Last active December 19, 2023 14:54
Automate your macOS backup to Backblaze B2 using Restic and launchd.
#!/bin/bash
PID_FILE=~/.restic_backup.pid
TIMESTAMP_FILE=~/.restic_backup_timestamp
if [ -f "$PID_FILE" ]; then
if ps -p $(cat $PID_FILE) > /dev/null; then
echo $(date +"%Y-%m-%d %T") "File $PID_FILE exist. Probably backup is already in progress."
exit 1
else
@dado-prateek
dado-prateek / backup-host.sh
Last active December 23, 2023 08:09
Backup with duplicity to yandex.disk
#!/bin/sh
# Duplicity wrapper
#
# Not working for now. Yandex prevents uploading lagre files via webdav.
# add to crontab:
# 0 0 * * * /bin/sh /usr/local/sbin/backup-host.sh
set -e
@fluxrad
fluxrad / onedark.theme
Last active January 26, 2024 13:12
A one-dark theme for xfce4-terminal
[Scheme]
Name=One Dark
ColorForeground=#ABB2BF
ColorCursor=#ABB2BF
ColorBackground=#282C34
ColorSelection=#3B4451
ColorSelectionUseDefault=FALSE
ColorBold=#B9C0CB
ColorBoldUseDefault=FALSE
ColorPalette=#282C34;#E06C75;#98C379;#E5C07B;#61AFEF;#C678DD;#56B6C2;#ABB2BF;#3E4452;#BE5046;#98C379;#D19A66;#61AFEF;#C678DD;#56B6C2;#5C6370
@BlakeGardner
BlakeGardner / install nano.sh
Last active April 23, 2024 20:22
Syntax highlighting in nano on Mac OS
# Last updated March, 2022 for Apple silicon Macs
# Install Homebrew if you don't already have it: https://brew.sh
# install nano from homebrew
brew install nano nanorc
# update your nanorc file
echo 'include "/opt/homebrew/share/nanorc/*.nanorc"' >> ~/.nanorc
# close and re-open your terminal and you'll have syntax highlighting

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@berkorbay
berkorbay / github_desktop_ubuntu.md
Last active April 30, 2024 14:54
To install Github Desktop for Ubuntu

IMPORTANT

See the following links for further updates to Github Desktop for Ubuntu. These are official instructions. (also mentioned by fetwar on Nov 3, 2023)

For the sake of "maintaining the tradition" here is the updated version.