Skip to content

Instantly share code, notes, and snippets.

@yortz
yortz / useful_queries.rb
Last active September 12, 2019 10:34
Useful queries for stats retrieval
# Total number of users from last month
User.where(last_sign_in_at: 1.month.ago..Date.today).count
User.where(last_sign_in_at: 1.month.ago..Date.today).order(:last_sign_in_at).pluck(:email, :last_sign_in_at)
# Number of users who updated at least one experiment in the last month
Experiment.joins(:user).where(updated_at: 1.month.ago..Date.today).order(:updated_at).pluck(:updated_at, :id, :title, 'users.email').uniq {|r| r.last}.count
Experiment.joins(:user).where(updated_at: 1.month.ago..Date.today).order(:updated_at).pluck(:updated_at, :id, :title, 'users.email').uniq {|r| r.last}
Experiment.joins(:user).where(updated_at: 1.month.ago..Date.today).order(:updated_at).pluck(:updated_at, :id, :title, 'users.email').uniq {|r| r.last}.map {|a| {a.first.strftime("%b-%Y") => { experiment_title: a[2], user_email: a.last } }}
# Number of experiments,grouped by users, created per month for the past 18 months
@yortz
yortz / app.js.coffee
Created February 3, 2016 12:58
require fancybox in octopress for octopress gallery plugin
#= require ./libs/jquery-1.9.1
#= require modernizr-2.0
#= require ender
#= require jquery.waitforimages
#= require fancybox/jquery.mousewheel-3.0.6.pack
#= require fancybox/jquery.fancybox.pack
#= require underscore
#= require twitter
#= require gallery
#= require ./libs/lunr.min
@yortz
yortz / gallery_tag.rb
Created February 2, 2016 10:13
gallery tag plugin that integrates lightbox functionality to octopress image gallery
@yortz
yortz / koala.rb
Created July 28, 2015 07:53
koala test
# go to facebook explorer api and get a token, be sure to add user_posts to the app permission!!!
graph_api = Koala::Facebook::API.new("your token in here")
graph_api.get_connections("me", "posts", { limit: 200 } )
@yortz
yortz / anagram_test.rb
Created August 13, 2013 11:25
exercism ruby/anagram test
require 'minitest/autorun'
require_relative 'anagram'
class AnagramTest < MiniTest::Unit::TestCase
def test_no_matches
detector = Anagram.new('diaper')
assert_equal [], detector.match(%w(hello world zombies pants))
end
@yortz
yortz / gist:5867564
Last active December 19, 2015 00:19
defmodule Twitter do
def get_oauth_token
consumer_key= "yourkey"
consumer_secret = "yoursecret"
url = 'https://api.twitter.com/oauth'
consumer = Oauthex.Consumer.new(
key: :erlang.binary_to_list(consumer_key),
secret: :erlang.binary_to_list(consumer_secret)
let g:ScreenImpl = 'Tmux'
let g:ScreenShellTmuxInitArgs = '-2'
let g:ScreenShellInitialFocus = 'shell'
let g:ScreenShellQuitOnVimExit = 0
" Screen settings
map <F5> :ScreenShellVertical<CR>
command! -nargs=? -complete=shellcmd W :w | :call ScreenShellSend("load '".@%."';")
map <Leader>c :ScreenShellVertical bundle exec rails c<CR>
map <Leader>r :w<CR> :call ScreenShellSend("rspec ".@% . ':' . line('.'))<CR>
map <Leader>e :w<CR> :call ScreenShellSend("cucumber --format=pretty ".@% . ':' . line('.'))<CR>
map <Leader>b :w<CR> :call ScreenShellSend("break ".@% . ':' . line('.'))<CR>
# Generating Site with Jekyll
WARNING: 'noise.png %}' was not found (or cannot be read) in /Users/yortz/code/projects/website.com/source/_assets/images/{% asset_path images
File not found or cannot be read: /Users/yortz/code/projects/website.com/source/_assets/images/{% asset_path images/straight-border.png %}
Configuration from /Users/yortz/code/projects/website.com/_config.yml
Building site: source -> public
Successfully generated site: source -> public
@yortz
yortz / gist:5225462
Created March 22, 2013 23:12
jekyll-assets octopress theme.scss
$noise-bg: image-url("{% asset_path images/noise.png %}") top left !default;
$img-border: inline-image("{% asset_path images/straight-border.png %}");
// Main Link Colors
$link-color: #e11e30 !default;
$link-color-hover: adjust-color($link-color, $lightness: 20, $saturation: 45) !default;
$link-color-visited: adjust-color($link-color, $hue: 80, $lightness: -4) !default;
$link-color-active: adjust-color($link-color-hover, $lightness: -15) !default;
// Main Section Colors