Skip to content

Instantly share code, notes, and snippets.

View markoa's full-sized avatar

Marko Anastasov markoa

View GitHub Profile
@markoa
markoa / create-txt-files-in-macos-finder.md
Created July 5, 2023 10:48
How to create a custom macOS Finder action to create a text file inside a folder

Being able to create plain text files easily anywhere in Finder helps with using the iCloud-backed native file system for personal knowledge management. It's my preferred alternative to third-party apps whose longevity may be uncertain.

Create an Automator service

  1. Open Automator.
  2. From Library, choose "Utilities", then "Run AppleScript" action.
  3. At the top of the workflow window, you'll see a few dropdown menus. Set the first one ("Workflow receives current") to "files or folders", and the second one to "Finder".
  4. Paste the following AppleScript code:
@markoa
markoa / wordpressxml2jekyll.rb
Created January 4, 2010 09:48
Script to export posts from a Wordpress XML file to Jekyll (Textile) files. Collects comments in a YAML file too.
#!/usr/bin/env ruby
# Input: WordPress XML export file.
# Outputs: a series of Textile files ready to be included in a Jekyll site,
# and comments.yml which contains all approved comments with metadata which
# can be used for a Disqus import.
require 'rubygems'
require 'hpricot'
require 'clothred'
@markoa
markoa / deploy.rb
Created October 10, 2011 13:31
Ingredients to monitor Resque with God automatically via Capistrano (on Ubuntu)
namespace :deploy do
desc "Hot-reload God configuration for the Resque worker"
task :reload_god_config do
sudo "god stop resque"
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}"
sudo "god start resque"
end
end
# append to the bottom:
@markoa
markoa / config.rb
Created September 12, 2013 08:52
Current Middleman configuration
###
# Blog settings
###
# Time.zone = "UTC"
activate :blog do |blog|
blog.prefix = "blog"
blog.permalink = ":year/:month/:day/:title.html"
blog.sources = "posts/:year-:month-:day-:title.html"
@markoa
markoa / configuration-middleware.rb
Created October 19, 2010 16:45
Monkey patch for OmniAuth::Strategy to make it Rack::Config configurable. Here we also include sample middleware that sets different configuration within an app serving many domains.
module App
module Middleware
class OmniAuthConfigurator
def initialize(app)
@app = app
end
def call(env)
current_domain = env["SERVER_NAME"] || env["HTTP_X_FORWARDED_FOR"]
website = Website.find_by_domain(current_domain)
@markoa
markoa / bash_contour.sh
Last active September 27, 2016 12:58
Stuff I usually need in ~/.bash_profile
set -o vi
eval `ssh-agent`
ssh-add ~/.ssh/id_rsa
export PS1="\w ★ "
export LANGUAGE="en"
export LANG="C"
export LC_MESSAGES="C"
@markoa
markoa / postgis
Last active December 27, 2015 02:08 — forked from Jesterovskiy/postgis
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y postgresql-9.3-postgis-2.1 postgresql-9.3-postgis-2.1-scripts
@markoa
markoa / log.log
Created October 17, 2013 10:31
Error while running `bundle install` with RubyGems 2.1.9 on Ubuntu 12.04.
Fetching source index from https://rubygems.org/
Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most
likely your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see bit.ly/ruby-ssl. To connect without
using SSL, edit your Gemfile sources and change 'https' to 'http'.
@markoa
markoa / README.md
Last active December 19, 2015 11:19

Workaround for Semaphore regression on 2013-07-07/08, bundler missing for Ruby 1.9.2.

If your project is using Ruby 1.9.2, add these build setup commands to avoid the regression:

rbenv local 1.9.2-p320
gem install bundler --no-ri --no-rdoc

Update: regression has been fixed

@markoa
markoa / irb.rb
Created February 21, 2013 11:55
How to shut up irb
# either irb --noecho, or
conf.echo = false