Skip to content

Instantly share code, notes, and snippets.

View gist:9415493
(* Take 2 lists, return a tuple with the elements that are in both and the *)
(* elements that are only in first list, and elements only in second list *)
let list_diff l1 l2 =
let (shared, only_in_first) = List.fold_left
(fun (s, o) e -> if List.mem e l2 then (e::s, o) else (s, e::no))
([], []) l1 in
let only_in_second = List.fold_left
(fun o e -> if List.mem e shared then o else e::o) [] l2 in
(shared, only_in_first, only_in_second)
View gist:9510047
type bad_request =
| Invalid of string * string list
| Requested of string * string list
type not_acceptable = mimetype list * lang list
type t =
| BadRequest of bad_request list
| NotFound
| NotAllowed
View gist:d6810ceee02575bf3d43
class AchievementStatusViewSet(viewsets.ModelViewSet):
queryset = api_models.AchievementStatus.objects.all()
serializer_class = api_serializers.AchievementStatusSerializer
@action()
def generate_activity(self, request, pk=None):
api_models.PlayerActivity.objects.create()
View gist:cd1f918497b7246cc468
class AchievementStatusViewSet(viewsets.ModelViewSet):
queryset = api_models.AchievementStatus.objects.all()
serializer_class = api_serializers.AchievementStatusSerializer
filter_fields = ('achievement', 'status', 'owner')
def create(self, request, pk=None):
type = 'new_objective' if (request.DATA['status'] == 'objective') else 'achievement_unlocked'
activity = api_models.PlayerActivity.objects.create(owner=request.user,
type=type)
activity.achievement_statuses.add(what)
View gist:e8dcd72fec0614553074
@action(methods=['GET', 'POST', 'DELETE'])
def followers(self, request, player):
[...]
if request.method == 'GET':
"""
Get the players who follow this player
"""
[...]
View gist:de40c9431b9f3c64f697
class ElementSerializerMixin(object):
[...]
creation = serializers.SerializerMethodField('get_creation')
modification = serializers.SerializerMethodField('get_modification')
ELEMENT_FIELDS = ('creation', 'modification',)
def _get_date(self, date):
return date.strftime('%Y-%m-%dT%H:%M:%SZ')
def get_creation(self, obj):
View gist:d9e4df53b30e2b7e43d9
(* ************************************************************************** *)
(* Project: Life - the game, Website *)
(* Author: db0 (db0company@gmail.com, http://db0.fr/) *)
(* Latest Version is on GitHub: https://github.com/Life-the-game/Website *)
(* ************************************************************************** *)
open Eliom_content
open Html5.F
open Eliom_parameter
open Services
View config.json
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 60%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#26b671",
"@brand-success": "#26b671",
"@brand-info": "#4dd799",
@db0company
db0company / scroll.js
Created June 20, 2014 04:35
Smart scrolling
View scroll.js
// I ended up using this instead: http://alvarotrigo.com/fullPage/
// This is just for future reference but it doesn't work very well on mobiles
var achievement_smart_scrolling = function() {
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var scrollOn = true;
var setScrollOn = function() {
View gist:4746587f08e31c928233
db0s-MacBook-Pro:Downloads db0$ ./ffmpeg -i "かぐや姫の物語 サウンドトラック.m4a" -ss 00:40:55 -t 00:00:59 kaguya.m4a
ffmpeg version 2.3-tessus Copyright (c) 2000-2014 the FFmpeg developers
built on Jul 17 2014 22:19:03 with clang version 3.3 (tags/RELEASE_33/final)
configuration: --cc=/opt/local/bin/clang-mp-3.3 --prefix=/Users/tessus/data/ext/ffmpeg/sw --as=yasm --extra-version=tessus --disable-shared --enable-static --disable-ffplay --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libxavs --enable-version3 --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvpx --enable-libgsm --enable-libopus --enable-libmodplug --enable-fontconfig --enable-libfreetype --enable-libass --enable-libbluray --enable-filters --disable-indev=qtkit --enable-runtime-cpudetect
libavutil 52. 92.100 / 52. 92.100