Skip to content

Instantly share code, notes, and snippets.

View cramhead's full-sized avatar

Marc d'Entremont cramhead

  • Squamish, BC, Canada
View GitHub Profile
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
@cramhead
cramhead / serverImages.js
Last active January 2, 2016 12:29
load image into CollectionFS
fs = Npm.require('fs');
var loadImages = function() {
var assets_folder = getAssetPath();
var image = fs.readFileSync(assets_folder + '/20131022_GR-Limited-Edition.jpg', 'binary');
//fs.writeFileSync('/Users/cram/Desktop/test.jpg', image, {encoding: 'binary', mode: 777});
var saved = Images.storeBuffer('20131022_GR-Limited-Edition.jpg', image, {encoding: 'binary', noProgress: true, contentType: 'image/jpeg'});
};
loadImages();
@cramhead
cramhead / assetPath.js
Created January 7, 2014 18:06
get meteor asset path
function getAssetPath() {
var meteor_root = Npm.require('fs').realpathSync(process.cwd() + '/../');
console.log(meteor_root);
var application_root = Npm.require('fs').realpathSync(meteor_root + '/../');
// if running on dev mode
if (Npm.require('path').basename(Npm.require('fs').realpathSync(meteor_root + '/../../../')) == '.meteor') {
application_root = Npm.require('fs').realpathSync(meteor_root + '/../../../../');
}
@cramhead
cramhead / every.js
Created June 13, 2014 19:16
call the function every so many calls
// call the func every count times
var every = function(count, func) {
var self = this,
counter = 0;
return function(arg) {
counter++;
// console.log('counter is ' + counter);
if (counter === count) {
counter = 0;
// console.log("reset counter");
@cramhead
cramhead / gist:dc431ab0417fce7aa965
Created July 6, 2014 18:33
Adding and removing collection-hooks in a meteor app
var hookHandles = [];
var initCollectionHooks = function() {
//once the seed process is complete or no seeding takes place add the listener
hookHandles.push(
Collectibles.after.insert(function(userId, doc) {
// get the imageIds and set them as being linked
App.emitter.emit('collectible.added', userId, doc);
})
@cramhead
cramhead / gist:2a25bbe6d43c75152b99ae0f62d68cf4
Created February 2, 2017 19:18 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@cramhead
cramhead / .block
Created June 13, 2017 23:09
fresh block
license: mit
@cramhead
cramhead / .block
Last active June 14, 2017 21:47
tree example
license: mit
@cramhead
cramhead / .block
Last active June 14, 2017 16:49
fresh block
license: mit
@cramhead
cramhead / .block
Last active June 14, 2017 19:37
Sample chart from Mike's tutorial https://bost.ocks.org/mike/bar/2/
license: mit