Skip to content

Instantly share code, notes, and snippets.

View ydaniv's full-sized avatar

Yehonatan Daniv ydaniv

View GitHub Profile
@ydaniv
ydaniv / bootstrap.sh
Last active August 29, 2015 14:08
Openbudgets Vagrantfile
#!/bin/sh
# Create the virtual environment
mkvirtualenv openbudgets
# Link central project code directory to its virtual environment
setvirtualenvproject /home/vagrant/envs/openbudgets /home/vagrant/openbudgets
# Move to the root of central project code directory
@ydaniv
ydaniv / shall.js
Last active August 29, 2015 14:12
A mix of pub/sub and Promises that allows decoupled transfer of control from one component to another.
/**
* Assuming an implementation of a pub/sub system that provides publish() and subscribe() functions.
* Also assuming a Promises A+ implementation.
*
* In this way a publisher that requires some unknown subscriber to either accept or decline can
* publish an event that will pass a deferred object to any subscribed component that can either
* resolve or reject the promise.
*
* A nice example is some action button that requires a modal confirm dialog to prompt the user to
* either accept or decline the action.
@ydaniv
ydaniv / supr.js
Created July 10, 2011 06:43
simple wrapper for the ES5 Object.create mechanism and a function that fetches overridden methods from the prototype chain.
/*
* Copyright (C) 2011 Yehonatan Daniv <maggotfish@gmail.com>
*
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
*
* 0. You just DO WHAT THE FUCK YOU WANT TO.
*
* supr.js is a simple wrapper for the Object.create mechanism of ES5,
* to ease the creation of objects via the Create function.
@ydaniv
ydaniv / DRA API Alternatives
Last active November 20, 2015 01:42
2 API alternatives for the Django-REST-assured testing library.
############
# Option A #
############
class CategoryTestCase(RESTAPITestCase):
"""Tests Category API endpoints."""
base_name = 'category'
user_factory = account_factories.Admin
@ydaniv
ydaniv / defaultuuidfield.py
Created December 1, 2015 13:11
Django UUIDField with primary key and default value that doesn't break `if self.id` checks inside `save()`
import uuid
from django.db import models
from django.utils.encoding import force_text as force_unicode
class DefaultUUIDField(models.UUIDField):
def __init__(self, *args, **kwargs):
kwargs['blank'] = True
kwargs.setdefault('editable', False)
import os
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
DEBUG = True
FIXTURES = (
'dev/sites',
'dev/objects',
'pages',
@ydaniv
ydaniv / example.build.js
Created March 10, 2013 07:53
Example of a build config for the r.js optimizer, in a typical UIjet app
({
// appDir : "use if creating a proper app according to RequireJS' conventions",
baseUrl : 'path/to/base',
// dir : "use if we're outputting a directory",
optimize : 'uglify',
paths : {
plugins : '../../lib',
mustache : '../../lib/mustache',
common : '../common',
ui : 'ui',
@ydaniv
ydaniv / directives.js
Last active December 30, 2015 00:09
AngularJS-SpinJS SpinButton module
define([
'spin'
], function (Spinner) {
return [
function () {
return {
restrict: 'A',
scope : {
spinAction : '&spinAction',
@ydaniv
ydaniv / duotone.js
Created August 20, 2019 11:23
Introducing Kampos examples :: duotone simplified
export default function () {
return {
fragment: {
uniform: {
u_light: 'vec3',
u_dark: 'vec3'
},
main: `vec3 gray = vec3(dot(lumcoeff, color));
color = mix(u_dark, u_light, gray);`
uniforms: [
@ydaniv
ydaniv / ticker-full.js
Created August 20, 2019 11:24
Introducing Kampos examples :: ticker full
import {Kampos, effects, Ticker} from 'kampos';
const target1 = document.querySelector('#canvas1');
const media1 = document.querySelector('#video1');
const target2 = document.querySelector('#canvas2');
const media2 = document.querySelector('#video2');
const hueSaturation = effects.hueSaturation();
const brightnessContrast = effects.brightnessContrast();