Skip to content

Instantly share code, notes, and snippets.

View zengfengbo's full-sized avatar

bobo zengfengbo

  • www.biocsi.com
  • Wuhan.China
View GitHub Profile

Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

Specs
AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4 or 5
@zengfengbo
zengfengbo / query_freq.cc
Created September 24, 2017 17:13 — forked from chenshuo/query_freq.cc
Sort queries by their frequencies.
// answer to http://weibo.com/1915548291/z2UtyzuvQ
// see also http://www.cnblogs.com/baiyanhuang/archive/2012/11/11/2764914.html
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <fstream>
#include <iostream>
@zengfengbo
zengfengbo / gist:b506a7ed46a8a050b18a5fcc98fa00da
Created January 11, 2017 11:58 — forked from ibogun/gist:ec0a4005c25df57a1b9d
Installing gcc 4.9 & g++ 4.9 on Ubuntu 12.04 OR Ubuntu 14.04
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
sudo apt-get install g++-4.9
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@zengfengbo
zengfengbo / bwa-fb.py
Last active August 29, 2015 14:12 — forked from brentp/bwa-fb.py
"""
align reads with bwa mem
remove duplicates with samblaster
call variants with freebayes
"""
import sys
import os.path as op
import os
def base(fq):