Skip to content

Instantly share code, notes, and snippets.

View sebabouche's full-sized avatar

Sébastien Nicolaïdis sebabouche

  • Sifnos.io
  • La Trinité sur Mer
View GitHub Profile
@tomfa
tomfa / fields.py
Last active June 9, 2023 11:21
Django compressed json field / compressed binary field
from django.utils.text import compress_string
from django.core.serializers.json import DjangoJSONEncoder
class CompressedBinaryField(models.BinaryField):
compress = compress_string
@staticmethod
def uncompress(s):
zbuf = io.BytesIO(s)
@coryhouse
coryhouse / immutableJsExample.js
Last active July 18, 2022 04:40
Handling React state via Immutable.js map
// At top, import immutable
import { Map } from 'immutable';
// Later, in constructor...
this.state = {
// Create an immutable map in state using immutable.js
user: Map({ firstName: 'Cory', lastName: 'House'})
};
updateState({target}) {
@sauy7
sauy7 / cell.rb
Created June 3, 2015 06:09
Example using Devise's current_user with Trailblazer and Cells 4.0.0.beta5
# concepts/account/cell.rb
class Account::Cell < Cell:Concept
...
def show
render
end
class Grid < Cell::Concept
def show
@nchervyakov
nchervyakov / C:\MyProject\src\MyProject\UserBundle\Form\Type\RegistrationFormType.php
Created May 7, 2014 11:07
Symfony2 FOSUserBundle. Registration using just email.
<?php
namespace MyProject\UserBundle\Form\Type;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
use FOS\UserBundle\Model\UserManager;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use MyProject\UserBundle\Entity\User;
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active May 28, 2024 17:41
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################