Skip to content

Instantly share code, notes, and snippets.

View stabenfeldt's full-sized avatar
🎯
Focusing

Martin Stabenfeldt stabenfeldt

🎯
Focusing
View GitHub Profile
class Assignment < ActiveRecord::Base
# $LOUD_N_CLEAR = true
# Counts workdays between two Dates (not Time)
def count_weekdays(startdate,stopdate)
@workdays = 0
startdate.to_date.upto(stopdate.to_date) do |date|
if date.wday.to_s =~ /[0,1,2,3,4]/
@workdays +=1
require 'rubygems'
require 'active_support/core_ext/date/calculations.rb'
WORKDAY_STOP = 16
module DateCalculation
def weekend?
self.wday.to_s =~ /[6,0]/
end
it "can invite others" do
login(@user, @password)
visit group_path(@group)
within '#group_header' do |scope|
scope.click_link 'Invite'
end
@stabenfeldt
stabenfeldt / mysql_backup.sh
Created June 3, 2012 17:50
MySQL backup oneliner
mysqldump -u USER -p PASSWORD database | gzip -9 > BACKUP/prod-`date +%Y.%m.%d`c.gz
@stabenfeldt
stabenfeldt / test.zsh
Created September 19, 2012 07:09
rvm --trace use 1.9.2-p290
Martins-iMac-4429% rvm --trace use 1.9.2-p290
+__rvm_parse_args:637> [[ -n 4.3.11 ]]
+__rvm_parse_args:672> [[ -z '' && -n '' ]]
+__rvm_parse_args:675> [[ error == || 0 -eq 1 || -n '' ]]
+__rvm_parse_args:16> [[ -n use ]]
+__rvm_parse_args:18> rvm_token=use
+__rvm_parse_args:20> (( 1 > 0 ))
+__rvm_parse_args:22> next_token=1.9.2-p290
+__rvm_parse_args:23> shift
+__rvm_parse_args:28> case use ([[:alnum:]]*|@*)
@stabenfeldt
stabenfeldt / geo_data.rb
Last active August 29, 2015 14:01
Geodata reverse lookup Ruby client
class GeoData
require 'json'
require 'net/http'
attr_reader :lat, :lon
def initialize(lat: lat, lon: lon)
@lat = lat
@lon = lon
end
app = angular.module("trenger")
app.controller 'SessionCtrl', ['$scope', '$http', '$window', '$localStorage', '$q',
($scope, $http, $window, $localStorage, $q) ->
$scope.current_user = JSON.parse($("meta[name='current_user']").attr('content'))
$scope.authErrors = []
defer = $q.defer()
$scope.authorized = () ->
$scope.current_user? and $scope.current_user._id?
app = angular.module("trenger")
app.controller 'SessionCtrl', ['$scope', '$http', '$window', '$localStorage', '$q',
($scope, $http, $window, $localStorage, $q) ->
$scope.current_user = JSON.parse($("meta[name='current_user']").attr('content'))
$scope.authErrors = []
defer = $q.defer()
$scope.token = $localStorage.token
class TemplatesController < ApplicationController
skip_before_filter :authenticate_user!
#skip_authorization_check :template
def template
render :template => 'templates/' + params[:path], :layout => false
end
end
angular.module('app', [])
.directive('starred', function() {
return {
restrict: 'E',
scope: {
objectClass: '='
},
templateUrl: '/templates/starred.html.slim',
controller: function($scope, $attrs) {
return $scope.star_clicked = function(e) {