Skip to content

Instantly share code, notes, and snippets.

@bunnymatic
bunnymatic / nested_content_snippet.rb
Created December 6, 2012 08:28
nested content in rails view helpers
# because i can never remember exactly how and when to use concat
# when building content in helpers
def nested_content
content_tag 'div' do
concat(content_tag 'span', 'span block')
concat(tag 'br')
concat(link_to 'root link', root_path)
concat(tag 'br')
concat(link_to('#') do
concat(content_tag 'h2', 'Head \'em off')
@brobertsaz
brobertsaz / serversetup.md
Last active July 6, 2020 08:56
Ubuntu 12.04 Ruby, Rails, Nginx, Unicorn

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key
@mfields
mfields / theme-options.php
Created January 31, 2013 01:12
Sample theme options page for WordPress Themes.
<?php
/**
* _s Theme Options
*
* @package _s
* @since _s 1.0
*/
/**
* Register the form setting for our _s_options array.
@tkretschmer-rb
tkretschmer-rb / GL4.2-UnicornToPuma
Last active December 15, 2015 10:49
Instructions on converting GitLab 4.2 from unicorn to puma.
1) Delete the line containing 'unicorn' from Gemfile
2) Add the following line under the "Servers" section
gem "puma", "~> 1.6.3"
3) From /home/gitlab/gitlab run
sudo bundle install --no-deployment
4) From /home/gitlab/gitlab run the install command that fits the database you are using, I use MySQL
sudo -u gitlab -H bundle install --deployment --without development test postgres
5) Create a new file config/puma.rb. Put the following inside it
#!/usr/bin/env puma
@jordelver
jordelver / gist:5806460
Created June 18, 2013 15:41
Sharing files using netcat

Sharing files using netcat

The receiver

nc -l 5566 > data-dump.sql

Listen on port 5566 and redirect output to data-dump.sql

The sender

@PWSdelta
PWSdelta / rspec_model_testing_template.rb
Last active June 12, 2025 15:08
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@xenda
xenda / gist:6418328
Last active December 22, 2015 04:39

¡Hola, extraño (por ahora)!,

En Xenda estamos buscando una persona para que se una a nuestro equipo de trabajo. Es una oferta especial, porque es para una persona especial. No solemos contratar mucha gente porque preferimos escalar a nivel de proyectos antes que en personas, pero hoy estaremos buscando a quien sería nuestro siguiente integrante (o Xendar, como nos solemos llamar).

En esta etapa de tu vida, tú (disculparás la confianza) aún no tienes mucha experiencia laboral y te interesa tenerla. Además, no eres un(una) desarrollador(a) normal. Tú lo sabes. Tal vez no lo digas en voz alta, pero aprendes muy rápido, y los retos te atraen. Pasas tus domingos viendo screencasts o aprendiendo algo de AngularJS y cómo integrarlo con una biblioteca de Javascript que ejecuta comandos en una tableta de Arduino. Eres genial.

¿Qué requerimos de ti?

No importa que tengas poca experiencia (o ninguna). Este es un puesto de desarrollador a nivel junior, y nos encargare

@iqbalhasnan
iqbalhasnan / carrierwave.rb
Last active May 25, 2023 06:06
carrierwave mini_magick image processing - quality, strip, exif rotation, gaussian blur, interlace
#config/initializers/carrierwave.rb
module CarrierWave
module MiniMagick
# Rotates the image based on the EXIF Orientation
def exif_rotation
manipulate! do |img|
img.auto_orient
img = yield(img) if block_given?
img
end
@raecoo
raecoo / awk-example.sh
Last active September 21, 2023 07:12
awk/grep commands for Rails log analysis
# Access number
cat production.log | grep "^Processing" | wc | awk '{print $1}'
# Each IP access number
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq -c
# Independent IP number
cat production.log | grep "^Processing" | awk '{print $4}' | uniq | wc | awk '{print $1}'
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq | wc -l
@ibraheem4
ibraheem4 / postgres-brew.md
Last active July 11, 2025 10:31 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update