Skip to content

Instantly share code, notes, and snippets.

View namor's full-sized avatar

John Wong namor

View GitHub Profile
@namor
namor / cto_line.pine
Created November 16, 2022 15:09 — forked from basnijholt/cto_line.pine
CTO Line indicator for TradingView
//@version=4
study(title="CTO Line", shorttitle="CTO", overlay=true, resolution="")
smma(src, length) =>
smma = 0.0
smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length
smma
v1 = smma(hl2, 15)
m1 = smma(hl2, 19)
m2 = smma(hl2, 25)
v2 = smma(hl2, 29)
Migrator.CourseContent.import_from_elula(986, 46, 1900)
Migrator.CourseContent.import_from_elula(987, 46, 1931)
Migrator.CourseContent.import_from_elula(988, 46, 1917)
Migrator.CourseContent.import_from_elula(989, 46, 1899)
["April 2019: Character Month, 986, 1900",
"June 2019: Love Life Month , 987, 1931",
"May 2019: Spiritual Life Month, 988, 1917",
"Welcome to the Lifebook Membership!, 989, 1899"]
@namor
namor / upsert.ex
Created May 29, 2019 09:20
Watch Progress Upsert
def upsert(%{user_id: user_id, media_id: media_id, current_time: current_time, total_time: total_time, event_time: event_time} = data)
progress_percentage = nil
seconds_left = nil
on_conflict_query = from(p in Progress,
where: p.user_id = user_id and p.media_id = media_id and p.last_event_at < event_time,
update: [set: [current_time: ^current_time, total_time: ^total_time, event_time: event_time, progress: progress_percentage, seconds_left: seconds_left]])
Repo.insert(data, on_conflict: on_conflict_query, conflict_target: [:user_id, :media_id])
end
@namor
namor / thumbnail
Created June 24, 2014 06:17
Transloadit Template - Thumbnail any media type (file / image / video)
{
"steps": {
"import": {
"robot": "/s3/import"
},
"videos": {
"use": "import",
"robot": "/file/filter",
"accepts": [
[
@namor
namor / Gemfile
Created January 14, 2014 04:19
Problem with BSON
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 4.0.2'
gem 'hashie'
gem 'simple_form'
gem 'dropzonejs-rails'
gem 'settingslogic'
gem 'kaminari'
gem 'devise'
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 4.0.2'
gem 'hashie'
gem 'simple_form'
gem 'dropzonejs-rails'
gem 'settingslogic'
gem 'kaminari'
gem 'devise'
@namor
namor / Gemfile
Created January 14, 2014 04:18
Gemfile for CircleCI Failure
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 4.0.2'
gem 'hashie'
gem 'simple_form'
gem 'dropzonejs-rails'
gem 'settingslogic'
gem 'kaminari'
gem 'devise'
@namor
namor / gist:5335435
Last active December 15, 2015 22:49
Workflow for working with Github
== Git(Hub) workflow
# Create new branch
git checkout -b <feature-branch> --track
git push -u origin <feature-branch>
<YOUR git commits>
# Do this often
@namor
namor / capybara-helpers.rb
Created March 5, 2012 07:59 — forked from jc00ke/capybara-helpers.rb
Capybara helpers
def screenshot
require 'capybara/util/save_and_open_page'
now = Time.now
p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}"
Capybara.save_page body, "#{p}.html"
path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s
page.driver.render path
Launchy.open path
end
@namor
namor / gist:1281716
Created October 12, 2011 16:24 — forked from SethWilson/gist:1277194
Installing Ruby 1.9.2 with rbenv
brew install --HEAD rbenv
brew install --HEAD ruby-build
brew install --HEAD https://raw.github.com/jasoncodes/homebrew/rbenv-vars/Library/Formula/rbenv-vars.rb # https://github.com/mxcl/homebrew/pull/7891
brew install readline
brew install ctags
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
echo 'gem() { rbenv exec gem "$@" && rbenv rehash && hash -r; }' >> ~/.bash_profile
exec
CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)" rbenv install 1.9.2-p290
rbenv global 1.9.2-p290