• Stars
    star
    141
  • Rank 252,234 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

web-development notes and archive of Old articles

Scrapbook2

Pure git/github version of my scrapbook on Ruby on Rails, web-development, linux system configuration.

source https://stackoverflow.com/questions/3087975/make-the-cursor-a-hand-when-a-user-hovers-over-a-list-item

##########################################################################
##                                                                      ##
##   Check individual .md files above for more information on topics    ##
##                                                                      ##
##########################################################################

Archive:

tools for developers

# on VM
curl --upload-file /tmp/export.csv https://transfer.sh/
# https://transfer.sh/123456/export.csv

# on Laptop
wget  https://transfer.sh/123456/export.csv

Web-development notes unsorted

random notes

# bin/importmap pin local-time
time_tag post.created_at, 'data-local': 'time-ago'


rails g resource comment post:reference content:text

form.text_area :content, size: '20x5'


<div id="<%= dom_id @post %>" >
</div>

Notice message

  <% if quote.errors.any? %>

      <%= @model.errors.full_messages.to_sentence.capitalize %>
  <% end %>

Rails find session_id in rails console

#  `app` is variable  and `ENV` a constant loaded when you start rails console
a = Rails.application.config.session_store.new(app, Rails.application.config.session_options)
a.class # => ActionDispatch::Session::RedisStore
a.get_session(ENV, '07319b2485be9ac4850664cd47cede38')  # you can find session id inspecting
                                                        # your cookis via firefox or plugin

# or a.find_session(ENV, '07319b2485be9ac4850664cd47cede38')

generate ri documentation

rvm docs generate

to lunch ri Array

cowsay

require 'net/http'
require 'cgi'

