Skip to content

Instantly share code, notes, and snippets.

@kamikat
kamikat / cookie-chrome.sh
Last active March 25, 2023 18:38
export curl cookie text from firefox and chrome on linux
@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
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
@mlanett
mlanett / rails http status codes
Last active May 20, 2025 19:08
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
@addyosmani
addyosmani / README.md
Last active July 2, 2025 14:29 — 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

@jhass
jhass / .rubocop.yml
Last active January 7, 2025 19:23
My preferred Rubocop config
AllCops:
RunRailsCops: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
class A
def initialize
p :A
end
end
class B < A
def initialize
p :B
end
stage 'Test'
// Split the previously executed tests into 10 jobs
def splits = splitTests parallelism: [$class: 'CountDrivenParallelism', size: 10], generateInclusions: true
def branches = [:]
// Prepare each job
for (int i = 0; i < splits.size(); i++) {
def split = splits[i]
branches["split${i}"] = {
// The job should allocate a new jenkins slave
node('dockerSlave') {
@tzmartin
tzmartin / embedded-file-viewer.md
Last active July 7, 2025 09:26
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

FROM tomcat:8.0.38
# Place the code version inside the webapps directory
ARG PACKAGE_VERSION
RUN echo "${PACKAGE_VERSION}" >> /usr/local/tomcat/webapps/version.txt
COPY project.war /usr/local/tomcat/webapps/project.war
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]