Skip to content

Instantly share code, notes, and snippets.

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

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 Aug 13, 2020
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
View README.md

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 Mar 6, 2018
Find filenames contain illegal windows characters on Mac/Linux -- regex pattern match windows reserved characters
View find_illegal_windows_filename.sh
# 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 Nov 28, 2022
Use macOS-style shortcuts in Windows
View README.md

Use macOS-style shortcuts in Windows / keyboard mappings using a Mac keyboard on 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

Here's some examples of how this script work:

@ascendbruce
ascendbruce / trello-cards-count-bookmarklet.js
Last active Feb 27, 2016
Show cards count bookmarklet for Trello
View trello-cards-count-bookmarklet.js
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 Feb 6, 2016
Fetch facebook graph object scrape information clear cache in command line
View gist:ed51360753edf7ce1fd8
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
View rubocop_disable_all.yml
# 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 Aug 29, 2015
rails console customization without modifying Gemfiles
View .pryrc
# 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|
View if_unless_bmbm.rb
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?
View rails_all_models.rb
# 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