Tuesday, December 29, 2015

improve markdown syntax highlighting in sublime text


https://blog.mariusschulz.com/2014/12/16/how-to-set-up-sublime-text-for-a-vastly-better-markdown-writing-experience

The Markdown Extended Package

https://github.com/jonschlinkert/sublime-markdown-extended

Markdown syntax highlighter for Sublime Text, with extended support for GFM fenced code blocks, with language-specific syntax highlighting. YAML Front Matter. Works with ST2/ST3.


The Monokai Extended Package


Extends Monokai from Soda with additional syntax highlighting for Markdown, LESS, HTML, Handlebars and more. https://github.com/jonschlinkert



notes on GFM (github flavored markdown):
https://help.github.com/articles/github-flavored-markdown/



customize sublime text themes


https://github.com/buymeasoda/soda-theme/wiki/Theme-customisation


To begin customising an existing theme, create a new file in your User folder (located in the Sublime Text Packages directory) with the same name as the theme file you are extending.

For example, to customise Soda Dark, create an empty file called Soda Dark.sublime-theme (or for Sublime Text 3 create an empty file called Soda Dark 3.sublime-theme) in your User folder.

From this point, any valid theme rules you place in this file will automatically be applied by Sublime Text when the related theme is active.

Sunday, December 27, 2015

soda dark theme for sublime text

see commented-out section below for usage:

{
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme",
"ignored_packages":
[
"Vintage"
],
"show_full_path": true
}

// "soda_classic_tabs": true,
// "theme": "Soda Dark.sublime-theme"

Friday, December 18, 2015

de-dsstore.bat: batch file to delete-all-instances-of-ds_store-in-windows


http://awesometoast.com/delete-all-instances-of-ds_store-in-windows/

de-dsstore.bat:
e:
del /s /q /f /a .DS_STORE
del /s /q /f /a ._.*




bootstrap3 hide/show using hidden class and add/remove class




in bootstrap 3
use the hidden class instead of hide
use add/remove class instead of hide/show
jQuery ->
  if $('div.ground-school').length
    $(".previous-attempt-select").on "change", ->
      select = $(this)  #the select box from which an option was chosen
      quiz_id = select.val()
      if quiz_id > 0
        window.document.location = "/quiz_review_graded?quiz_id=#{quiz_id}"

    $(".lesson-thumbnail").on "click", ->
      link = $(this)
      lessonid = link.data('lessonid')
      # show the detail table for the selected header thumbnail
      detail_table = $(".video-thumbnail[data-videoid='#{lessonid}']").closest('table')
      detail_table_is_visible = detail_table.is(':visible')
      # if the details table isn't already visible, thumbnail is acting like an on button
      on_button_was_pressed = !detail_table_is_visible
      lesson_header = detail_table.closest('tr').prev()

      # hide everything
      $(".lesson-header").addClass('hidden')
      $(".detailtable").addClass('hidden')
      #undim header thumbnails
      $(".lesson-thumbnail").css('opacity', 1.0)
      # show reqs table for the selected lesson
      if on_button_was_pressed
        link.css('opacity', 0.7)
        detail_table.removeClass('hidden')
        lesson_header.removeClass('hidden')

Thursday, December 17, 2015

Remove iBook citations with a keyboard shortcut

save the following script
open a terminal window
run the scripts (loops until you exit it manually)


#!/usr/bin/env ruby
require 'clipboard'
loop do
  unless @clip == Clipboard.paste
    excerpt = Clipboard.paste
    puts "excerpt=#{excerpt}"
    cleaned = excerpt.match(/“([\n\w\d\s\D\W]+)”\n/)
    excerpt = cleaned.nil? ? excerpt : cleaned[1]
    puts "cleaned=#{excerpt}"
    Clipboard.copy(excerpt)
    @clip = Clipboard.paste
  end
end

sample run

the script will extract just the content between the quotes:

[smr@smr Desktop]$ ./remove-ibook-quotes.rb 

excerpt=“This rather obscure code, which you don’t need to understand in detail, arranges for precisely the behavior described above: it uses the minimum cost parameter in tests and a normal (high) cost parameter in production. (We’ll learn more about the strange ?-: notation in Section 8.4.5.)

Excerpt From: Michael Hartl. “Ruby on Rails Tutorial (3rd Ed.).” iBooks. 

cleaned=This rather obscure code, which you don’t need to understand in detail, arranges for precisely the behavior described above: it uses the minimum cost parameter in tests and a normal (high) cost parameter in production. (We’ll learn more about the strange ?-: notation in Section 8.4.5.)

notes

https://gist.github.com/iandundas/560df39f84ad00664101

prokizzle commented on Nov 7, 2015
Here's a ruby script that works for me

require 'clipboard'
loop do
  unless @clip == Clipboard.paste
    excerpt = Clipboard.paste
    cleaned = excerpt.match(/“([\n\w\d\s\D\W]+)”\n/)
    excerpt = cleaned.nil? ? excerpt : cleaned[1]
    Clipboard.copy(excerpt)
    @clip = Clipboard.paste
  end
end




use the clipboard ruby gem to copy and paste from the system clipboard

#!/usr/bin/env ruby

# require 'clipboard'
# loop do
#   unless @clip == Clipboard.paste
#     excerpt = Clipboard.paste
#     cleaned = excerpt.match(/“([\n\w\d\s\D\W]+)”\n/)
#     excerpt = cleaned.nil? ? excerpt : cleaned[1]
#     Clipboard.copy(excerpt)
#     @clip = Clipboard.paste
#   end
# end

