Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
libs=( "/usr/local/lib/libmacfuse_i32.2.dylib" \
"/usr/local/lib/libosxfuse_i32.2.dylib" \
"/usr/local/lib/libosxfuse_i64.2.dylib" \
"/usr/local/lib/libmacfuse_i64.2.dylib" \
"/usr/local/lib/libosxfuse_i32.la" \
"/usr/local/lib/libosxfuse_i64.la" \
"/usr/local/lib/pkgconfig/osxfuse.pc" )
@anhkind
anhkind / gist:5523900
Created May 6, 2013 08:01
Fix: (ActiveRecord::StatementInvalid) "Mysql::Error: Lock wait timeout exceeded; try restarting transaction: UPDATE some_table.....
sudo vi /etc/my.cnf
Add/ Uncomment this: innodb_lock_wait_timeout=120
launchctl unload /usr/local/Cellar/mysql/5.5.28/homebrew.mxcl.mysql.plist
launchctl load /usr/local/Cellar/mysql/5.5.28/homebrew.mxcl.mysql.plist
vi:
devise:
confirmations:
confirmed: Xác nhận tài khoản thành công! Bạn hiện đang đăng nhập.
send_instructions: Bạn sẽ nhận được email hướng dẫn xác nhận tài khoản trong vài phút nữa.
send_paranoid_instructions: Nếu email của bạn có trong hệ thống, bạn sẽ nhận được email hướng dẫn xác nhận tài khoản trong một vài phút nữa.
failure:
already_authenticated: Bạn đã đăng nhập.
inactive: Tài khoản của bạn chưa được kích hoạt.
invalid: Email hoặc mật khẩu không chính xác.
class BinaryReverse
def reverse(n)
res = 0
while n > 1 do
res = res * 2 + n % 2
n = n / 2
end
res * 2 + 1
end
end
@anhkind
anhkind / pre-commit
Last active December 22, 2015 06:49
Git pre-commit hook with rspec
#!/usr/bin/env ruby
exit 0 if ENV["SKIP_TEST"] # set environment SKIP_TEST to skip rspec
require 'pty'
html_path = "/tmp/rspec_results.html"
begin
puts "Running rspec ..."
PTY.spawn( "rspec spec --format h > /tmp/rspec_results.html" ) do |stdin, stdout, pid|
begin
stdin.each { |line| print line }
rescue Errno::EIO
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@anhkind
anhkind / gist:fcbd6bcddbf28abaa211
Created July 25, 2014 13:53
Run ngrok to background
ngrok -log=stdout 80 > ngrok.log &
@anhkind
anhkind / bookmarklet
Last active August 29, 2015 14:07
Inject JS file
javascript:(function(){ var file = prompt("Paste URL of the js file here:"); document.body.appendChild(document.createElement('script')).src=file;})()
@anhkind
anhkind / heroku_postgres.sh
Last active August 16, 2022 11:16
Heroku postgres: dump and restore
# Details: https://devcenter.heroku.com/articles/heroku-postgres-import-export
# Create postgres role (v13) if not existing yet
createuser -s postgres -U <os-username>
# Dump
heroku pg:backups capture
curl -o latest.dump `heroku pg:backups public-url`
# Restore to local db