Skip to content

Instantly share code, notes, and snippets.

View stevedev's full-sized avatar

Steve Thompson stevedev

View GitHub Profile
@mbuckley
mbuckley / demo.component.ts
Created August 31, 2017 19:14
DatatableExportService Usage Example
import { DataTableUserOptions } from "lib-ThemisUI/src/lib/thDataTable/data-table.interfaces";
import { DatatableExportService } from "common/services/datatable-export-service/datatable-export.service";
class DemoComponentController {
public dataTableOptions: DataTableUserOptions;
/* @ngInject */
constructor(
private $q: angular.IQService,
private DatatableExportService: DatatableExportService,
@timuruski
timuruski / git_sred_log.sh
Last active August 29, 2015 14:08
Git SRED helper.
# In your .gitconfig add this alias:
# [alias]
# sred = "!source ~/.git_sred_log && sred_log"
# Assumes input date is formatted as YYYY-MM-DD,
# passes additional arguments to git-log.
sred_log() {
sred_date="${1:-$(date +"%Y-%m-%d")}"
shift
@timuruski
timuruski / generate_token.rb
Created August 31, 2011 21:01
A concise way to generate random values until a unique one is found.
class Device
include MongoMapper::Document
key :token, :unique => true, :default = lambda { generate_token }
def self.generate_token
token = ActiveSupport::SecureRandom.hex until token_available?(token)
token
end
$ cd ~/workspace/tmp/
$ git clone git://gist.github.com/1163698.git gist-1163698
> ...
$ cd gist-1163698/
$ git remote add brett git://gist.github.com/1168323.git gist-1168323
$ git remote add steve git://gist.github.com/1168327.git
$ git fetch brett
> ...
> From git://gist.github.com/1168323
> * [new branch] master -> brett/master
@jasonrudolph
jasonrudolph / about.md
Last active May 14, 2024 16:36
Programming Achievements: How to Level Up as a Developer

Potato Salad with Black Beans and Chipotle Chiles

Chipotle chiles are dried, smoked jalapeños that are sold canned in adobo sauce, a vinegary tomato sauce. They can be found in the Mexican food section of most large grocery marts.

Ingredients

  • 2 lbs Red Bliss potatoes (about 6 medium or 18 small), scrubbed
  • 1/4 cup red wine vinegar
  • 1/2 cup mayonnaise
  • 1 medium celery rib, minced (about 1/2 cup)
require 'mongo_mapper'
MongoMapper.database = 'tmp'
class HasValidAccessTokensValidator < ActiveModel::EachValidator
VALID_ACCESS_TOKENS = ['read', 'write', 'admin']
def validate_each(record, attribute, value)
unless value.all? { |token| VALID_ACCESS_TOKENS.include?(token) }
record.errors[attribute] << (options[:message] || "has invalid access_tokens")
@mikelikesbikes
mikelikesbikes / gist:1007228
Created June 3, 2011 21:43
Fibonacci with Inject!
def fib(n)
(0..n).inject([1,0]) { |(a,b), _| [b, a+b] }[0]
end
@stevedev
stevedev / gist:1000711
Created May 31, 2011 15:42
Website Pre-flight Checklist

Things to do every time we launch a web application.

  • Google Analytics
  • Ensure hosting is setup and client has hosting credentials
  • Test in IE 7, 8, 9.
  • Test in Firefox 3, 4 on Mac & PC
  • Test in Chrome on Mac & PC
  • Test in Opera on Mac & PC
  • Create sitemap.xml cronjob or run generator
  • Create favicon.ico
@kdwinter
kdwinter / authenticable.rb
Last active September 5, 2015 05:45
Authlogic plugin for MongoMapper
module Authenticable
extend ActiveSupport::Concern
included do
key :username, String
key :email, String
key :crypted_password, String
key :password_salt, String
key :persistence_token, String
key :login_count, Integer, :default => 0