Skip to content

Instantly share code, notes, and snippets.

@soeffing
soeffing / Gruntfile.js
Created September 4, 2013 09:30
Example of a Gruntfile.js configuration if you plan to develop with AngularJS and an Rails JSON API
// Generated on 2013-08-13 using generator-angular 0.3.1
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT });
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
// # Globbing
@soeffing
soeffing / Pretty Specs
Created February 28, 2014 17:24
Specs - Interview
1 require 'spec_helper'
2
3 describe User do
4 it 'I can create a new user' do
5 user = User.create(email: '[email protected]', fname: 'John', lname: 'Doe')
6 expect(user.id).to_not be_nil
7 end
8
9 it 'validates the required fields' do
10 user = User.new(email: nil, fname: nil, lname: nil)
@soeffing
soeffing / Model - Interview
Last active August 29, 2015 13:56
Pretty Model
module Legacy
class User < ActiveRecord::Base
# Constants
SENIORITY = {
0 => 'fan',
1 => 'novice',
2 => 'creative',
3 => 'senior',
4 => 'pro'
require 'open-uri'
class Ad < ActiveRecord::Base
# NOTE: These need to come before inclusion of CountsEntries module
STATES = [:uploaded, :encoded, :published, :invalid]
AVAILABLE_TYPES = %w(Video Print Radio Banner Concept)
include CountsEntries
@soeffing
soeffing / gist:78ce88f33d6538edb942
Created December 29, 2014 15:11
Drying up controllers
module Api
module V2
class AdsController < ApiController
respond_to :json
before_filter :return_attributes
before_filter :check_for_file_urls, only: [:update, :create]
def create
@object = ::Ad.new(params[:ad])
class AdsController < ApplicationController
before_action :require_auth, :default_params
# rubocop:disable Style/MethodLength
def index
@contest = Contest.find(@params[:contest_id], cookies, {})
query_params = 'embed[resource]=[id,image.url(:detail_preview),url(:mp4),url(:ogg)]' \
'&embed[nested][user][profile]=[email][last_name,first_name,avatar.url(:detail)]' \
'&embed[votes]=[all,rate,user_id]' \
module Api
module V2
class ApiController < ::ApplicationController
before_action :doorkeeper_authorize!, unless: :public_endpoint?
skip_before_filter :verify_authenticity_token
skip_before_filter :ensure_locale_and_platform
skip_before_filter :store_locale_and_platform
skip_before_filter :set_user_time_zone
"use strict";
function cache_store(callback, key, value) {
callback('store ' + value + ' to cache' );
};
function slow_provider_function(callback, key) {
const providerResult = 'provider result';
setTimeout(function() {
console.log('slow result fetched');
Raw Tm Ouput for "oracle_database" query
[(u'relational_database', 0.7822651624720822),
(u'rdsadmin_util', 0.7787341712211107),
(u'exec_rdsadmin', 0.7743804381040291),
(u'multitenant_architecture', 0.7698099597277153),
(u'redo_log', 0.7678954596330855),
(u'rc_droot', 0.7666727633511776),
(u'right-click_the_table', 0.7662226424822405),
(u'step-by-step_oracle', 0.7648878850923293),
--- Main topics of ThriveHive (Semrush + Spyfu keywords) based on detected clusters ----
Main Topcis:
Email Blasts
Facebook Tagging
Email subject line