This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
current_branch=$(git rev-parse --abbrev-ref HEAD) | |
remote="$1" | |
if [ "$current_branch" == "main" ] && [ "$remote" == "origin" ]; then | |
echo "You can not push to $remote from $current_branch" | |
exit 1 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nmcli connection import type openvpn file your-connection.ovpn | |
nmcli connection modify your-connection +vpn.data username=your-user-name | |
nmcli connection modify your-connection ipv4.never-default true | |
nmcli connection up your-connection passwd-file passwd-file | |
# To list all VPN connections | |
nmcli connection show --active | grep vpn | |
# To connect to the VPN | |
nmcli connection up your-connection passwd-file passwd-file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# drop this file in app/lib/pagination.rb | |
module Pagination | |
DEFAULT_PAGE_LIMIT = 10 | |
def pages(records:, url:) | |
paginate = Paginate.new(records: records, | |
url: url, | |
limit: limit, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nori' | |
single_comment = <<~EOF | |
<?xml version="1.0" encoding="UTF-8"?> | |
<comments> | |
<comment> | |
<description>TEST COMMENT 123</description> | |
</comment> | |
</comments> | |
EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nc -v mongo_url 27017 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
heroku logs -t -n=10 | awk -F " |=" '/fwd/{system("geocode " $14)}' | grep --line-buffered "Full address\|State" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use it with at command | |
# e.g. `reminder "make tea" | at now + 30 minutes` | |
# Also learn how to make atrun work in osx | |
# https://unix.stackexchange.com/questions/478823/making-at-work-on-macos/478840#478840 | |
function reminder(){ | |
echo "reattach-to-user-namespace say $1; reattach-to-user-namespace osascript -e 'tell app \"System Events\" to display dialog \"${1}\" with title \"Reminder ⏰\"'" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str="daily" && str_up="${str^^}" && echo $str_up | fold -bw1 > lol.txt && echo $str_up | fold -w1 | xargs echo && tail -n +2 lol.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
require 'active_support/all' | |
STRING = 'Once upon a time in a world far far away' | |
def use_truncate | |
STRING.truncate(27) | |
end | |
def use_first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun sendTil() | |
"Sends til to littil. If you select a region and sendTil then it will send the content of that region, else it will send the whole buffer content." | |
(interactive) | |
(request | |
"http://littil.io/api/tils" | |
:type "POST" | |
:data (json-encode '(("til" . (("snippet" . ,(if (use-region-p) | |
(buffer-substring (region-beginning) (region-end)) | |
(buffer-string))))))) | |
:headers '(("Content-Type" . "application/json") ("Authorization" . "Basic *your key*")) |
NewerOlder