This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
url_file = "urlfile.txt" | |
def sanitize_filename(filename) | |
name = filename.strip | |
# NOTE: File.basename doesn't work right with Windows paths on Unix | |
# get only the filename, not the whole path | |
name.gsub!(/^.*(\\|\/)/, '') | |
# Strip out the non-ascii character |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate YAML file of teams' github repositories suitable for generating pages | |
# with jekyll/github pages and upload it to a github repository. | |
# | |
# Requires the 'octokit' gem | |
# | |
# Usage | |
# export TOKEN=my-github-personal-token | |
# export ORG=my-org | |
# ruby team-repo-list.rb | |
# export TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"net/http" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'moped' | |
require 'yajl' | |
session = Moped::Session.new([ "127.0.0.1:27017" ]) | |
session.use "imminence_development" | |
query = session.command({ | |
geoNear: "places", | |
near: [ -2.16933984212885, 52.27229461855149 ], | |
spherical: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
alias_method :valid_password_without_legacy?, :valid_password? | |
def valid_password?(incoming_password) | |
if valid_password_without_legacy?(incoming_password) | |
return true | |
elsif Digest::MD5.hexdigest(incoming_password) == self.encrypted_password | |
update_legacy_password(incoming_password) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test "should create new user with oauth params" do | |
auth_hash = { | |
"uid" => "1234abcd", | |
"info" => { | |
"uid" => "1234abcd", | |
"email" => "[email protected]", | |
"name" => "Luther Blisset", | |
} | |
} | |
user = User.find_for_gds_oauth(auth_hash).reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A class to filter input parameters coming from a form in rails | |
# and collate them into a form suitable for use with a taggable | |
# object. | |
# | |
# This will mutate the params hash it is given. | |
# | |
# This could be used in a controller to take input that represents | |
# tags under its various names and collapse them to hand to a domain | |
# model that only knows about tags/tag_ids. Used with a decorator | |
# such as https://gist.github.com/2906392 it could handle everything |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/inflector' | |
class TagTypeDecorator | |
def self.has_tag_types(*types) | |
types.each do |sym| | |
define_method sym do | |
taggable.tags.select { |t| t.tag_type == sym.to_s.singularize.capitalize } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one or more | |
contributor license agreements. See the NOTICE file distributed with | |
this work for additional information regarding copyright ownership. | |
The ASF licenses this file to You under the Apache License, Version 2.0 | |
(the "License"); you may not use this file except in compliance with | |
the License. You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :api do | |
task :create_client => :environment do | |
raise "Requires name. id and secret are optional" unless ENV['name'] | |
@service ||= AuthServiceTools.new | |
@service.create_client(ENV['name'], ENV['id'], ENV['secret']) | |
puts @service.description | |
end |
NewerOlder