Skip to content

Instantly share code, notes, and snippets.

Devon Hinton devmanhinton

  • dv01
  • New York City
View GitHub Profile
@devmanhinton
devmanhinton / gist:b360be3595e8f3599074
Created Apr 30, 2015
Auto Start ClassPath virtualenv
View gist:b360be3595e8f3599074
This is for zsh so you might have to change for other shells but general idea is the same
Note: Change 'ClassPath' to the root of your project
chpwd () {
case $PWD in
*ClassPath*)
python -c 'import sys; print sys.real_prefix' 2>/dev/null 1>/dev/null || source bin/activate
esac
}
View gist:8000650
#decode base64
Dir.mkdir('decoded_photos/')
Dir.foreach('./photos') do |item|
next if !item.match(/.*_signature_image/)
base64_encoded = File.read("photos/" + item)
decocded = Base64.decode64(base64_encoded.split(',')[1])
File.open("decoded_photos/#{item}.png", 'wb') do |file|
file.write(decocded)
end
end
View gist:8000335
bucket = Storage.fetch.buckets["postcard_batch"]
Dir.mkdir('photos/')
bucket.objects.each do |obj|
File.open("photos/#{obj.key}.png", 'wb') do |file|
obj.read do |chunk|
file.write(chunk)
end
end
end
View gist:8000136
bucket = Storage.fetch.buckets["postcard_batch"]
Dir.mkdir('photos/')
bucket.objects.each do |obj|
File.open("photos/#{obj.key}", 'wb') do |file|
obj.read do |chunk|
file.write(chunk)
end
end
end
@devmanhinton
devmanhinton / gist:7197605
Last active Dec 26, 2015
Alternative to Current Collection Recognition
View gist:7197605
Hey!
Currently, a collection is recognized by the rules.js "collection" rule-- The el has a child that is the singular version
of itself.
This adds a cognitive load because it adds a conidtional to another rule:the model/scoping rule.
The model/scoping rule without collections: 'A dom elem with a class that ends in a dash will bind the children
of that dom element to the child of that name of the current model in scope'
@devmanhinton
devmanhinton / gist:7103303
Created Oct 22, 2013
Way to include views
View gist:7103303
Add EndDash.View.extend
== Client can call EndDash.view.extend({
.... Normal Backbone View things ....
})
Under the hood will return "Backbone.View.extend({
.... Same Normal Backbone View things ....
})
@devmanhinton
devmanhinton / gist:7013095
Last active Dec 25, 2015
Combing many files to one end_dash_templates.js
View gist:7013095
var fs = require('fs')
, path = require('path')
, _ = require('underscore')
, outputPath = __dirname
, filesToParse = 0
, callback
var compressFiles = function(templatesLocation, outputPath, callback) {
if (arguments.length != 3) {
throw new Error("All three arugments are required")
@devmanhinton
devmanhinton / gist:6875413
Created Oct 7, 2013
Fun times with combining javascript files
View gist:6875413
1 #!/bin/bash
2 pushd ~/Amicus/suspendors_project/suspendersTest/client_side_js
3 if [ -e "bundle.js" ]
4 then
5 echo "removing old bundle.js"
6 rm -f bundle.js
7 fi
8 if [ -e "main.js" ]
9 then
10 echo "removing old bundle.js"
View gist:6818895
7:29:15 BUILDER: devon, staging, brief:oct3_integration: restarting first service
COMMAND: sudo su deploy sg apps -c 'cd -P /mnt/services/brief/current && TORQUEBOX_HOME=/mnt/torquebox/current JBOSS_HOME=/mnt/torquebox/current/jboss JRUBY_HOME=/usr/bin/jruby /usr/bin/jruby/bin/jruby -S torquebox deploy --name=brief-service .'
status: 1; err: ; out: Errno::EACCES: Permission denied - Permission denied
utime at org/jruby/RubyFile.java:1040
touch at /usr/local/share/jruby-1.7.2/lib/ruby/1.9/fileutils.rb:1146
each at org/jruby/RubyArray.java:1613
touch at /usr/local/share/jruby-1.7.2/lib/ruby/1.9/fileutils.rb:1143
deploy_yaml at /usr/local/share/jruby-1.7.2/lib/ruby/gems/shared/gems/torquebox-rake-support-2.3.0/lib/torquebox/deploy_utils.rb:317
deploy at /usr/local/share/jruby-1.7.2/lib/ruby/gems/shared/gems/torquebox-2.3.0/bin/torquebox:112
__send__ at org/jruby/RubyBasicObject.java:1665
You can’t perform that action at this time.