Skip to content

Instantly share code, notes, and snippets.

View johndel's full-sized avatar
🖖

John Deliyiannis johndel

🖖
View GitHub Profile
@johndel
johndel / gsadmin.rb
Created March 21, 2013 18:01
gsadmin/lib/gsadmin.rb for understanding configuration variables from file gsadmin.rb
require "gsadmin/engine"
require "rails"
module Gsadmin
class Engine < Rails::Engine
end
def self.config(&block)
yield Engine.config if block
Engine.config
@johndel
johndel / check_rails_project.rb
Created March 9, 2013 11:22
Check if a project is a rails project.
def check_if_rails_project
abort = 0
unless File.exists?("Gemfile")
say "Missing Gemfile! Is this a rails project? If yes, something went really wrong, create your Gemfile and retry", :red
abort = 1
end
unless File.exists?(Rails.root.join("config/routes.rb"))
say "Missing routes.rb! Is this a rails project? If yes, something went really wrong, create your routes.rb and retry", :red
abort = 1
end
class AddIndexesToTables1 < ActiveRecord::Migration
def change
add_index(:adverts, :category_id)
add_index(:adverts, :profile_id)
add_index(:adverts, :video_id)
add_index(:adverts, :active)
add_index(:advert_area_mappings, :advert_id)
add_index(:advert_area_mappings, :area_id)
@johndel
johndel / find_unused_images.rb
Created February 20, 2013 17:25
Image cleanup script
# encoding: utf-8
require "fileutils"
img=Dir.glob("**/*.jpeg")+Dir.glob("**/*.jpg")+Dir.glob("**/*.png")+Dir.glob("**/*.gif")
data=Dir.glob("**/*.htm*")+Dir.glob("**/*.css*")+Dir.glob("**/*.js*")
puts img.length.to_s+" images found & "+data.length.to_s+" files found to search against"
content=""
@johndel
johndel / athens.json
Created February 11, 2013 10:37
Athens json format from worldweatheronline
{
"data": {
"current_condition": [
{
"cloudcover": "1",
"humidity": "54",
"observation_time": "10:14 AM",
"precipMM": "0.0",
"pressure": "1013",
"temp_C": "7",
@johndel
johndel / usersmine.lua
Created February 9, 2013 00:12
crtmpserver users.lua file
users=
{
username1="password",
username2="password",
}
realms=
{
{
name="My realm...",
@johndel
johndel / mine.lua
Created February 9, 2013 00:10
crtmp mine.lua
configuration=
{
daemon=false,
pathSeparator="/",
logAppenders=
{
{
name="console appender",
type="coloredConsole",
@johndel
johndel / gist:4706913
Created February 4, 2013 14:10
Simple controller test
...
describe "GET 'delete'" do
before :each do
@upload = create(:upload)
end
it "deletes the upload" do
expect{
delete :destroy, id: @upload
}.to change(Upload, :count).by(-1)
@johndel
johndel / vcr.rb
Created February 4, 2013 13:53
vcr
VCR.configure do |c|
c.ignore_localhost = true
c.cassette_library_dir = Rails.root.join("spec", "vcr")
c.hook_into :webmock
end
RSpec.configure do |c|
c.treat_symbols_as_metadata_keys_with_true_values = true
c.around(:each, :vcr) do |example|
name = example.metadata[:full_description].split(/\s+/, 2).join("/").underscore.gsub(/[^\w\/]+/, "_")
@johndel
johndel / omniauth_helpers.rb
Created February 4, 2013 13:51
Omniauth Helper File
def omniauth_facebook
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({
:provider => 'facebook',
:uid => '1234567',
:info => {
:nickname => 'jbloggs',
:email => '[email protected]',
:name => 'Joe Bloggs',
:first_name => 'Joe',
:last_name => 'Bloggs',