Skip to content

Instantly share code, notes, and snippets.

@Kmaschta
Kmaschta / django_active_view_tag.py
Last active February 20, 2016 17:23
Django active view tag
from django import template
register = template.Library()
# custom tag "active_view" to return 'active' in the template when the view is active
# usage : {% active_view request name='view-name' %}
# usage : {% active_view request url='/view/abs/url' %}
# usage : {% active_view request re='^/view/ur.*' %}
@register.simple_tag(takes_context=True)
def active_view(context, name=None, url=None, re=None, cond=True):
@Kmaschta
Kmaschta / install-gominer.sh
Last active March 22, 2017 14:25 — forked from albertstartup/steps.sh
AWS GPU / P2, Ubuntu 16.04, Nvidia driver 375 & CUDA 8.0, decred/gominer
#!/bin/bash
# Requirements
# - NVIDIA Driver - NVIDIA-Linux-x86_64-375.39.run - http://www.nvidia.fr/Download/index.aspx
# - CUDA runfile (local) - cuda_8.0.61_375.26_linux.run - https://developer.nvidia.com/cuda-downloads
sudo apt update -y && sudo apt upgrade -y
sudo apt install build-essential linux-image-extra-`uname -r` -y
chmod +x NVIDIA-Linux-x86_64-375.39.run
@Kmaschta
Kmaschta / wakatime_stats.py
Created May 5, 2017 15:21
Retrieve a maximum of Wakatime stat
#!/usr/bin/python
help = """Retrieve all the stats from WakaTime API
Usage:
wakatime_stats.py <token>
Options:
-h --help Show this very help message
See https://wakatime.com/developers
@Kmaschta
Kmaschta / setup-tests.js
Created October 27, 2017 09:40
Prevent unhandled Promise rejection errors
// Warn from unhandled promise rejection that can occurs without failing tests
// jest --setupFiles setup-tests.js
process.on('unhandledRejection', (error, promise) => {
console.error('Unhandled Rejection at:', promise, `\n${error.stack}`);
});
@Kmaschta
Kmaschta / index.js
Created February 12, 2018 12:48
Express-Winston Benchmark
const express = require('express');
const winston = require('winston');
const expressWinston = require('./express-winston');
const app = express();
const consoleFormatter = ({ level, meta: { req, res, responseTime, stack } }) => {
let msg = `${winston.config.colorize(level, level)} HTTP ${req.method} ${req.url}`;
if (res) {
@Kmaschta
Kmaschta / index.js
Created March 6, 2018 07:11
Apollo Memory Debug
require('isomorphic-fetch');
const express = require('express');
const { makeExecutableSchema } = require('graphql-tools');
const graphqlHTTP = require('express-graphql');
const books = [
{ title: "Harry Potter and the Sorcerer's stone", author: "J.K. Rowling" },
{ title: "Jurassic Park", author: "Michael Crichton" },
];
### Keybase proof
I hereby claim:
* I am kmaschta on github.
* I am kmaschta (https://keybase.io/kmaschta) on keybase.
* I have a public key ASAvkWIvIk1a3VcepH9b0Rl9_wd2ECc7UaHwaUDbLtBuIwo
To claim this, I am signing this object:
@Kmaschta
Kmaschta / algo-dobble.py
Last active April 12, 2019 19:26
Algorithme Dobble
#!/usr/bin/python
# coding: utf-8
import sys
def plan_projectif(modulo):
"""Génération d'un plan projectif réel
Il est composé d'un plan affine (une matrice) et
des points à l'infini du plan réel.
@Kmaschta
Kmaschta / Parse-International-Days.js
Created April 29, 2019 11:44
Parse International Days
// https://www.journee-mondiale.com/les-journees-mondiales.htm
(() => {
const links = {};
const articles = document.querySelectorAll('article');
articles.forEach((article, monthIndex) => {
const items = article.querySelectorAll('li');
items.forEach((li) => {
@Kmaschta
Kmaschta / Makefile
Created December 12, 2017 16:49
Artifact deployment example
.PHONY: build
TAG ?=
SERVER ?= staging-server
install:
npm install
start:
node --require reify server.js