Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Extracting URLs from the exported HTML from getpocket.com/export
# In the following line $1 is the exported HTML from pocket
# Which will be passed to this script as a CLI parameter
# copied from https://gist.github.com/fmartingr/88a258bfad47fb00a3ef9d6c38e5699e?permalink_comment_id=4324412#gistcomment-4324412
grep -Eoi '<a [^>]+>' $1 | tac > pocket2shiori.txt
# Reading the URLs one by one and adding to shiori, with tags, if they exist
@ptzn
ptzn / karabiner.json
Created January 2, 2018 12:14
remapping cmd+space to right command using karabiner-elements
// REMAPPING CMD+SPACE TO RIGHT COMMAND USING https://github.com/tekezo/Karabiner-Elements
// Put following code into rules section into ~/.config/karabiner/karabiner.json file
// "profiles": [
// ...
"rules": [
{
"description": "RightCommand to Switch Input Source",
"manipulators": [
{
"conditions": [
#!/bin/sh
# Remove backups older than a given days
TM_PATH=/Volumes/stuff0/Backups.backupdb/zeus
DAYS=60
sudo find "${TM_PATH}" -maxdepth 1 -mtime +${DAYS} -type d -execdir tmutil delete '{}' \;
exit 0
# usage:
# say hello; notify #=> "Done" message will be sent on success and "Ooops" on error
# say hello; notify "in far far away galaxy" #=> "in far far away galaxy" message will be sent on success and "Ooops" on error
notify() {
local exit_code=$?
local api_key="PUT_API_KEY"
local chat_id="PUT_CHAT_ID_HERE"
@ptzn
ptzn / report
Last active December 24, 2015 06:09
Generate HTML report from CSV file generated by TimeTracker.app
#!/usr/bin/env ruby
#
# Generate HTML report from CSV generated by TimeTracker.app
# Options:
# -i, --input - path to csv file
# -s, --start-time - report start time
# -e, --end-time - report end time (today by default)
# -p, --project - project name to include into report (all by default)
# -d, --delimiter - CSV delimiter ("," by default)
# -o, --out - directory to write report
constraints(OwnDomain) do
match # ...
resources #...
end
class OwnDomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != "www" && request.host !~ /localhost|\.local|hostname\.com/
end
end
@ptzn
ptzn / bm.rb
Last active December 13, 2015 18:08
search_for = '46846'
value = '00000'
stats = []
search_for.size.times do |index|
stats[index] ||= []
10.times do |digit|
# This Rack middleware helps solving the issue with some Rails versions which do not accept
# a '*/*;q=0.6' and their variants 'Accept' request header. This header is particularly used
# by Google Bot, and if Rails doesn't like it, it will return a 500 or 406 error to Google Bot,
# which is not the best way to get your pages indexed.
#
# References:
# - http://stackoverflow.com/questions/8881756/googlebot-receiving-missing-template-error-for-an-existing-template
# - https://github.com/rails/rails/issues/4127
#
class GoogleBotAware
@ptzn
ptzn / formatted_date_attribute.rb
Created June 3, 2011 18:11 — forked from skojin/formatted_date_attribute.rb
virtual formatted date attribute
module FormattedDateAttributes
# Define virtual formatted date attribute
#
# formatted_date_attribute(:start_at, :end_at, :format => :default)
# formatted_date_attribute(:start_at, :end_at, :format => '%d/%m/%y')
#
# format parameter can be a symbol from config/initializers/date_time_formats.rb or any
# string format that will work with Date#strftime and DateTime.strptime methods
def formatted_date_attributes(*args)
options = { :format => :default }.merge(args.extract_options!)
setopt autocd
setopt CORRECT
autoload -U compinit
compinit
#zmodload zsh/complist
zstyle ':completion:*' menu yes select
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:processes' command 'ps -xuf'