class Cowsays
  def say(message)
    message = CGI.escape(message)
    Net::HTTP.get_print(URI.parse(http://www.cowsays.com/cowsay?message=#{message}))
  end
end

source: ruby tapas 30

rails all models

Rails.application.eager_load!
ActiveRecord::Base.descendants

include Rails helpers in cusom class

class Foo
  include Rails.application.routes.url_helpers
  # ... or you can Delegate methods it
  
  
  def home_macro
    h.link_to 'Home', root_path
  end
  
  private
  
  def h
    ActionController::Base.helpers
  end

end

note you can do include UrlHelper which includes link_to but this will work only for String based urls as this module was changed in Rails 4 ( check source code )

if you keep getting error arguments passed to url_for can't be handled ... your only chance is to use my former code

checkbox, radio input value to boolean

ActiveRecord::ConnectionAdapters::Column.value_to_boolean 'f'  # => false
ActiveRecord::ConnectionAdapters::Column.value_to_boolean 't'  # => true
ActiveRecord::ConnectionAdapters::Column.value_to_boolean '0'  # => false
ActiveRecord::ConnectionAdapters::Column.value_to_boolean '1'  # => true
ActiveRecord::ConnectionAdapters::Column.value_to_boolean nil  # => false

in Rails 4.2 and above this is depricated and replaced with

ActiveRecord::Type::Boolean.new.type_cast_from_database(value)

...works the same the only difference is that when nil is passed it returns nil and "y", "n" will give you deprication warning

https://gist.github.com/equivalent/3825916

In rails 5.x you need to do

ActiveModel::Type::Boolean.new.cast('true')

Robots.txt examlpe

Dont chache content that is restricted

Tell browser not to cache content that hold harmfull data (e.g.: user settings, card details..>)

<meta http-equiv="Cache-control" content="no-cache no-store">

Memory stats simple method

def memstats
  `ps -o size= #{$$}`.strip.to_i
end

source: ruby tapas 42

grep tail

 tail -f log/production.log | grep "NoMethodError"

rails time to iso 8601 (javascript time)

"2010-10-25 23:48:46 UTC".to_time.iso8601

Gems

More Repositories

1

public_uid

Automatically generates random unique public id for record.
Ruby
74
star
2

copy_carrierwave_file

Copy Carrierwave files between records
Ruby
34
star
3

dude_policy

policy objects for Ruby on Rails from perspective of current user/account
Ruby
32
star
4

docker_rails_aws_elasticbeanstalk_demmo_app

LRUG talk - Docker Rails AWS Elastic Beanstalk - "puppies" demo app
Ruby
21
star
5

equivalent.github.io

My WebDeveloper blog website <3
SCSS
19
star
6

dummy-sinatra-puma-socket-docker-app

Sinatra Puma server dummy app with connection on a socket so that you can point NginX on socket to test Nginx setup
Ruby
18
star
7

health_check_nginx_docker

simple Docker image running Nginx that responds to /health-check with 200
Dockerfile
12
star
8

elixir_phoenix_docker_postgres_example

Elixir Phoenix Docker Postgresql Example
Elixir
10
star
9

maze_magic

Ruby gem for generating Maze
Ruby
9
star
10

simple_listener

simple implementation of listeners / observers in Ruby
Ruby
8
star
11

inputs

gem for building pragmatic CLI tools
Ruby
7
star
12

no_cache_control

sets Cache-Control header to no-cache no-store
Ruby
5
star
13

json-api-RC3

A specification for building JSON APIs - Mirror to RC3
CSS
4
star
14

code_katas

just my Morning code katas
Ruby
4
star
15

awesome-links

collection of awesome talks I've seen
4
star
16

bulkgate_sms_gateway_contract

Ruby on Rails Contract classes for SMS Gateway via bulkgate.com
Ruby
4
star
17

we_demand_serverless_ruby

online petition application hosted on serverless-ruby.org
Ruby
4
star
18

witch_doctor

Rails engine for handling virus scanning responses
Ruby
4
star
19

mailer_preview_request_model

Enable Rails ActionMailer Preview to accept argumeents
Ruby
3
star
20

git_to_svn_behavior-

bash script for getting svn behaviour from git on some folder (f.e. containing binaries)
Shell
3
star
21

shoulda-matchers-callbacks

Shoulda Matchers gem extension for Active Model (Rails) callbacks
Ruby
3
star
22

thyme_ubuntu_notification

Plugin for Thyme gem that sends Ubuntu notification when Pomodoro ends
Ruby
3
star
23

scrapbook

CSS
3
star
24

pull_tempfile

Simple lib to pull url to tempfile
Ruby
2
star
25

truecrypter

simplyfy decrypting file with truecrypt in terminal
Ruby
2
star
26

docker-nginx-puma-rails

Dockerfile for NginX to run along Rails app running Puma
Dockerfile
2
star
27

little_bastard

Docker image that will trigger reocuring requests on an endpoint with GO lang script
Go
2
star
28

wifi-coffee

WiFi hotpots of my favorite coffee places
1
star
29

campbase

dummy app
Ruby
1
star
30

test_podcast

another recruiter test
1
star
31

incoming_webhook_notifier

Simple Ruby lang Net/HTTPs implementation to send requests to "incomming webhooks" to Airbrake or Slack
Ruby
1
star
32

s3_bunny

Ruby
1
star
33

s3_makes_me_a_lazy_bastard

gem or pulling s3 bucket backups and uploading them to testing servers
Ruby
1
star
34

my-web-developer-journal

Bio and keeping track of professional developer & open source highlights
1
star
35

geocoder_google_maps

Easiest possible implementation of google maps into geocoder gem (or just longitude latitude attributes)
Ruby
1
star
36

docker_rails_aws_eb_demmo_app

Demmo app for AWS Elastinc Beanstalk settup
Ruby
1
star
37

my_rails_monkeypatch_bunch

just some monkeypatches that can be helpfull
Ruby
1
star
38

tests_for_recruiters

Ruby
1
star
39

meme

HTML
1
star
40

dude_policy_example1

example Ruby on Rails app for Dude Policy gem
Ruby
1
star
41

derren

pragmatic solution for deploying static SPAs to Azure Blobs under a proxy
Ruby
1
star
42

redcarpet_markdown_to_prismjs

Gem for lazy Prism.js implementation to Redcarpet
Ruby
1
star
43

hotwire-demo

trying out Hotwire.dev features
Ruby
1
star
44

code_exercises

Code exercises that I fallowed along from various web-development books, screencasts ...
Ruby
1
star
45

playground_tests_for_imageprocessing

just demo/playground rails application where I'm testing dragonfly and currierwave gems and playing around with config.
Ruby
1
star
46

pragmatic_serializer

Pragmatic JSON API Ruby Serializer
Ruby
1
star
47

public-config-files

Just configuration files (vim, bash, ... )
Vim Script
1
star
48

my_awesome_lambda-lamby

example RoR Lambda app from Lamby Quick Start page https://lamby.custominktech.com/docs/quick_start
Ruby
1
star
49

jt_ruby_image_editor

Job test: create simple console Ruby image editor
Ruby
1
star
50

prime_numbers_times_table

Recruiter test: create script to generate times table on first 10 prime numbers
1
star