Skip to content

Instantly share code, notes, and snippets.

View casiodk's full-sized avatar

Nicolai Seerup casiodk

View GitHub Profile
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@casiodk
casiodk / publish_operation.rb
Created April 5, 2019 13:28
app/operations/posts/publish_operation.rb
module Posts
class PublishOperation < BaseOperation
attribute :post_id, Types::Strict::String
attribute :publish_on, Types::Strict::DateTime
def call!
guard!
validate!
publish
post.apply_post_published(event)
# frozen_string_literal: true
require 'openssl'
class Cipher
def initialize(klass:, id:, key:)
@cipherable_type = klass.name
@cipherable_id = id
@key = Base64.decode64(key)
end
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
@casiodk
casiodk / gist:f4edec1e1620ad340b22
Created November 5, 2015 09:55
Eksempel på circle.yml fil
deployment:
production:
branch: master
commands:
- heroku maintenance:on --app app_name_here
- git push git@heroku.com:app_name_here.git $CIRCLE_SHA1:master
- heroku run rake db:migrate --app app_name_here
- heroku run rake setup_something --app app_name_here
- heroku run rake fs:rebuild --app app_name_here
- heroku restart --app app_name_here
@casiodk
casiodk / gist:9d41e7fa2ae919597323
Last active September 17, 2015 15:18
job for updating width and height on images
Image.all.each do |image|
begin
file = File.new("image.jpg", "w").binmode
open(image.image_url, "r") { |data| file.write data.read }
image.width, image.height = ::MiniMagick::Image.open(file)[:dimensions]
image.save
rescue
puts "Øv"
end
puts image.inspect
@casiodk
casiodk / Carrierwave testing
Created September 17, 2015 14:28
Speed up carrierwave tests
# -*- encoding : utf-8 -*-
CarrierWave.configure do |config|
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['AWS_REGION']
}
config.fog_directory = "#{ ENV['FOG_DIRECTORY'] }#{ Rails.env }"
config.fog_public = false
@casiodk
casiodk / gist:1063625
Created July 4, 2011 17:05
Progress Bar
//VIDEOS CONTROLLER//
def new
@video = Video.new
@uuid = (0..29).to_a.map { |x| rand(10) }
end
def create
@video = Video.new(params[:video])
@video2 = Video.new(params[:video])
require "rubygems"
require "ruby-audio"
require "fileutils"
require "rmagick"
# TODO: set these with command line options
# pixel width of final waveform image
Width = 1800
# pixel height of final waveform image
Height = 280