Skip to content

Instantly share code, notes, and snippets.

View bradical's full-sized avatar

Bradley Wagner bradical

View GitHub Profile
<script src="https://cc.cdn.civiccomputing.com/8.0/cookieControl-8.0.min.js"></script>
<script>
var config = {
apiKey: '<API-KEY>',
product: 'PRO',
necessaryCookies: ['<GTM_COOKIE>'], // for GTM itself
optionalCookies: [{
name: 'analytics',
label: 'Analytics',
description: 'We use cookies to track analytics and engagement with things like videos on our sites including Google Analytics, FullStory, and Spectate.',
@bradical
bradical / bad-zip-code.java
Created August 14, 2013 22:51
A bad way to zip 800,000 files in a directory
public void zipFiles(File folderToZip, String zipFileToCreate)
{
ZipOutputStream zipStream = new ZipOutputStream(new FileOutputStream(zipFileToCreate));
File[] files = folderToZip.listFiles();
for (File file : files)
{
String fileAbsolutePath = file.getAbsolutePath();
String zipEntryName = fileAbsolutePath.substring(folderToZip.getAbsolutePath().length() + 1);
FileInputStream inputStream = new FileInputStream(file);
ZipEntry zipEntry = new ZipEntry(zipEntryName);
@bradical
bradical / review date workflow
Created March 18, 2013 15:42
Simple review date workflow for Cascade
<system-workflow-definition name="test" initial-step="initialize" >
<triggers>
<trigger name="email" class="com.cms.workflow.function.EmailProvider" />
<trigger name="publish" class="com.cms.workflow.function.Publisher" />
<trigger name="merge" class="com.cms.workflow.function.Merge" />
<trigger name="assignStepIfUser" class="com.cms.workflow.function.AssignStepIfUser" />
<trigger name="assignToGroupOwningAsset" class="com.cms.workflow.function.AssignToGroupOwningAsset" />
<trigger name="assignToWorkflowOwner" class="com.cms.workflow.function.AssignToWorkflowOwner" />
<trigger name="delete" class="com.cms.workflow.function.Delete" />
<trigger name="deleteAndUnpublish" class="com.cms.workflow.function.DeleteAndUnpublish" />
@bradical
bradical / gist:4490354
Created January 9, 2013 03:42
Rails upgrade
cd /path/to/my/project
git branch rails_3_2_11_upgrade
vi Gemfile # Change: gem 'rails', "3.2.10" to: gem 'rails', "3.2.11"
bundle update rails
git commit -a -m "Upgrading Rails to 3.2.11 to fix security issues"
git push -u origin rails_3_2_11_upgrade
hub "Upgrade Rails to 3.2.11 to fix security issues" -b master # Create a PR from the branch; Note the issue number
hub browse user/project pull/<PULL_REQUEST_NUM> # Open it in the browser
# Merge that branch if you can!
# Let your CI server run your tests and deploy your changes
@bradical
bradical / size-queries.sql
Created August 6, 2012 20:59
Queries to get size of various things in Cascade
# Query to get the file and associated blob data for all Files in a Site and to sum the length of the blobs to get the total byte size for all the files
select fc.id,b.id,octet_length(b.data), (sum(octet_length(b.data))/1024/1024) as "Total Bytes(MB)" from cxml_foldercontent fc left join cxml_blob b on fc.fileBlobId = b.id where siteId='<SITE_ID>' and assetType='FIL' and isCurrentVersion=1 order by octet_length(b.data) desc;
# Same as above, but does not sum and instead lists files in descending order by size
select fc.cachePath, b.id,octet_length(b.data) from cxml_foldercontent fc left join cxml_blob b on fc.fileBlobId = b.id where siteId='9a6807160a00016b00e06bc38171e0d5' and assetType='FIL' and isCurrentVersion=1 order by octet_length(b.data) desc;
# Same as first one except for Page and XML content
@bradical
bradical / gist:1473303
Created December 13, 2011 18:45
DelayedJob ActiveRecord Queries
# Output failed jobs by id with the delayed job type, associated ActiveRecord type, id, and method if applicable
Delayed::Job.where("failed_at is not null").select("id, handler, run_at, failed_at, last_error, job_type").order("id ASC").each { |j| puts "Id: #{j.id}\n DJ Type: #{$1 if j.handler =~ /!ruby\/struct:Delayed::(\w*) \n/}\n Failed at: #{j.failed_at}\n Object type: #{$1 if j.handler =~ /\nobject: !ruby\/(.*?)\s*\n/}\n Object Id: #{$1.to_i if j.handler =~ / id: (\d*)\n/}\n Method Name: #{$1 if j.handler =~ /\nmethod_name: (.*)\n/}\n Size: #{j.handler.size}\n\n\n"}
# Failed jobs
Delayed::Job.where('failed_at is not null')