Skip to content

Instantly share code, notes, and snippets.

View jonathanmach's full-sized avatar

Jonathan jonathanmach

View GitHub Profile
@jonathanmach
jonathanmach / App.vue
Last active December 31, 2021 01:24
Prototype: Advanced filtering: flexible conditions
<template>
<div>
<ul>
<template v-for="(filter, index) in filters.children">
<FilterExpression
:prop="filter"
:depth="1"
:index="index"
@add="addNewChild"
@change="mainChangeHandler"
{
"referral": {"count":1, "percent":0.25},
"facebook": {"count":1, "percent":0.25},
"email": {"count":1, "percent":0.25}
}
{
"basic_age": [
1,
5,
6,
2,
1,
3,
0,
0
[
{
"utm_medium": "example",
"users_signed_up": 24,
"email_in": 36,
"users_name_specified": 14,
"users_notifications": 31,
"users_validated": 26
},
{
<!-- We're using Vue Functional components here -->
<template functional>
<div class="link-bookmark">
<!-- The above parent div has been added so the parent scoped styles won't leak into this component -->
<a
:href="props.href"
target="_blank"
class="flex items-center border cursor-pointer rounded-md hover:bg-gray-100 py-2 px-4"
>
<div class="decorator">
from django.shortcuts import render
from .models import Habit, Category
from .serializers import HabitSerializer, NewHabitSerializer, SectionSerializer
from rest_framework import generics
from rest_framework.response import Response
from rest_framework.decorators import api_view
from rest_framework import status
from django.utils import dateparse
/* eslint-disable no-unused-vars */
import Vue from "vue";
import Vuex from "vuex";
import habit from "@/store/modules/habit.js";
import habitLogs from "@/store/modules/habitLogs.js";
import habitSection from "@/store/modules/habitSection.js";
import VuexORM from "@vuex-orm/core";
import Habit from "@/models/Habit";
import HabitLog from "@/models/HabitLog";
import Category from "../models/Category";
/* eslint-disable no-unused-vars */
import HabitService from "@/services/HabitService.js";
import Habit from "@/models/Habit";
import Category from "../../models/Category";
export default {
mutations: {
FETCH_HABITS(state, habitArray) {
// Test data
const data = [
@jonathanmach
jonathanmach / Base64Example.py
Created October 13, 2017 22:40
Encoding file to Base64
import xml.etree.ElementTree as ET
import base64
image = open('demo.pdf', 'rb') # open binary file in read mode
image_read = image.read()
image_64_encode = base64.b64encode(image_read)
# Decode test
image_64_decode = base64.decodestring(image_64_encode)
image_result = open('demo_decoded.pdf', 'wb') # create a writable image and write the decoding result