Skip to content

Instantly share code, notes, and snippets.

View pjambet's full-sized avatar

Pierre Jambet pjambet

View GitHub Profile

Keybase proof

I hereby claim:

  • I am pjambet on github.
  • I am pierrej (https://keybase.io/pierrej) on keybase.
  • I have a public key whose fingerprint is A7A2 1A00 1B8E BF41 1E54 7574 8DEF 6131 386B D257

To claim this, I am signing this object:

# Create new comment
Comment.create( :author => "sacha", :message => "toto", :recipe => r)
# Ya plus simple
r.comments.create author: 'sacha', message: 'toto'
# Normalement ca devrait pas poser de problemes de mass assignment ca
def get_name_for_user user
user
end
@pjambet
pjambet / .vimrc
Last active December 13, 2015 22:25
let g:gist_post_private = 1
@pjambet
pjambet / test.py
Last active December 15, 2015 11:59
Why I hate PHP syntax
# user_id is an integer, follow is a hash wich values are all integers
# PHP
$userIds = array_unique(array_merge(array_values($follows), array($userId)));
# ruby
userIds = follows.keys.push(user_id).uniq
# python
userIds = set(follows.keys().append(user_id))
@pjambet
pjambet / fabfile.py
Created August 18, 2013 21:58 — forked from fiee/fabfile.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
fabfile for Django
------------------
see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle)
several additions, corrections and customizations, too
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= FoundationLinkRenderer
super.try :html_safe
end
class FoundationLinkRenderer < LinkRenderer
protected
export CPPFLAGS="-I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include"
export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -Wl,-dead_strip_dylibs"
POSTGRES_EXTRA_CONFIGURE_OPTIONS="--with-uuid=e2fs --with-bonjour --with-openssl -v" asdf install postgres 9.6.10
<p class="subtitle">Learn how one of the web&#8217;s biggest accidental success stories evolved.</p></header></div></div><div class="site-inner"><div class="content-sidebar-wrap"><main class="content"><article class="post-9674 page type-page status-publish entry"><div class="saboxplugin-wrap"><div class="saboxplugin-gravatar"><picture width="100" height="100" alt="Claire Broadley" class="avatar avatar-100 wp-user-avatar wp-user-avatar-100 alignnone photo sp-no-webp"><source srcset="https://digital.com/wp-content/uploads/AAEAAQAAAAAAAAkMAAAAJDIwMTM5ZDdiLTQwNTMtNDMxZS1iOGJlLWZlOGI1NzlhYzFlNg-150x150.webp" type="image/webp"><source srcset="https://digital.com/wp-content/uploads/AAEAAQAAAAAAAAkMAAAAJDIwMTM5ZDdiLTQwNTMtNDMxZS1iOGJlLWZlOGI1NzlhYzFlNg-150x150.jpg"><img src="https://digital.com/wp-content/uploads/AAEAAQAAAAAAAAkMAAAAJDIwMTM5ZDdiLTQwNTMtNDMxZS1iOGJlLWZlOGI1NzlhYzFlNg-150x150.jpg" width="100" height="100" alt="Claire Broadley" class="avatar avatar-100 wp-user-avatar wp-user-avatar-100 alignnone photo s
@pjambet
pjambet / stripe_errors.md
Last active July 28, 2019 16:25
Stripe Errors
  • api_connection_error: Failure to connect to Stripe's API.
  • api_error: API errors cover any other type of problem (e.g., a temporary problem with Stripe's servers), and are extremely uncommon.
  • authentication_error: Failure to properly authenticate yourself in the request.
  • card_error: Card errors are the most common type of error you should expect to handle. They result when the user enters a card that can't be charged for some reason.
  • idempotency_error: Idempotency errors occur when an Idempotency-Key is re-used on a request that does not match the first request's API endpoint and parameters.
  • invalid_request_error: Invalid request errors arise when your request has invalid parameters.
  • rate_limit_error: Too many requests hit the API too quickly.
  • validation_error: Errors triggered by our client-side libraries when failing to validate fields (e.g., when a card number or expiration date is invalid or incomplete).
try {
// Use Stripe's library to make requests...
} catch (CardException e) {
// Since it's a decline, CardException will be caught
System.out.println("Status is: " + e.getCode());
System.out.println("Message is: " + e.getMessage());
} catch (RateLimitException e) {
// Too many requests made to the API too quickly
} catch (InvalidRequestException e) {
// Invalid parameters were supplied to Stripe's API