Skip to content

Instantly share code, notes, and snippets.

@Tembrel
Tembrel / Issue374a.java
Created December 28, 2023 15:48
Run multiple tasks in succession under a retry policy until one succeeds
package com.example.failsafe;
import dev.failsafe.*;
import dev.failsafe.function.*;
import java.util.*;
import static java.util.stream.Collectors.toList;
import org.junit.*;
import static org.junit.Assert.*;
@Joxebus
Joxebus / 1_yaml_slurper_sample.groovy
Last active August 29, 2023 12:49
YAML sample with Groovy 3
import groovy.yaml.YamlSlurper
def slurper = new YamlSlurper()
def configuration = '''
version: 3.0
environment: "dev"
context:
path: "/test"
endpoints:
@andyyou
andyyou / rails_webpacker_bootstrap_expose_jquery.md
Last active August 9, 2022 07:38
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@eliotsykes
eliotsykes / date_time_formats.rb
Created February 9, 2017 18:39
Real World Rails DATE_FORMAT samples
~/dev/real-world-rails (master)
$ ag -G 'config/initializers/' ::DATE_FORMATS
apps/accelerated_claims/config/initializers/date_formats.rb
1:Date::DATE_FORMATS[:printed] = '%d %B %Y'
apps/advocate-defence-payments/config/initializers/date_time.rb
2:Date::DATE_FORMATS[:default] = Settings.date_format
5:DateTime::DATE_FORMATS[:default] = Settings.date_time_format
8:Time::DATE_FORMATS[:default] = Settings.date_time_format
@yuki24
yuki24 / json_with_synbolize_names.rb
Created January 13, 2017 22:51
JSON with the symbolize_name: true option
require 'json'
require 'open-uri'
require 'benchmark/ips'
require 'memory_profiler'
json = open('https://network.pivotal.io/api/v2/products').read
Benchmark.ips do |x|
x.report('symbolize_names: false') { JSON.parse(json) }
x.report('symbolize_names: true') { JSON.parse(json, symbolize_names: true) }
require 'rails_event_store'
require 'aggregate_root'
PaymentAuthorized = Class.new(RailsEventStore::Event)
PaymentSuccessed = Class.new(RailsEventStore::Event)
PaymentFailed = Class.new(RailsEventStore::Event)
PaymentCaptured = Class.new(RailsEventStore::Event)
class Payment
InvalidOperation = Class.new(StandardError)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Todo;
class TodosController extends Controller
{
@oelmekki
oelmekki / doc.md
Created December 30, 2015 19:37
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

@erikcox
erikcox / SimCityLoadingMessages.txt
Created November 11, 2015 21:23
A list of loading messages from the game SimCity, which I repurposed for Slack loading messages.
Adding Hidden Agendas
Adjusting Bell Curves
Aesthesizing Industrial Areas
Aligning Covariance Matrices
Applying Feng Shui Shaders
Applying Theatre Soda Layer
Asserting Packed Exemplars
Attempting to Lock Back-Buffer
Binding Sapling Root System
Breeding Fauna
@kylev
kylev / signals_badly.rb
Last active August 29, 2015 14:26
An exploration of common pitfalls in Ruby Exception/Signal handling.
#!/usr/bin/env ruby
# Some members of ruby community continue to misunderstand the interplay of
# signal handlers and exception handling. This is a brief exploration
# via examples. You can run them by uncommenting the invocations at
# the bottom. You can see their behavior with Ctrl-C.
#
# Some of the examples will require a kill -9 from another terminal to
# stop.
#