Skip to content

Instantly share code, notes, and snippets.

View jcastaneyra's full-sized avatar
🏖️
Working from everywhere

Jose Castaneyra jcastaneyra

🏖️
Working from everywhere
View GitHub Profile
@jcastaneyra
jcastaneyra / CONVENTIONS.md
Created February 25, 2025 00:10 — forked from peterc/CONVENTIONS.md
CONVENTIONS.md file for AI Rails 8 development
  • You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use rails new first to generate all of the boilerplate files necessary.
  • Create an app in the current directory with rails new .
  • Use Tailwind CSS for styling. Use --css tailwind as an option on the rails new call to do this automatically.
  • Use Ruby 3.2+ and Rails 8.0+ practices.
  • Use the default Minitest approach for testing, do not use RSpec.
  • Default to using SQLite in development. rails new will do this automatically but take care if you write any custom SQL that it is SQLite compatible.
  • An app can be built with a devcontainer such as rails new myapp --devcontainer but only do this if requested directly.
  • Rails apps have a lot of directories to consider, such as app, config, db, etc.
  • Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
  • Guard against incapable browsers accessing controllers with `allo
function upload_media(imgURI) {
var options = new FileUploadOptions();
options.fileKey="file";
var time = new Date().getTime();
var fileName = time+".jpg";
options.fileName = fileName;
options.mimeType ="image/jpeg";
options.chunkedMode = false;
var uri = encodeURI("http://<your bucket name>.s3.amazonaws.com/");
@jcastaneyra
jcastaneyra / mass_renaming_s3_files.rb
Created February 28, 2013 22:53
Small example to rename massive files that fit in a regular expression in a bucket
require 'rubygems'
require 'aws/s3'
AWS::S3::Base.establish_connection!(
:access_key_id => 'MYACCESSKEYID',
:secret_access_key => 'MYSECRETACCESSKEY'
)
bucket = 'my-massive-files-bucket'
objects = []
@jcastaneyra
jcastaneyra / DataPopulator.java
Created October 10, 2012 01:58
Initializing bean populator
package util;
import java.io.File;
import javax.sql.DataSource;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.FileSystemResource;
@jcastaneyra
jcastaneyra / gps_logger.ino
Created October 6, 2012 15:50
Gps logger
#include <TinyGPS.h>
#include <Wire.h>
#include "DS3231.h"
#include <SD.h>
int ledPin = 13;
TinyGPS gps;
long lat, lon;
@jcastaneyra
jcastaneyra / stalker_xbee_router.pde
Created January 3, 2012 19:50
Seeeduino Stalker Xbee Router
int buzzPin = 11;
void setup() {
Serial.begin(57600);
pinMode(buzzPin, OUTPUT);
}
void loop() {
@jcastaneyra
jcastaneyra / arduino_xbee_coordinator.pde
Created January 3, 2012 19:48
Arduino UNO Xbee Coordinator
#include <SoftwareSerial.h>
#define RxD 11
#define TxD 12
SoftwareSerial beeSerial = SoftwareSerial(RxD,TxD);
void setup() {
beeSerial.begin(57600);
}
require 'rubygems'
require 'daemons'
#require File.join(File.dirname(__FILE__), 'daemons_extension')
ENV['RAILS_ENV'] ||= 'development'
ENV['BUNDLE_GEMFILE'] ||= File.join(Dir.pwd, 'Gemfile')
options = {
:app_name => 'mail_consumer',
:dir_mode => :script,
require 'rubygems'
require 'zip/zip'
require 'zip/zipfilesystem'
current_path = Dir.pwd
scorm_file = current_path + "/" + tmp_dir + '/' + course + "/#{scorm_module}.zip"
# module_path is where scorm files are (files to zip)
Dir.chdir(module_path)
files_to_zip = Dir["**/*"]