Skip to content

Instantly share code, notes, and snippets.

@T4rk1n
T4rk1n / tests_assets_Dockerfile
Created October 18, 2018 18:51
assets-docker
FROM ubuntu:latest
RUN mkdir /app
COPY app/ /app
RUN apt-get update && apt-get upgrade -y
RUN apt-get install python python-pip -y
RUN pip install -r /app/requirements.txt

Additional auth cookies:

  • dash_user
    • signed with itsdangerous.
    • the username appear in clear text in the cookie as user.hjswEldasfkj
  • dash_user_data
    • json web signature with itsdangerous.
    • The json web signature is not entirely safe, do not put sensible data.

The users cookies have no expires, they are validated by itsdangerous.

@T4rk1n
T4rk1n / webpack.config.js
Created July 25, 2017 00:45
basic webpack config
const path = require('path')
const distFolder = path.resolve(__dirname, 'dist')
const srcFolder = path.resolve(__dirname, 'src')
module.exports = {
entry: ['./src/app.js'],
output: {
filename: 'app.min.js',
path: distFolder
},
@T4rk1n
T4rk1n / imageroller.js
Last active July 21, 2017 04:48
Image Roller
/**
* Preload images in a directory.
* @param {string} baseurl
* @param {string} extension
* @return {Promise} resolve an Array<Image>.
*/
function preloadImages(baseurl, extension, starter) {
return new Promise(function(res) {
var i = starter;
var images = [];
@T4rk1n
T4rk1n / animations.js
Last active June 12, 2017 20:22
VanillaJS (ES7) animations.
const getOffset = (elem) => {
const off = elem.getBoundingClientRect()
return {
left: off.left + window.scrollX,
top: off.top + window.scrollY
}
}
const getFontSize = (elem) => parseFloat(window.getComputedStyle(elem, null).getPropertyValue('font-size'))
@T4rk1n
T4rk1n / FunctionalExtensions.cs
Last active May 6, 2017 01:10
Map, Filter, Reduce.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace FunctionalCSharp
{
internal class Program
{
public static void Main(string[] args)
const defaultStorageOptions = {
onSuccess: (value) => {},
onError: (error) => {}
}
/**
* Base class with `abstract` methods.
*/
@T4rk1n
T4rk1n / action.js
Last active June 8, 2017 14:51
Redux store implementation with thunk and promise middleware.
export const fulfilled = (actionType) => `${actionType}_FULFILLED`
export const rejected = (actionType) => `${actionType}_REJECTED`
export const pending = (actionType) => `${actionType}_PENDING`
export const resetAction = (actionType) => `${actionType}_RESET`
/**
* Create a dictionary with all the phases of an async action
* @param {string} baseAction
*/
const createActionTypes = (baseAction) => ({
<!DOCTYPE html>
<html lang="en">
<!--
Static markdown document viewer.
Markdown renderer: remarkable
-->
<head>
<title>Markdown document viewer</title>
<meta charset="UTF-8">
@T4rk1n
T4rk1n / meta.py
Last active September 17, 2016 04:33
Metaclass example
"""
Metaclass example by a metaddict.
Python 2: replace metaclass= by a class variable __metaclass__ =
"""
class Meta(type):
def __new__(mcs, cname, cbases, cdict):
meta_name = cname
new_class_dict = {}
for class_attribute_name, class_value in cdict.items():