Skip to content

Instantly share code, notes, and snippets.

@iamdionysus
iamdionysus / foo.scala
Created January 8, 2019 09:44
Scala: Pass Seq to var-args function
def foo(os: String*) = os.toList.foreach(println)
val args = Seq("hi", "there")
foo(args:_*)
@iamdionysus
iamdionysus / insta-java-8.sh
Created November 30, 2016 02:49
Install java 8 and remove 7 in amazon linux
sudo yum install java-1.8.0 -y
sudo yum remove java-1.7.0-openjdk -y
@iamdionysus
iamdionysus / pull-all.sh
Last active February 8, 2016 04:23
git pull for all subdirectories
ls | xargs -I{} git -C {} pull
ls | xargs -P10 -I{} git -C {} pull
@iamdionysus
iamdionysus / install.sh
Created November 6, 2015 15:10
install
#!/usr/bin/env bash
######################################################################
# Utility variable and function
######################################################################
GREEN='\033[0;32m'
NC='\033[0m' # No color
say()
@iamdionysus
iamdionysus / copy_paste_win32ole_excel.rb
Last active August 29, 2015 14:18
ruby win32ole copy and paste last row in excel
excel = WIN32OLE.new 'Excel.Application'
excel.visible = true
workbook = excel.Workbooks.open "path/to/file"
sheet = workbook.Worksheets 1
def excel_copy_and_paste_last_row excel, workbook, sheet
last_row = sheet.UsedRange.Rows.Count
sheet.Rows(last_row).copy
sheet.Cells(last_row + 1, 1).Select
Sub test_set_table()
ActiveDocument.Tables(4).Cell(1, 1).Range.Text = "Blah"
End Sub
Sub test_get_http()
Dim result As String
Dim myURL As String
@iamdionysus
iamdionysus / install-recent-ghc.md
Created June 20, 2014 00:50
How to install recent ghc and cabal for ubunt 12.04 by adding ppa

Add apt-repository, install ghc and cabal

I used this repository.

sudo add-apt-repository ppa:hvr/ghc
sudo apt-get install ghc-7.8.3
sudo apt-get install cabal-install-1.20

Add the bin directory to PATH

The packages install into /opt/ghc/$VER and /opt/cabal/$VER respectively. If you use zsh, make sure to add to bash settings as well. In Emacs haskell-mode, when hasekll-interactive-bring command tries to load ghci, the PATH envrionment seems to be under bash. Save the settings and test.

@iamdionysus
iamdionysus / how-to-make-passenger-work-with-rails-4-1.md
Last active August 29, 2015 14:02
How to make passenger work with rails 4.1

Issue

rails 4.1 production setting uses secret_key_base by reading values from the environment for security reason. If ENV["SECRET_KEY_BASE"] doesn't exist nginx + passenger will raise error. You can simply set up envrionment variable in the shell, but under rvm, it sometimes gets tricky.

Solution

Use figaro gem and set it up

  • Gemfile, add gem 'figaro' and bundle update
  • figaro install : this does
    • create config/application.yml
    • append .gitignore
  • config/application.yml, add SECRET_KEY_BASE: your_key
@iamdionysus
iamdionysus / how-to-make-pry-work-with-inf-ruby.md
Created June 6, 2014 02:56
backup for the how to make pry work with inf-ruby

At least from my experience and set up, this is not a proper way to make pry work under emacs 24.3 and current inf-ruby with MEPLA installation. Since this gist shows up quite high in google search result, I'd like to comment here what was the problem and how I solved it.

Issues

  • (add-to-list 'inf-ruby-implementations '("pry" . "pry")) causes init.el load error. It's already implemented in the inf-ruby.el source so I don't think it's necessary to add again.

  • (setq inf-ruby-default-implementation "pry") actually makes inf-ruby run the pry. However, with flaws. If pry is running with this set up and if I send the buffer/region/block, I get NameError: uninitialized constant IRB from (pry):1:in `__pry___'. Again, I looked into the inf-ruby.el source code and it looks like inf-ruby is already taking care of the pry smartly. So this set up shouldn't be added to init.el as well.

Solution

  • don't add anything which is mentioned above to init.el to make pry work especially if it's in