Skip to content

Instantly share code, notes, and snippets.

@knowuh
knowuh / se
Last active August 29, 2015 14:16
Open the current directory with subl (sublime text) -- optionally using a project file.
#!/bin/bash
# Chmod this u+x and put it in your $PATH
# Open the first .sublime-project or the working dir
# in SublimeText assumes that `subl` is in your path
for f in ./*.sublime-project; do
if [ -e "$f" ]
then
subl --project "$f"
@knowuh
knowuh / replace_run_in_sequence.rb
Created December 10, 2014 20:25
Given a sequence run, and an anonymous activity_run, insert the anonymous run into the sequence_run.
def replace_run_in_sequence(seq_r_id, new_run_id)
new_run = Run.find(new_run_id)
sequence_run = SequenceRun.find(seq_r_id)
old_run = sequence_run.runs.detect { |r| r.activity_id == new_run.activity_id }
if old_run
clone_run(old_run,new_run)
if new_run.percent_complete > old_run.percent_complete
puts "removing run #{old_run.id}"
sequence_run.runs.delete(old_run)
@knowuh
knowuh / answers
Last active August 29, 2015 14:08
Answer which is choking process_external_activity_data_job.rb
[
{
"type":"open_response",
"question_id":"4462",
"answer":"The increase demands during day because it might be something you need it for and the same thing through the season.",
"is_final":false
},
{
"type":"open_response",
"question_id":"4463",
@knowuh
knowuh / -
Created October 31, 2014 18:20
def run_report(key)
r = Run.find_by_key(key)
r.sequence_run.runs.each do |r|
puts [r.id, r.activity_id, r.remote_endpoint, r.collaboration_run||"none", run.dirty?].join(", “)
end
end
ssh deploy@learn.concord.org
deploy@ip-10-30-155-89:~$ cd /web/portal/current
deploy@ip-10-30-155-89:/web/portal/current$ git log --pretty=oneline -10
cac87bea8fea23984101611962de5df0be34c0f6 fixes: "Preview" doesn't work when editing "Home Page Content " [#77842658]
8a35e2e5204d3032947029341e22cf411fbff245 Add genigames_data feature to learn portal
ef36bb660ee8c69b0d5bfc25a7575b508ecdff98 Add genigame_connector gem; bump json gem
c056e16d086a85aeddb821f48830985435f0660c Add geniverse_remote_auth feature to learn portal
@knowuh
knowuh / video_embed.html
Created August 29, 2014 10:46
video embed for has home-page (first pass)
<h3> Testing </h3>
<div>
The has project video:
</div>
<div style="border: 1px solid black; padding: 2em;">
<video controls="" autoplay="true" width="500" preload="auto" name="media">
<source src="https://has-production.s3.amazonaws.com/resources/HASPortalGuide/Resources/PortalGuideMovie-Broadband/Resources/PortalGuideMovie-Broadband%20-%20Broadband.m4v" type="video/mp4">
</video>
</div>
@knowuh
knowuh / SassMeister-input-HTML.html
Created August 27, 2014 22:24
Generated by SassMeister.com.
<div class="example-block">
<!-- START RIBBON -->
<div class="ribbon ribbon-red">
<div class="banner">
<div class="text">30 Day Free Trial</div>
</div>
</div>
<!-- END RIBBON -->
<div class="headline">Professional</div>
<div class="tagline">Perfect for business growth.</div>
@knowuh
knowuh / SassMeister-input-HTML.html
Created August 27, 2014 22:23
Generated by SassMeister.com.
<div class="example-block">
<!-- START RIBBON -->
<div class="ribbon ribbon-red">
<div class="banner">
<div class="text">30 Day Free Trial</div>
</div>
</div>
<!-- END RIBBON -->
<div class="headline">Professional</div>
<div class="tagline">Perfect for business growth.</div>
@knowuh
knowuh / gist:30c11efd0d17c925bbcf
Last active August 29, 2015 14:04
Extra slashes in CORS requests causes rack/cors errors on Heroku as of 07/25
Last night CORS requests stopped working for us on Heroku. We are using rack-cors (0.2.8) middleware.
It rurns out our request paths didn't match our rackup configuration.
The real question might be: why were these requests returning correct HTTP headers in the past?
One hypothesis is that some other processes was cleaning up requests with redundant slashes.
The configuration:
#…
require 'rack/cors'
@knowuh
knowuh / photo.py
Last active May 28, 2023 10:49
Blender script to turn an image data block into 3D cubes...
import bpy
import colorsys
"""
cubify-image.py - Turns each pixel of an image into a scaled cube.
Noah Paessel | @knowuh - updated on 2022-02-13 (test w Blender 3.1b)
MIT license http://opensource.org/licenses/MIT
WARNING: This script will generate a thousands objects (one per image pixel)
I recommend only using it with image with less than 40,000 pixels (200x200).