require 'clipboard'
# loop do
#   unless @clip == Clipboard.paste
    excerpt = Clipboard.paste
    # grab everything inside the printer's quoes
    cleaned = excerpt.match(/“([\n\w\d\s\D\W]+)”\n/)
    excerpt = cleaned.nil? ? excerpt : cleaned[1]
    Clipboard.copy(excerpt)
    puts "stripped text copied to the clipboard:"
    puts excerpt

    # @clip = Clipboard.paste
#   end
# end

Saturday, December 12, 2015

python setup on osx 10.9


##################################################
# useful references
##################################################
https://dbader.org/blog/setting-up-sublime-text-for-python-development

http://outofmemoryblog.blogspot.co.uk/2012/08/python-development-with-sublime-text-2.html

https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/



##################################################
# system python vs python.org pkg vs homebrew python
##################################################
system:
which python
/usr/bin/python
python --version
Python 2.7.5

python.org python-3.5.0-macosx10.6.pkg:
which python3
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
python3 --version
Python 3.5.0

homebrew:
which python3
/usr/local/bin/python3
python3 --version
Python 3.5.1



configure sublime text for python syntax highlighting, autocomplete


  1. install SublimeRope using the package manager

SublimeRope gives you:
autocompletion
find defn
docs for selected fn

https://github.com/JulianEberius/SublimeRope

Thursday, December 10, 2015

compile bootstrap-3.3.6 using node and less


download source from:
http://getbootstrap.com/getting-started/#download

use homebrew to upgrade node if necessary
[smr@smr bootstrap-3.3.6]$ brew upgrade node

Error: node 5.1.1 already installed

cd bootstrap-3.3.6
npm install
grunt dist
or
grunt

see:
http://getbootstrap.com/getting-started/#grunt-commands
for details of grunt commands.


Tuesday, December 1, 2015

gotcha - if you git co a branch that uses a different rvm ruby, ruby is not switched automatically



if you forget this, you can inadvertently install stuff to the wrong ruby/gemset/etc.

easy workaround: when you switch to such a branch, close and reopen the terminal window. this will cause rvm to load the ruby listed in .ruby-version


[smr@smr pws2013 (master)]$ git co migrate-to-rails4 
Switched to branch 'migrate-to-rails4'
[smr@smr pws2013 (migrate-to-rails4)]$ ll
total 1592
drwxr-xr-x   34 smr  staff    1156 Dec  1 17:40 .
drwxr-xr-x    5 smr  staff     170 Apr 13  2013 ..
-rw-r--r--@   1 smr  staff   15364 Dec  1 10:30 .DS_Store
drwxr-xr-x   16 smr  staff     544 Dec  1 17:40 .git
-rw-r--r--    1 smr  staff     686 Dec  1 17:40 .gitignore
-rw-r--r--    1 smr  staff      14 Mar 25  2013 .rspec
-rw-r--r--    1 smr  staff       8 Dec  1 17:40 .ruby-gemset
-rw-r--r--    1 smr  staff      11 Dec  1 17:40 .ruby-version
-rw-r--r--    1 smr  staff     166 May 22  2013 Capfile
-rw-r--r--    1 smr  staff    2841 Dec  1 17:40 Gemfile
-rw-r--r--    1 smr  staff    7869 Dec  1 17:40 Gemfile.lock
-rw-r--r--    1 smr  staff    3695 Dec  1 17:40 Guardfile
-rw-r--r--    1 smr  staff    9208 Mar  7  2013 README.rdoc
-rw-r--r--    1 smr  staff     272 Mar  7  2013 Rakefile
drwxr-xr-x   10 smr  staff     340 Jun 12  2013 app
drwxr-xr-x    5 smr  staff     170 Dec  1 17:40 bin
drwxr-xr-x   16 smr  staff     544 Dec  1 17:40 config
-rw-r--r--    1 smr  staff     157 Mar  7  2013 config.ru
drwxr-xr-x  132 smr  staff    4488 Dec  1 17:40 content
drwxr-xr-x    8 smr  staff     272 Dec  1 17:40 db
drwxr-xr-x    3 smr  staff     102 Mar  7  2013 doc
-rw-r--r--    1 smr  staff  740672 Sep 30  2013 erd.pdf
drwxr-xr-x    4 smr  staff     136 Dec  1 17:40 grs_course_defns
drwxr-xr-x    7 smr  staff     238 May 25  2013 lib
drwxr-xr-x    8 smr  staff     272 Aug 16  2013 log
drwxr-xr-x    3 smr  staff     102 Jul 10 19:10 pdf
drwxr-xr-x    5 smr  staff     170 Dec  1 17:40 pdf-templates
drwxr-xr-x   12 smr  staff     408 Oct  4 14:38 public
drwxr-xr-x    5 smr  staff     170 Sep 23 11:46 script
drwxr-xr-x    8 smr  staff     272 Dec  1 17:40 smr
drwxr-xr-x   13 smr  staff     442 Dec  1 17:40 spec_old_unused
drwxr-xr-x    8 smr  staff     272 Dec  1 17:40 test
drwxr-xr-x    7 smr  staff     238 Aug  6 16:46 tmp
drwxr-xr-x    4 smr  staff     136 Mar  7  2013 vendor
[smr@smr pws2013 (migrate-to-rails4)]$ rvm current
ruby-1.9.3-p286
[smr@smr pws2013 (migrate-to-rails4)]$ rvm current
ruby-1.9.3-p286
[smr@smr pws2013 (migrate-to-rails4)]$ cd ../pws2013/
[smr@smr pws2013 (migrate-to-rails4)]$ rvm current
ruby-2.2.2@pws2013
[smr@smr pws2013 (migrate-to-rails4)]$ git co master
Switched to branch 'master'
[smr@smr pws2013 (master)]$ rvm current
ruby-2.2.2@pws2013
[smr@smr pws2013 (master)]$ cd ../pws2013/
[smr@smr pws2013 (master)]$ rvm current

ruby-1.9.3-p286