Skip to content

Instantly share code, notes, and snippets.

View niezbop's full-sized avatar

Paul Niezborala niezbop

  • WeWantToKnow
  • Paris
View GitHub Profile
@jancel
jancel / gist:1367606
Created November 15, 2011 17:01 — forked from r00k/gist:906356
Custom devise strategy
# In config/initializers/local_override.rb:
require 'devise/strategies/authenticatable'
module Devise
module Strategies
class LocalOverride < Authenticatable
def valid?
true
end
@O-I
O-I / weighted_random_sampling.md
Last active February 21, 2024 19:02
[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 = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
@jiggneshhgohel
jiggneshhgohel / doorkeeper_config.md
Last active September 29, 2023 16:38
Doorkeeper (with JWT token) Server and Client applications configuration, references etc

Provider(aka Server)-side configuration, routes, controllers etc

Rails 5.0.0.1

Doorkeeper 4.2.6

Devise 4.2.0

Gemfile

@jbarton311
jbarton311 / billionaire_matplotlib.py
Created November 13, 2019 03:24
How to draw a simple plot in matplotlib
from matplotlib import pyplot as plt
plt.style.use("fivethirtyeight")
COLORS = ['#456789', '#894567', '#678945', '#3B3D4B', '#FF8181']
# Create data
x4 = ['$50K (Median Salary)', '$1 Million', '$1 Billion']
y4 = [50000, 1000000, 1000000000]
# Create a figure and axis