Skip to content

Instantly share code, notes, and snippets.

Avatar

Philippe Dionne phildionne

View GitHub Profile
View .drone.yml
---
kind: pipeline
name: default
steps:
- name: test
image: ruby:2.6.3-alpine
commands:
- echo $FOO
- echo $BAR
View a.html
<h1>A</h1>
<a href="/">Home</a>
View application.rb
# config/application.rb
module MyApp
class Application < Rails::Application
# Handle exceptions with a custom controller
config.exceptions_app = lambda do |env|
ErrorsController.action(:show).call(env)
end
end
end
View gist:9c4433ad5c41bc4ee5039cf46925d9aa
### Keybase proof
I hereby claim:
* I am phildionne on github.
* I am pdionne (https://keybase.io/pdionne) on keybase.
* I have a public key ASALJIZd1Snk6_xqNGbjBFC-_Kmin4X8vbfm_A25PmSf5Qo
To claim this, I am signing this object:
@phildionne
phildionne / bot.rb
Last active May 20, 2016
Dialog Analytics example integration in a Facebook Messenger and Ruby chatbot.
View bot.rb
require_relative './dialog'
require 'facebook/messenger' # https://github.com/hyperoslo/facebook-messenger
Facebook::Messenger.configure do |config|
config.access_token = ENV['FACEBOOK_ACCESS_TOKEN']
config.verify_token = ENV['FACEBOOK_SECRET_TOKEN']
end
include Facebook::Messenger
@phildionne
phildionne / bot.rb
Last active May 20, 2016
Dialog Analytics example integration in a Telegram and Ruby chatbot.
View bot.rb
require_relative './dialog'
require 'telegram/bot' # https://github.com/atipugin/telegram-bot-ruby
Telegram::Bot::Client.run(ENV.fetch('TELEGRAM_TOKEN')) do |bot|
bot.listen do |message|
case message.text
when '/test'
Dialog.track(message)
text = "Welcome to test"
View script.rb
@client.query_in_batches("SELECT * FROM Invoice", per_page: 1000) do |records|
records.entries.each do |record|
# Record has an active class
if record.class_ref.present? && !record.class_ref.name.match(/supprimé/)
reference = record.class_ref
# Find project & organisation
project = Project.find_by!(quickbooks_class_id: reference.value)
organisation = project.organisation
View gist:380b9ba5272bf2017355
FactoryGirl.define do
# Points according to Geojson specifications (X, Y) or (Longitude, Latitude)
sequence :point do
[
[38.15704300068319, 82.64793458394706],
[65.25863617658615, -24.040317703038454],
[-144.94273960590363, 20.84642690140754],
[137.46707799844444, 80.3652603412047],
[-131.11246040090919, 3.13029068056494],
[-37.99821515567601, 70.2160071535036],
@phildionne
phildionne / apartment.rb
Last active Aug 29, 2015
Rails + Apartment + PostGIS + activerecord-postgis-adapter
View apartment.rb
Apartment.configure do |config|
config.persistent_schemas = %w{ shared_extensions }
end
View lazy.rb
# Enumerator#lazy is very slow and should only be used when iterating over large/infinite collections
# where you know you are going to get your results quite early in the iteration.
require 'benchmark/ips'
Benchmark.ips do |r|
r.report("map") do
(0..50).map{ |i| 'lol' if i.even? }
end
You can’t perform that action at this time.