Skip to content

Instantly share code, notes, and snippets.

@et
et / fixer.rb
Last active May 10, 2018 15:05
original = "const logger = require('../lib/logger');"
replacement = "const { Logger } = require('@neatcapital/logger');\nconst logger = new Logger(__filename);"
Dir.glob('./config/*.js') do |filename|
text = File.read(filename)
text.gsub!(original, replacement)
File.open(filename, 'w') { |file| file.puts text }
end
@et
et / freekudos.js
Created March 24, 2018 19:37
Kudos everyone in your strava feed
document.querySelectorAll('button.js-add-kudo').forEach(node => node.click())
@et
et / app.rb
Created February 6, 2018 07:13
With POST endpoints
require 'json'
require 'sinatra'
class App < Sinatra::Base
get '/event' do
hub_challenge = params['hub.challenge']
content_type :json
{ 'hub.challenge' => hub_challenge }.to_json
end
@et
et / Gemfile
Last active February 6, 2018 07:03
Set up initial handshake for Strava webhooks
source 'https://rubygems.org'
gem 'sinatra'
group :development do
gem 'sinatra-contrib'
end
const { is, fromJS } = require('immutable')
const nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } })
const nestedWithoutImmutable = nested.setIn(['a', 'b', 'c'], 'foo')
const nestedWithImmutable = nested.setIn(['a', 'b', 'c'], fromJS('foo'))
console.log("Is it equal? " + is(nestedWithoutImmutable, nestedWithImmutable));
console.log("\nWithout immutable setter\n" + nestedWithoutImmutable);
@et
et / init.vim
Created June 19, 2017 17:20
neovim clipboard settings for mac
" Allows yank to copy to clipboard
set cb=unnamed
" Allows pasting from clipboard
set cb=unnamedplus
" Allows selecting text and using CMD+c
set mouse=
@et
et / errors.rb
Created May 2, 2017 15:47
Adding errors to all active admin forms
Dir.glob('app/admin/*.rb') do |file_name|
File.open(file_name, "r") do |f|
text = File.read(f)
form_matches = text.match(/form do \|(?<block_param>\w+)\|/)
if form_matches && form_matches[:block_param]
semantic_errors_matches = text.match(/#{form_matches[:block_param]}.semantic_errors\(\*f\.object\.errors\.keys\)/)
if !semantic_errors_matches
defmodule CitrusByte do
@moduledoc """
Provides the `flatten/1` function to flatten a List
"""
@doc """
Flattens a List
## Examples
var _this = this;
items.map(function(item) {
return _this.massageSomething(item);
});
[
{ "date": "Aug 23", "count": 2343 },
{ "date": "Aug 24", "count": 4545 },
{ "date": "Aug 25", "count": 7342 },
{ "date": "Aug 26", "count": 994 },
{ "date": "Aug 27", "count": 1500 },
{ "date": "Aug 28", "count": 4234 },
{ "date": "Aug 29", "count": 7233 },
{ "date": "Aug 30", "count": 2233 },
{ "date": "Aug 31", "count": 100 }