Skip to content

Instantly share code, notes, and snippets.

View sunny's full-sized avatar
☀️

Sunny Ripert sunny

☀️
View GitHub Profile
@jeromecornet
jeromecornet / File locations
Last active August 26, 2021 21:14
Tailwindcss with sprockets
tailwind_transformer.rb -> app/models/tailwind_transformer.rb
tailwind.rb -> config/initializers/tailwind.rb
tailwind.config.js.erb -> config/tailwind.config.js.erb
package.json -> ./package.json
@mislav
mislav / gh-rename-master
Last active April 24, 2022 10:02
Rename the default branch of a repository using GitHub CLI https://github.com/cli/cli/releases/tag/v0.10.0
#!/bin/bash
# Usage: gh-rename-master <newbranch> [<remote>]
#
# Renames the "master" branch of the current repository both locally and on GitHub.
#
# dependencies: GitHub CLI v0.10
set -e
newbranch="${1?}"
remote="${2:-origin}"
@Ynote
Ynote / dot-css-dot-js.md
Created November 10, 2018 11:28
[Conferences] Some thoughts about DotCSS and DotJS 2018

About DotJS and DotCSS 2018

This year, I preferred DotCSS to DotJS. Some talks were amazing and inspiring. The atmosphere was kind and I talked to some speakers ! (@frivoal, @natalyathree AAAANNNND @SaraSoueian <3 <3).

DotCSS

About text wrapping and line-breaking

This talk was done by Florian Rivoal. He describes some new features to handle line-breaks and text-wrapping better. Some are already implemented in some browsers, some not. What I noted :

  • Whitespace CSS rules (pre, preline, etc.) use several steps to deal with whitespace.
@MarceloCajueiro
MarceloCajueiro / script.rb
Created July 17, 2018 11:50
Move sidekiq jobs from one queue to another
queue = Sidekiq::Queue.new("default")
queue.each do |job|
if job.klass == "DailyFrequencyCreatorWorker"
DailyFrequencyCreatorWorker.set(queue: 'daily_frequency_creator').perform_async(*job.args)
job.delete
end
end;nil
@sunny
sunny / enumerator_lazy_compact_extension.rb
Last active September 7, 2019 16:16
Adds #compact to Lazy Enumerators in Ruby
class Enumerator::Lazy
def compact
reject(&:nil?)
end
end
@alassek
alassek / 01_Annotated_Source.md
Last active November 19, 2023 11:53
Extending Arel to support @> operator

I've been doing some work lately with JSON documents in PostgreSQL using jsonb columns. You can query these documents using a GIN index in PG, but the syntax can be a little cumbersome

SELECT "events".* FROM "events" WHERE "events"."body" @> '{"shift":{"user_id":2}}'

You have to construct the right side of the query as a JSON string, which is a bit annoying. So I wondered if I could adapt Arel to do the tedious stuff for me.

@scmx
scmx / react-proptype-warnings-as-errors-with-sinon.markdown
Last active March 1, 2019 08:42
Make React PropType warnings throw errors with mocha.js, enzyme.js and sinon.js

Make React PropType warnings throw errors with enzyme.js + sinon.js + mocha.js

A simple stateless functional component that we want to test that it renders without propType warnings.

import React, { PropTypes } from 'react'

let VersionListItem = function ({ active, version }) {
  return (

RouteTranslator gem is wrapping the current locale assignment in an around_filter set_locale_from_url and then resets it to the previous value.

Devise has a FailureApp to deal with unauthenticated requests, and it uses I18n to build the flash message and the redirection URL. But at that stage, the I18n default locale is set and the messages and URL are not localized in the context of the request (i.e. if the request URL is in French, and the default locale of the app is English, Devise will redirect to the English URL with an english flash message).

This is a solution for propagating the application locale to the the Devise middleware.

@O-I
O-I / weighted_random_sampling.md
Last active November 14, 2024 08:30
[TIx 8] Weighted Random Sampling in Ruby

One of the many reasons I love working with Ruby is it has a rich vocabulary that allows you to accomplish your goals with a minimal amount of code. If there isn't a method that does exactly what you want, it's usually possible to build an elegant solution yourself.

Let's take the example of simulating the rolling of a die.

We can represent a die as an array of its faces.

die = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]