Skip to content

Instantly share code, notes, and snippets.

View nauman's full-sized avatar
🚀
Need MVP? book me in https://tidycal.com/nauman

Nauman Tariq nauman

🚀
Need MVP? book me in https://tidycal.com/nauman
View GitHub Profile
@nauman
nauman / ai_gen_rails_rules.json
Last active April 20, 2025 15:27
AI Code Generation for Ruby on Rails
{
"meta": {
"context": "You are an expert programming AI assistant prioritizing minimalist, efficient code and accepting user preferences even if suboptimal.",
"interaction_rules": [
"Clearly display the current step of the plan being executed.",
"Ask for clarification if requirements are ambiguous.",
"Always optimize for minimal code complexity and resource overhead.",
"Explain reasoning at each step, highlighting assumptions and potential limitations."
],
"workflow": {
<button type="button" class="rounded-md p-2 inline-flex items-center justify-center text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary-500" aria-expanded="false" data-action="click->nav#toggleMobile touch->nav#toggleMobile" data-toggle-id="nav-mobile">
<span class="sr-only">Open menu</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" class="h-6 w-6 fill-current" role="img" aria-labelledby="a2w5c94ogjox2tzeih251tta5g7ymzi2"><title id="a2w5c94ogjox2tzeih251tta5g7ymzi2">Icons/design/hamburger default</title>
<line x1="4" y1="6" x2="20" y2="6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></line>
<line x1="4" y1="12" x2="20" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></line>
<line x1="4" y1="18" x2="20" y2="18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="r
@nauman
nauman / _nav_bar.html.erb
Last active October 11, 2021 11:32
Tailwind navbar 1
<header class="w-full">
<nav class="relative px-5 md:px-8 border-2 border-indigo-600">
<div>
<div class="flex justify-between items-center py-8 xl:justify-start xl:space-x-10">
<div class="branding">
<a href="#" class="flex">
<span class="sr-only">Product</span>
</a>
<a href="/">Product</a>
</div>
@nauman
nauman / new.html.erb
Last active August 28, 2021 17:14
Devise Tailwind login page before refactoring
<main class="px-5 md:my-8 md:px-8 xl:px-20 py-16 md:py-20">
<div class="flex flex-col items-center">
<h2 class="text-3xl font-bold text-transparent
bg-clip-text bg-gradient-to-br text-transparent
bg-clip-text bg-gradient-to-br from-pink-500
to-blue-700 filter drop-shadow">Product Name</h2>
<h2 class="py-6">Log in to Product</h2>
<div class="sm:mx-auto sm:w-full sm:max-w-md mx-auto w-full">
<div class="py-8 px-4 sm:shadow sm:rounded-lg px-10">
/settings
_variables
/tools
_clearfix
_hidetext
_sizing
_typography
_vertical
_cover
/generic
@nauman
nauman / rvm.rb
Created April 6, 2017 04:52
tcsh.rc rvm setup
#!/home/holly/.rvm/rubies/ruby-2.3.0-preview1/bin/ruby
# riffing on a tune by Paul at po-ru.com
# 1. Using a bash shell, install rvm according to instructions.
# 2. Install this script in your path, say in ~/bin.
# 3. Make it executable.
# 4. Add the following alias to your .tcshrc:
# alias rvm 'eval `~/bin/rvm.rb \!*`'
# 5. Use and enjoy rvm in your tcsh
# Note that this script relies on a ruby already installed in the path.
# It shouldn't be too hard to enhance it to bootstrap itself using rvm.

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

module Basefields
def default_fields label
case label
when "name" then "text_field"
when "password" then "password_field"
when "hidden" then "hidden_field"
when "message" , "description" then "text_area"
#when "position" then "number_field"
@nauman
nauman / application.rb
Created November 29, 2012 06:34
catch all exceptions
#catch all exceptions
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: :render_500
rescue_from ActionController::RoutingError, with: :render_404
rescue_from ActionController::UnknownController, with: :render_404
rescue_from ActionController::UnknownAction, with: :render_404
rescue_from ActiveRecord::RecordNotFound, with: :render_404
end
private
@nauman
nauman / app.js
Created October 15, 2012 05:37
Titanium header - > title, content -> table, footer -> banner
Ti.UI.setBackgroundColor('#000');
var win = Ti.UI.createWindow({
backgroundColor: 'red',
exitOnClose: true,
fullscreen: false
});
var footerLabel = Ti.UI.createLabel({
text: 'Banner Rotation',