Skip to content

Instantly share code, notes, and snippets.

View johndel's full-sized avatar
🖖

John Deliyiannis johndel

🖖
View GitHub Profile
@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 / 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 / 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=""
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 / 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
@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 / gsadmin.rb
Created March 21, 2013 18:03
initializers/gsadmin.rb
Gsadmin.config do |config|
config.route = "admin"
config.devise_model = "admin"
end
@johndel
johndel / baby
Created March 24, 2013 13:59
Test tank bot for RTanque. Still baby steps :)
class Baby < RTanque::Bot::Brain
NAME = 'baby'
include RTanque::Bot::BrainHelper
def tick!
test_sensors
if sensors.position.on_left_wall?
command.speed = 3
command.heading = Math::PI
command.radar_heading = Math::PI
@johndel
johndel / gsadmin-initializer.rb
Created April 2, 2013 23:55
Generator for initializing gsadmin setup
module Gsadmin
module Generators
class InitializerGenerator < Rails::Generators::Base
source_root File.expand_path("../templates", __FILE__)
desc "Gsadmin installation generator."
def welcome
say "Thank you for using gsadmin, if you have any questions, my email is [email protected]", :cyan
end
@johndel
johndel / test.rb
Created April 4, 2013 10:38
It returns Favorite Game: ["Mario", "Contra", "Metroid"] instead of looping through array. Guess why :)
def describe_favorites(*games)
games.each do |game|
puts "Favorite Game: #{game}"
end
end
describe_favorites(['Mario', 'Contra', 'Metroid'])