Skip to content

Instantly share code, notes, and snippets.

View sheenobu's full-sized avatar
🙃
smug

Sheena Artrip sheenobu

🙃
smug
View GitHub Profile
@sheenobu
sheenobu / share.gradle
Created March 29, 2012 16:02
Getting a project to use your local alfresco dependency jars within eclipse, useful for the Alfresco Shaded WAR file.
apply plugin: 'eclipse'
apply plugin: 'java'
eclipse {
classpath {
file {
withXml {
/* Iterate over each share dependency file and add it to the eclipse classpath */
def node = it.asNode()
def alfresco_dir = project.property('alfresco.directory')
@sheenobu
sheenobu / flaskr.py
Created June 14, 2012 18:46
Flaskr - utility building modular flask applications. Prototype/v0.0.1
#!/usr/bin/env python
# simple command line application and utility library for building modular flask applications.
# Just drop me in your root, chmod +x ./testserver.py, and ./flaskr.py init
# then you can chmod +x ./testserver.py and ./testserver.py to run it.
# finally create new modules using ./flaskr new module-name and add
# the name to mods.py.
# v0.0.1
def build_flask(config):
from flask import Flask
@sheenobu
sheenobu / load_template_style_1.js
Created October 4, 2012 22:28
Trying my hand at node.js code with a documentation/readable code style.
/*
* vi: set syntax=javascript :
* vi: set tabstop=2 :
* vi: set expandtab :
*/
var dust = require('dustjs-linkedin'),
fs = require("fs"),
Glob = require("glob").Glob,
path = require('path'),
async = require('async')
@sheenobu
sheenobu / gist:3932488
Created October 22, 2012 16:46
mirror: How to Install Ruby on Rails on CentOS 6 with RVM
#https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-centos-6-with-rvm
sudo yum update
sudo yum install curl git
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
rvmsudo yum install -y ...
rvm install 1.9.3
rvm use 1.9.3 --default
@sheenobu
sheenobu / detect-find.sh
Created October 23, 2012 17:28
Detecting GNU find vs BSD find
FIND="find";find --version > /dev/null 2>&1 || FIND="gfind"
$FIND ...
or
ARGS="-iname ... -o -iname ..."; find --version > /dev/null 2>&1 && find $ARGS || gfind $ARGS
@sheenobu
sheenobu / order_decorator.rb
Created October 30, 2012 15:36
Spree Commerce: Trigger on a completion of an order
Spree::Order.class_eval do
# or before_transition
state_machine.after_transition :to => 'complete' do |order|
...
end
end
@sheenobu
sheenobu / git-merge-to-server-annotated.sh
Created October 31, 2012 19:49
Merging of remote code while keeping local modifications and avoiding weird merges
#!/bin/bash
# An assumption is that our stash stack is already empty, otherwise a
# git stash && git stash pop
# would pop stacks even if git stash failed to save anything.
# (git stash could return a non-zero on 'no stash created' BUT it doesn't (yet) )
# store local changes
git stash
@sheenobu
sheenobu / fizzbuzz.rb
Created November 1, 2012 14:02
SingleLineFizzbuzz
(1..100).each { |x| puts( (eval(("'Fizz'" if x % 3 == 0).to_s + ("'Buzz'" if x % 5 == 0).to_s) or x) ) }
@sheenobu
sheenobu / gist:3995738
Created November 1, 2012 19:02
Create N lists by unzipping a the results of map.
even_numbers,odd_numbers,starts_with_one = entire = (1..10).map do |x|
[ (x if x % 2 == 0) ,(x if x % 2 != 0), (x if x.to_s[0] == '1') ]
end.transpose.map { |x| x.compact }
# The entities within the map [ ..., ..., ..N] end up in their respective list
# variables. compact is for removing nils from the resulting nested lists.
@sheenobu
sheenobu / traffic_lights.js
Created November 3, 2012 23:00
Finite State Machine learning with state-machine.js and nodejs
/*
* Modelling traffic lights as a persistent finite state machine using
* state-machine.js and nodejs.
*/
/*
* This is a specialization of Object.extend that checks if the
* destination function exists, and if so, merges the two functions
* into one function. This allows two conflicting functions
* to become a series of procedural steps.