Skip to content

Instantly share code, notes, and snippets.

@lionel-panhaleux
lionel-panhaleux / quizz.py
Created August 1, 2019 14:16
Python test
#!/usr/bin/env python
# Write a function that determines if any of its arguments evaluates to True.
def test_find_true():
"""
>>> find_true(True, {})
True
>>> find_true(None, (), 0)
False
"""
@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@Nagyman
Nagyman / workflows-in-django.md
Last active January 27, 2024 08:29
Workflows in Django

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
@vperron
vperron / readerXmlToJekyll.py
Last active December 22, 2015 09:29
Export Google Reader XML posts to Jekyll post template.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import errno
from string import Template
from slugify import slugify
from xml.dom.minidom import parse
@patocallaghan
patocallaghan / chai-expect.md
Last active September 14, 2023 14:54
Chai Expect Assertion library examples. From http://chaijs.com/api/bdd/ #chai #javascript #expect

##Chai Expect

##Language Chains

  • to
  • be
  • been
  • is
  • that
  • and
  • have
@ErikAndreas
ErikAndreas / 0background.md
Last active December 18, 2015 16:49
Proof of concept of full stack and tooling for AngularJS i18n gettext-style using Jed, pybabel and po2json. UPDATE: will now be maintained at https://github.com/ErikAndreas/lingua and tooling at https://github.com/ErikAndreas/grunt-lingua

Been looking for a full stack including tools for gettext-style i18n with AngularJS.

  • Gettext-style support in markup (html and javascript) supporting singular, plural and interpolation/sprintf
  • Tooling for extraction of strings to be translated (to .pot) from html and javascript
  • Tooling for generating .json of .po files

Ended up (working proof of concept) with the following:

  • "lingua", an AngularJS module wrapping Jed
  • Some AngularJS bootstrapping
  • pybabel for xgettext style translations extraction (to .pot)
  • po2json for generating .json files (per translation) from .po files
@vaiorabbit
vaiorabbit / fnv32a.js
Last active February 4, 2024 19:49
FNV-1a Hash (http://isthe.com/chongo/tech/comp/fnv/) in JavaScript.
// 32 bit FNV-1a hash
// Ref.: http://isthe.com/chongo/tech/comp/fnv/
function fnv32a( str )
{
var FNV1_32A_INIT = 0x811c9dc5;
var hval = FNV1_32A_INIT;
for ( var i = 0; i < str.length; ++i )
{
hval ^= str.charCodeAt(i);
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
@arnaudbreton
arnaudbreton / gist:5327394
Created April 6, 2013 19:54
AngularJS directive for bootstrap-switch
<div class="switch switch-small" bootstrap-switch="sync">
<input id="syncswitch" type="checkbox" />
</div>
module.directive('bootstrapSwitch', function() {
return {
restrict:'A',
scope: {
sync: true
},
@ogrisel
ogrisel / .gitignore
Last active December 14, 2015 16:29
Demo Notebook + Helper For Distributed Model Selection with IPython.parallel and scikit-learn
*.pyc
*.npy
*.pkl
*.mmap