Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / redmine_timelog_controller_create.rb
Last active May 13, 2016 13:36
Partial refactoring of https://github.com/redmine/redmine/blob/master/app/controllers/timelog_controller.rb#L104. That whole controller would need a serious amount of work to be whipped into shape, but this is a start.
class TimeEntriesController < ApplicationController
before_action :set_project, :set_issue
def create
@time_entry = container.time_entries.build time_entry_params.merge(user: User.current)
if @time_entry.save
respond_to do |format|
format.html { redirect_back_or_default created_time_entry_url, notice: l(:notice_successful_create) }
format.api { render :show, status: :created, location: @time_entry }
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
anonymous
anonymous / TwitterFetcher.js
Created April 6, 2014 04:28
Twitter Post Fetcher + Bootstrap Quote Carousel
/*********************************************************************
* #### Twitter Post Fetcher v10.0 ####
* Coded by Jason Mayes 2013. A present to all the developers out there.
* www.jasonmayes.com
* Please keep this disclaimer with my code if you use it. Thanks. :-)
* Got feedback or questions, ask here:
* http://www.jasonmayes.com/projects/twitterApi/
* Updates will be posted to this site.
*********************************************************************/
var twitterFetcher = function () {
@rehno-lindeque
rehno-lindeque / list-maybe-operators.elm
Created March 21, 2014 11:46
Elm Functor/Applicative operator shorthands
-- Shorthand map over List-like
f <$ lx = map f lx -- <$> in Haskell
lx $> f = map f lx
infixr 2 <$
infixr 2 $>
-- Shorthand sequential application
lf <$$ lx = zipWith (\f x -> f x) lf lx -- <*> in Haskell
lx $$> lf = zipWith (\f x -> f x) lf lx -- <**> in Haskell
infixr 1 <$$
class Ticket < ActiveRecord::Base
belongs_to :grouper
belongs_to :user
validate :user_cant_be_blacklisted, on: :confirmation
validate :user_cant_double_book, on: :confirmation
validate :grouper_cant_be_full, on: :confirmation
validate :grouper_cant_have_occurred, on: :confirmation
@xpepper
xpepper / Some tools and tweaks on Mac OS X.md
Last active October 18, 2024 20:04 — forked from g3d/gist:2709563
Some tools and tweaks on Mac OS X
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@mispa
mispa / SassMeister-input.scss
Last active February 2, 2017 12:32
Obsolete Sass Mixins and Functions. Generated by SassMeister.com.
// ----
// libsass (v3.3.6)
// ----
/*
* ******************************************************************************************
* ******************************************************************************************
* Obsolete Mixins and Functions
* ******************************************************************************************
* ******************************************************************************************
@zoerooney
zoerooney / gulpfile.js
Last active August 29, 2015 13:56
current Gulp configuration
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
livereload = require('gulp-livereload');
gulp.task('styles', function(){
return sass('scss/')
.on('error', function (err) {
console.error('Error!', err.message);