Skip to content

Instantly share code, notes, and snippets.

View twidi's full-sized avatar
🕶️

Stéphane "Twidi" Angel twidi

🕶️
View GitHub Profile
# Auto list fields from django models - from https://djangosnippets.org/snippets/2533/#c5977
import inspect
from django.utils.html import strip_tags
from django.utils.encoding import force_text
def process_docstring(app, what, name, obj, options, lines):
# This causes import errors if left outside the function
from django.db import models
@davidbgk
davidbgk / redux-light.js
Last active March 3, 2016 20:37
Playing with Redux concepts
const createStore = (reducer, state = reducer(undefined, {})) => {
const subscribers = new Set()
return {
dispatch: (action) => {
state = reducer(state, action)
subscribers.forEach(func => func(action))
},
subscribe: (func) => {
subscribers.add(func)
return () => subscribers.delete(func)
@davidbgk
davidbgk / index.html
Last active February 2, 2016 17:23
A new version of my custom shorteners for recent browsers.
<!doctype html>
<meta charset="utf-8">
<title>Test JavaScript</title>
<style>
.turn-red { color: red; }
.turn-green { color: green; }
.turn-blue { color: blue; }
</style>
<h1>red</h1>
<h1>green</h1>
@jocki84
jocki84 / README.md
Last active June 23, 2022 06:13 — forked from hsablonniere/README.md
scrollIntoViewIfNeeded 4 everyone!!!

Polyfill for scrollIntoViewIfNeeded()

This gist provides polyfill code for the [scrollIntoViewIfNeeded()][SIVIN] Element method found on WebKit browsers.

Features

There is no particular requirement on the position in the hierarchy of the

@fdecampredon
fdecampredon / Container.js
Last active August 27, 2017 17:04
redux-relay
import React from 'react';
import { container } from 'redux-relay';
@container({
variablesFromState: (state) => ({myVariable: state.myState})
fragments: {
Relay.QL`
viewer {
@SleepWalker
SleepWalker / swipe.js
Created September 30, 2015 04:59
A simple swipe detection on vanilla js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
@koreno
koreno / README.md
Last active April 1, 2020 10:44
'rebaser' improves on 'git rebase -i' by adding information per commit regarding which files it touched.

Prebase

git-prebase improves on 'git rebase -i' by adding information per commit regarding which files it touched.

  • Each file gets an alpha-numeric identifier at a particular column, a list of which appears below the commit list. (The identifiers wrap around after the 62nd file)
  • Commits can be moved up and down safely (without conflicts) as long as their columns don't clash (they did not touch the same file).

Installation

Add the executable to your path and git will automatically expose it as

@sephiroth74
sephiroth74 / git pretty stat
Last active April 17, 2024 22:23
Show lines added/deleted and total commits per author in a period of time on all branches
git log --all --numstat --pretty="%H" --author="author" --since=1.year | awk 'NF==3 {plus+=$1; minus+=$2} NF==1 {total++} END {printf("lines added: +%d\nlines deleted: -%d\ntotal commits: %d\n", plus, minus, total)}'
@AutomationD
AutomationD / gist:9b438c2de72ce1294642
Created November 24, 2014 23:17
python 3.4 on Raspbian wheezy
sudo su
cat << EOF > /etc/apt/preferences
Package: *
Pin: release n=wheezy
Pin-Priority: 900
Package: *
Pin: release n=jessie
Pin-Priority: 300
@NotSqrt
NotSqrt / settings_test_snippet.py
Last active May 1, 2022 01:34 — forked from nealtodd/settings_test_snippet.py
Another shot at this problem ..
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return "notmigrations"
MIGRATION_MODULES = DisableMigrations()