Skip to content

Instantly share code, notes, and snippets.

# ofcause action_path doesn't work with this syntax
def init_and_slug_redirect
@place = Place.published.find(params[:id])
action = self.action_name
redirect_to action_path(@place), :status => :moved_permanently unless @place.friendly_id_status.best?
end
class CreateViews < ActiveRecord::Migration
def self.up
create_table :views, :force => true do |t|
t.references :loggable, :polymorphic => true
t.string :session_id
t.string :originating_ip
t.string :uri
t.timestamps
end
end
Time.now + (Time.parse("23:34:02").to_i-Time.now.to_i)
sum = 0
"23:34:02".split(":").each_with_index do |n, i|
case i
when 0
sum = sum+n.to_i*60*60
when 1
sum = sum+n.to_i*60
when 2
sum = sum+n.to_i
end
@jgrau
jgrau / gist:3787671
Created September 26, 2012 12:13
Example C# documentation
/// <summary>
/// This class performs an important function.
/// </summary>
public class TestClass
{
// Single parameter.
/// <param name="Int1">Used to indicate status.</param>
public static void DoWork(int Int1)
{
}
@jgrau
jgrau / create_labels.sh
Created June 27, 2016 17:16 — forked from Chompas/create_labels.sh
Bash script to create multiple Github labels at once
#!/usr/bin/env bash
# This is a modification from https://gist.github.com/omegahm/28d87a4e1411c030aa89
# Colours and convention picked from https://robinpowered.com/blog/best-practice-system-for-organizing-and-tagging-github-issues/
## Instructions
# Bash 4+ is needed because of associative arrays
# jq (https://stedolan.github.io/jq/)
# Create access Token from Github (https://help.github.com/articles/creating-an-access-token-for-command-line-use/) and save it under ".token" file
# Comment / Uncomment / Add, all the labels you want
@jgrau
jgrau / devise.da.yml
Created October 21, 2010 16:13
Updated to accomodate devise 1.4.5
da:
errors:
messages:
expired: "er udløbet. Vær venlig at bede om en ny"
not_found: "ikke fundet"
already_confirmed: "er allerede bekræftet"
not_locked: "var ikke låst"
not_saved:
one: "1 fejl medførte at denne %{resource} ikke kunne gemmes:"
other: "%{count} fejl medførte at denne %{resource} ikke kunne gemmes:"
@jgrau
jgrau / keybase.md
Last active February 18, 2019 13:06

Keybase proof

I hereby claim:

  • I am jgrau on github.
  • I am jgrau (https://keybase.io/jgrau) on keybase.
  • I have a public key ASDooTkZGBqM8T3cqDQolznE87B4pTov1LYG_7ehACY94wo

To claim this, I am signing this object:

@jgrau
jgrau / update-all-gems
Created August 15, 2016 14:28
A ruby script to update all gems one by one; running tests between each updated gem and committing to git.
#!/usr/bin/env ruby
# Makes accessing the latest exitstatus a bit easier
require 'English'
# Updates all the outdated gems one by one and commits the changes
# for every gem update. This should make it a lot easier to revert
# a gem update.
class UpdateAllGems
def self.run