I hereby claim:
- I am matthieuprat on github.
- I am mpr (https://keybase.io/mpr) on keybase.
- I have a public key ASAm9UMZTlRgNLRP5p2rUbP9uK9N_-ld7JRI4eGdQYHbYwo
To claim this, I am signing this object:
| version = 3.months.ago.utc.strftime("%Y%m%d%H%M%S") | |
| puts "Deleting migrations before version #{version.inspect}" | |
| migrations = | |
| ActiveRecord::MigrationContext.new(['db/migrate']) | |
| .migrations | |
| .take_while { |migration| migration.version < version } | |
| File.delete(*migrations.map(&:filename)) |
I hereby claim:
To claim this, I am signing this object:
| # http://codingdojo.org/kata/Potter/ | |
| UNIT_PRICE = 8 | |
| DISCOUNTS = [0, 0.05, 0.1, 0.2, 0.25] | |
| def price(books) | |
| # Count the number of occurences of each book | |
| counts = books.group_by(&:itself).values.map(&:size) | |
| raise if counts.size > DISCOUNTS.size |
| def wait_for_ajax(timeout: Capybara.default_max_wait_time) | |
| Timeout.timeout(timeout) do # Bad. | |
| loop until finished_all_ajax_requests? | |
| end | |
| end | |
| def finished_all_ajax_requests? | |
| !page.evaluate_script '(window.jQuery || {}).active' | |
| end |
| /* eslint-disable no-extend-native */ | |
| // Cf https://facebook.github.io/immutable-js/docs/#/Map. | |
| function notifySentry(method) { | |
| const error = new Error(`Warning: '${method}' was called on an Object`) | |
| Raven.captureException(error, { level: 'warning', tags: { objectUnknownMethod: method } }) | |
| } | |
| const DEFAULTS = { | |
| configurable: true, |
| Rx.Observable.prototype.debug = function(name = 'default') { | |
| const s = (window.__subscriptions = window.__subscriptions || {}) // Subscriptions by name. | |
| s[name] = s[name] || [] // Subscriptions. Useful to track memory leaks. | |
| let i = -1 | |
| let j = 0 | |
| return Rx.Observable.create(observer => { | |
| i += 1 // Subscription index. | |
| j += 1 // Number of live subscriptions. | |
| const log = (...args) => console.log(`[${name}][${i}] %c%s`, ...args) | |
| log('color: blue; font-weight: bold', 'subscribe', `(${j} live)`) |
| string.chars.map.with_index do |c, i| | |
| n = c.encode('windows-1252') rescue nil | |
| n ||= c.encode('iso-8859-1') rescue nil | |
| puts "#{i}: #{c}" unless n | |
| n.bytes.first | |
| end | |
| .pack('C*') | |
| .force_encoding('utf-8') |
| const s = Symbol() | |
| const o = { [s]: 1 } | |
| o.hasOwnProperty(s) | |
| //-> true | |
| Object.getOwnPropertyNames(o) | |
| //-> [] | |
| Object.getOwnPropertySymbols(o) |
| --- reactor.rb | |
| +++ reactor.rb | |
| @@ -165,16 +165,18 @@ | |
| def calculate_sleep | |
| if @timeouts.empty? | |
| @sleep_for = DefaultSleepFor | |
| else | |
| diff = @timeouts.first.timeout_at.to_f - Time.now.to_f | |
| if diff < 0.0 |
| #! /bin/bash | |
| PREV_HEAD=$1 | |
| HEAD=$2 | |
| BRANCH_CHECKOUT=$3 | |
| # Skip the hook if the checkout is not a branch checkout. | |
| [ "$BRANCH_CHECKOUT" = 1 ] || exit 0 | |
| # Tells wether a file has been modified between 'PREV_HEAD' and 'HEAD'. |