Skip to content

Instantly share code, notes, and snippets.

@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — 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

@demisx
demisx / active_record_objects_autosave.md
Last active February 26, 2024 17:31
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@pburtchaell
pburtchaell / styles.css
Last active February 25, 2024 12:24
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@theronic
theronic / Dockerfile
Created May 30, 2022 16:23
Deploy Clojure to Fly.io: Efficient Multi-stage Docker build to Deploy Clojure Application to Fly.io
FROM clojure:openjdk-15-tools-deps AS builder
WORKDIR /opt
ADD deps.edn deps.edn
RUN clj -Sdeps '{:mvn/local-repo "./.m2/repository"}' -e "(prn \"Downloading deps\")"
RUN clj -e :ok
COPY . .
RUN clj -e :ok
@mcmanus
mcmanus / trrprefs.md
Last active December 27, 2022 05:17 — forked from bagder/trrprefs.md
trr prefs

Preferences

All preferences for the DNS-over-HTTPS (DoH) functionality in Firefox are located under the "network.trr" prefix (TRR == Trusted Recursive Resolver). The support for these landed in Firefox 60 and has been improved in Firefox 61. Goto about:config to set these preferences.

Some users have reported needing to restart to have the changes take effect. The DNS tab of the about:networking page will indicate whether a name was resolved via TRR or not.

network.trr.mode

set this preference to 2 to enable DoH in a mode where DoH is used as the first choice for DNS, but it will still fallback to native DNS for full backwards compatibility. Set to 0 to disable DoH.

@paulrouget
paulrouget / ff.md
Last active November 21, 2021 21:13
Hacking Firefox
@jahfer
jahfer / active_record_test_logger.rb
Last active November 26, 2019 14:34
Small tweak to output Active Record logs inside of a test with the stacktrace attached
module MyLogSubscriber
def sql(*args)
trace = caller
Rails.backtrace_cleaner.remove_silencers!
Rails.backtrace_cleaner.add_silencer { |line| not line =~ /^(components)\// }
puts Rails.backtrace_cleaner.clean(trace)
super
puts "---------------"
end
end
@woxtu
woxtu / gist:c186b173be3a53171533
Last active March 4, 2019 05:37
Face detection in Rust
pub mod cv {
extern crate libc;
use self::libc::{c_char, c_double, c_int, c_schar, c_void};
#[repr(C)]
pub struct HaarClassifierCascade;
#[repr(C)]
pub struct MemStorage;
@kristianpd
kristianpd / admin.md
Last active June 25, 2018 08:09
History of Admin Next
@cjoudrey
cjoudrey / README.md
Last active December 27, 2015 13:59
File uploads in Batman

File uploads in Batman

Problem

When you use input type="file" in Batman, the change event is observed and node.files is used to obtain the file when it changes.

In browsers that do not support the FileReader API node.files will be undefined.

Strategy used in Shopify