git config --global init.templatedir '~/.git-templates'
mkdir -p ~/.git-templates/hooks
-
create ~/.tig-brother/checkouts.db (sqlite3) from the dump
-
copy the hook script
-
git init
in the git repo
#!/usr/bin/env ruby | |
require 'wanikani' | |
Wanikani.api_key = 'YOUR_WANIKANI_API_KEY' | |
wanikani_kanji_data = Wanikani::Level.kanji(*(1..60)) | |
def color_for(item) | |
case (item['user_specific'] || {})['srs'] | |
when 'apprentice' then '#dd0093' |
git config --global init.templatedir '~/.git-templates'
mkdir -p ~/.git-templates/hooks
create ~/.tig-brother/checkouts.db (sqlite3) from the dump
copy the hook script
git init
in the git repo
class InstagramRealTimeUpdatesController < ActionController::Base | |
def callback | |
case request.method_symbol | |
when :get | |
render text: Instagram.meet_challenge(params, ENV['INSTAGRAM_VERIFY_TOKEN']) | |
when :post | |
Instagram.process_subscription(request.body.read) do |handler| | |
handler.on_user_changed do |user_id, data| | |
media_id = (data['data'] || {})['media_id'] | |
InstagramJob.perform_later user_id, media_id |
require 'mechanize' | |
require 'kuromoji' | |
dom = Mechanize.new.get("http://tatoeba.org/eng/sentences/show/jpn") | |
jp_sentence = dom.parser.at("//div[@lang = 'ja']").text | |
# => "万一に備えて傘を持っていった方がいいだろうな。" | |
jp_sentence_w_furigana = dom.parser.at("//div[@lang = 'ja-Latn']").text | |
# => "万一[まんいち] に[] 備え[そなえ] て[] 傘[かさ] を[] 持っ[もっ] て[] いっ[] た[] 方[ほう] が[] いい[] だろ[] う[] な[] 。[]" | |
en_sentence = dom.parser.at("//div[@lang = 'en']").text | |
# => "Perhaps I should take an umbrella with me just in case." |
# using the awesome squeel gem | |
has_many :shares, dependent: :destroy | |
has_many :stories, through: :shares | |
has_many( | |
:stories_this_month, -> do | |
where do | |
date_part('month', created_at).eq(Date.today.month) & | |
date_part('year', created_at).eq(Date.today.year) |
-- cards are what you review. easy! | |
CREATE TABLE cards ( | |
id integer primary key, | |
-- the epoch milliseconds of when the card was created | |
nid integer not null, | |
-- notes.id | |
did integer not null, | |
-- deck id (available in col table) | |
ord integer not null, | |
-- ordinal, seems like. for when a model has multiple templates, or thereabouts |
### app access token | |
graph = Koala::Facebook::OAuth.new APP_ID, APP_SECRET | |
graph.get_app_access_token # => APP_TOKEN | |
### create test users with permissions | |
test_users = Koala::Facebook::TestUsers.new app_id: APP_ID, secret: APP_SECRET | |
user = test_users.create true, 'email,user_birthday,user_posts', name: 'Bob' | |
# => | |
# { "id" => USER_ID, | |
# "access_token" => USER_ACCESS_TOKEN, |
git log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit |
module MyApp | |
module V1 | |
class API < Grape::API | |
version 'v1', using: :path | |
format :json | |
before do | |
header['Access-Control-Allow-Origin'] = '*' | |
header['Access-Control-Request-Method'] = '*' |
class Note < ActiveRecord::Base | |
# The true polymorphic association | |
belongs_to :subject, polymorphic: true | |
# The trick to solve this problem | |
has_one :self_ref, class_name: self, foreign_key: :id | |
has_one :volunteer, through: :self_ref, source: :subject, source_type: Volunteer | |
has_one :participation, through: :self_ref, source: :subject, source_type: Participation | |
end |