Skip to content

Instantly share code, notes, and snippets.

@ascendbruce
ascendbruce / README.md
Last active August 5, 2018 07:44 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations

Install dependency

Get Homebrew installed on your mac if you don't already have it.

brew install highlight

Highlight your source

@ascendbruce
ascendbruce / README.md
Last active August 13, 2020 19:16
error when rake db:migrate with postgresql 9.6 and postgis 2.4. error message Server is version 9.6, library is version 10.0

error message

PG::InternalError: ERROR:  incompatible library "/usr/local/lib/postgresql/postgis-2.4.so": version mismatch
DETAIL:  Server is version 9.6, library is version 10.0.
: CREATE EXTENSION IF NOT EXISTS "postgis"
/Users/bruce/Projects/HB-Backend/db/migrate/20151013213623_enable_postgis.rb:3:in `change'
-e:1:in `<main>'

Caused by:
@ascendbruce
ascendbruce / find_illegal_windows_filename.sh
Created March 6, 2018 08:40
Find filenames contain illegal windows characters on Mac/Linux -- regex pattern match windows reserved characters
# Source: https://stackoverflow.com/questions/19008614/find-files-with-illegal-windows-characters-in-the-name-on-linux
# reserved characters for filename on windows: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
find . -name '*[<>:/\\|?*]*'
@ascendbruce
ascendbruce / README.md
Last active April 21, 2024 17:30
Use macOS-style shortcuts in Windows

Use macOS-style shortcuts in Windows / keyboard mappings using a Mac keyboard on Windows

ℹ️ There is a newer alternative project that does similar things and more, check it out at https://github.com/stevenilsen123/mac-keyboard-behavior-in-windows

Make Windows PC's shortcut act like macOS (Mac OS X) (using AutoHotkey (ahk) script)

With this AutoHotKey script, you can use most macOS style shortcuts (eg, cmd+c, cmd+v, ...) on Windows with a standard PC keyboard.

How does it work

@ascendbruce
ascendbruce / trello-cards-count-bookmarklet.js
Last active February 27, 2016 06:34
Show cards count bookmarklet for Trello
javascript: ! function() {
$(".js-num-cards").each(function(i) {
var size = $(".js-list:nth(" + i + ") .list-card-details").length;
$(".js-num-cards:nth(" + i + ")").text(size + " cards");
});
$(".js-num-cards").toggleClass('hide');
if ($(".board-header-btn-name .js-list-card-count").length === 0) {
$(".board-header-btn-name span").append(" <span class=\"js-list-card-count\"></span>");
@ascendbruce
ascendbruce / gist:ed51360753edf7ce1fd8
Last active February 6, 2016 10:57
Fetch facebook graph object scrape information clear cache in command line
curl -X POST -F "id={the url}" -F "scrape=true" "https://graph.facebook.com"
# from http://stackoverflow.com/questions/12100574/is-there-an-api-to-force-facebook-to-scrape-a-page-again
# Available cops (199) + config for /Users/bruce/Projects/rails:
# Type 'Lint' (36):
Lint/AmbiguousOperator:
Description: Checks for ambiguous operators in the first argument of a method invocation
without parentheses.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#parens-as-args
Enabled: false
Lint/AmbiguousRegexpLiteral:
Description: Checks for ambiguous regexp literals in the first argument of a method
@ascendbruce
ascendbruce / .pryrc
Last active August 29, 2015 14:10
rails console customization without modifying Gemfiles
# encoding: utf-8
# work-around from http://stackoverflow.com/a/15017892
required_version_gems = %w(
awesome_print-1.2.0
hirb-0.7.2
hirb-unicode-0.0.5
unicode-display_width-0.1.1
)
required_version_gems.each do |version_gem|
require 'benchmark'
require "active_support/core_ext/object/blank"
TIMES = 1000000
Benchmark.bmbm do |x|
x.report("if present? (actually present)") do
TIMES.times do
if "1".present?
# source: http://jokercatz.blogspot.tw/2013/09/rails-get-all-models.html
#first load all models
Rails.application.eager_load!
#okay…each now :)
ActiveRecord::Base.send(:subclasses).each do |model|
puts model.name
end