Skip to content

Instantly share code, notes, and snippets.

@addyosmani
addyosmani / README.md
Last active April 6, 2025 09:15 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@mlanett
mlanett / rails http status codes
Last active February 3, 2025 11:36
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
10 context 'when update products with valid data' do
9 it do
8 meta = described_class.enqueue(company.id, bind_data)
7 binding.pry #NOTE: debugger
6
5 Resque.inline = true
4 worker = Resque::Worker.new(:company_products)
3 binding.pry #NOTE: debugger
2 worker.work(0)
1
@fadhlirahim
fadhlirahim / dirty_associations.rb
Last active January 31, 2024 09:16
Awesome simple solution for Rails ActiveRecord dirty tracking associations
# Credit Brandon Weiss of http://anti-pattern.com/dirty-associations-with-activerecord
# app/models/dirty_associations.rb
module DirtyAssociations
attr_accessor :dirty
attr_accessor :_record_changes
def make_dirty(record)
self.dirty = true
self._record_changes = record
@kamikat
kamikat / cookie-chrome.sh
Last active March 25, 2023 18:38
export curl cookie text from firefox and chrome on linux
@unak
unak / constraint.rb
Last active October 26, 2019 17:29
type constraint
class Module
class ConstraintError < TypeError; end
def where(meth, constraint)
m = Module.new do
define_method(meth) do |*args|
args.zip(constraint.keys.first) do |arg, t|
raise ConstraintError, "type #{t} is expected, but #{arg.inspect} is passed" unless arg.is_a?(t)
end
ret = super(*args)
@EtienneDepaulis
EtienneDepaulis / _form.html.erb
Last active February 4, 2023 13:24
Generating a grouped collection select with `simple_form`and a model using the `ancestry` gem
<%=
f.association :category_id, collection: Category.roots,
as: :grouped_select,
group_method: :children, group_label_method: :name,
label_method: :name
%>
@rschmitty
rschmitty / 660-init-deb.sh
Created June 29, 2013 17:11
Linode script to register nginx after passenger isntall http://library.linode.com/assets/660-init-deb.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@jimothyGator
jimothyGator / README.md
Last active April 20, 2025 14:44
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@dariomncs
dariomncs / sphinx.conf
Created August 9, 2012 13:28
Sphinx configuration file using php
#!/usr/bin/php
#############################################################################
#
# S P H I N X C O N F I G U R A T I O N
#
#############################################################################
<?php
define('SPHINX_CONF_SOURCES_DIR', __DIR__ . DIRECTORY_SEPARATOR . "sources.d");