Skip to content

Instantly share code, notes, and snippets.

@dimroc
dimroc / clearCache.sh
Created July 11, 2017 15:59 — forked from benjamincharity/clearCache.sh
Clear the cache for a CircleCI project.
curl -X DELETE https://circleci.com/api/v1/project/:username/:project/build-cache?circle-token=:token
#!/bin/bash
for i in {0..99}; do
newname=`printf "%03d" $i`
mv "cleaned_fg/$i.jpg" "cleaned_fg/$newname.jpg"
done
@dimroc
dimroc / decrementfiles.sh
Created May 4, 2017 02:42
Decrement the number in file names in bulk
#!/bin/bash
for i in {1..546}; do
mv "tmp/frames/source/$i.jpg" "tmp/frames/source/$(($i-1)).jpg";
done
# Go to home directory
cd ~
# You can change what anaconda version you want at
# https://repo.continuum.io/archive/
wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
bash Anaconda3-4.2.0-Linux-x86_64.sh -b -p ~/anaconda
rm Anaconda3-4.2.0-Linux-x86_64.sh
echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.bashrc
#!/bin/bash
echo "Granting AWS ML access to S3 bucket dev.machinelearningservice.dimroc.com..."
aws s3api put-bucket-policy --bucket dev.machinelearningservice.dimroc.com --policy file://ml_bucket_policy.json
@dimroc
dimroc / cors.xml
Created March 26, 2017 03:36
CORS S3 Configuration to allow jquery.fileupload direct uploads from client
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
@dimroc
dimroc / spec_view_helpers.rb
Last active May 4, 2018 02:29
Easily use view helpers in specs with `h.number_to_currency`
module ViewHelpers
def h
ViewHelper.instance
end
class ViewHelper
include Singleton
include ActionView::Helpers::NumberHelper
include ApplicationHelper
end
@dimroc
dimroc / past_enum.rb
Created March 15, 2017 15:38
Class method `past_enum` to be used alongside as_enum (aka SimpleEnum) to generate past_*? methods
module PastEnum
extend ActiveSupport::Concern
class_methods do
def past_enum(enum_name)
pluralized = enum_name.to_s.pluralize
values = self.public_send(pluralized)
# Generate past_* methods.
# e.g. past_draft?
remote: URI::InvalidURIError: expected file:// scheme:
remote: /tmp/build_02fbcf7b380e429bf9912ee9e770601c/app/assets/config/manifest.js:1
remote: /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/uri_utils.rb:94:in `parse_asset_uri'
remote: /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/unloaded_asset.rb:134:in `load_file_params'
remote: /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/unloaded_asset.rb:64:in `params'
remote: /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:34:in `load'
remote: /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote: /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/
module Stubs
module S3
def s3_succeeds_to_get_fixture(fixture)
WebMock.stub_request(:get, /https:\/\/s3\.amazonaws\.com\/test\.someurl\.com\/csv_imports\/.*#{fixture}/).
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>''}).
to_return(:status => 200, :body => fixture_url(fixture), :headers => {})
end
def s3_succeeds_to_check_files
WebMock.stub_request(:head, /https:\/\/s3\.amazonaws\.com\/test\.someurl\.com\/.*/).