Skip to content

Instantly share code, notes, and snippets.

View rmoch's full-sized avatar

Richard Moch rmoch

  • France Université Numérique
  • Paris
View GitHub Profile

Keybase proof

I hereby claim:

  • I am rmoch on github.
  • I am rmoch (https://keybase.io/rmoch) on keybase.
  • I have a public key ASCqnaGcmWq-jum-dPkg0nr3jvgPZD0Y4D8RhbZlGEQ_QQo

To claim this, I am signing this object:

parseArticlesAttachments: function() {
for (var idx1 = 0; idx1 < this.state.articles.length; idx1++) {
var item = this.state.articles[idx1];
if (item.source === 'feed') {
if (item.attachments) {
for (var idx2 = 0; idx2 < item.attachments.data.length; idx2++) {
var att = item.attachments.data[idx2];
console.log('*****', att.type)
if (att.type === 'album') {
console.log('title ', att.title)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@rmoch
rmoch / gist:8296176
Created January 7, 2014 08:18
React
/** @jsx React.DOM */
// base on http://jsfiddle.net/spicyj/M6h22/
function copy(obj) {
var newObj = {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
newObj[key] = obj[key];
}
@rmoch
rmoch / gist:6364899
Last active April 22, 2016 17:47
- Django form widget for bootstrap switch HTML widget - http://www.bootstrap-switch.org/ - https://github.com/nostalgiaz/bootstrap-switch
class CheckBoxBootstrapSwitch(CheckboxInput):
"""Django widget for bootstrap switch HTML widget: http://www.bootstrap-switch.org/
Options can be provided through 'switch' argument:
switch = forms.BooleanField(required=False, label=_(u"bootstrap switch"),
widget=CheckBoxBootstrapSwitch(switch={'size': 'small', 'on': 'warning', 'text-label': 'Switch Me'}))
"""
def __init__(self, switch=None, *args, **kwargs):
self.switch = switch or {}
super(CheckBoxBootstrapSwitch, self).__init__(*args, **kwargs)
import re
# List of format available on Youtube
YOUTUBE_CHOICES = ("default", "hqdefault", "0", "1", "2")
# Default image if no thumbnail is found
NO_PREVIEW = "/static/img/no_preview.png"
def get_video_thumbnail(url, version="hqdefault"):
@rmoch
rmoch / gist:1915957
Created February 26, 2012 10:40
slugify
def asciify(unistr):
"""Returns an ascii string converting accented chars to normal ones.
Unconvertible chars are just removed.
>>> asciify(u'Ééüçñøà')
Eeucna
"""
return unicodedata.normalize('NFKD', unicode(unistr)).encode('ascii', 'ignore')
@rmoch
rmoch / importimages.py
Created November 27, 2011 14:26
Create embeded CMS Picture plugins from images hotlinked in TextPlugins.
# -*- coding: utf-8 -*-
import hashlib
import os
import urllib2
from optparse import make_option
from BeautifulSoup import BeautifulSoup as bf
from django.conf import settings
@rmoch
rmoch / gist:1315904
Created October 26, 2011 09:38
Natural time since i18n
# Natural time since template tag i18n
from django import template
from django.utils.encoding import force_unicode
from django.utils.translation import ungettext, ugettext as _
register = template.Library()
# from http://anandnalya.com/2009/05/20/humanizing-the-time-difference-in-django/
MOMENT = 60 # duration in seconds within which the time difference
# will be rendered as 'a moment ago'