Skip to content

Instantly share code, notes, and snippets.

@matiboy
matiboy / chrome_dev_tools_snippet.js
Created July 18, 2025 06:18
Download invoices from Wave Sales & Payments -> Invoices page
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
function clickDownloadButton() {
document.querySelector("span.export-pdf-modal button.wv-button--primary").click()
}
function clickExportButton() {
document.querySelectorAll("span.export-pdf-modal button").item(2).click()
}
function openExportToPDFModal(r) {
@matiboy
matiboy / if_else_as.py
Created January 21, 2024 15:53
Django template tag setting variable to context with an if/else condition
from django.template.defaulttags import TemplateIfParser
from django import template
register = template.Library()
class IfElseAs(template.Node):
def __init__(self, condition, if_var, else_var, var_name):
self.condition = condition
self.if_var = template.Variable(if_var)
self.else_var = template.Variable(else_var)
@matiboy
matiboy / test_scan.py
Created August 23, 2023 06:58
Scan with timestamp to remove old entries
from datetime import timedelta
import time
from reactivex.notification import OnError
from reactivex.testing import ReactiveTest, TestScheduler
from reactivex.testing.subscription import Subscription
from reactivex import operators
import reactivex
on_next = ReactiveTest.on_next
on_error = ReactiveTest.on_error
@matiboy
matiboy / gist:26ea3f0619920ab8cf2a
Created March 13, 2015 23:53
Commentable gist
import random
print random.pick([1,2,3])
var jasmineNG = {};
//set $q in your test
jasmineNG.$q = null;
//Could make similar to test a failing promise
jasmineNG.createPromiseReturningSpy = function() {
var deferred = jasmineNG.$q.defer();
// Use .andReturn to simply return a promise
var spy = jasmine.createSpy().andReturn(deferred.promise);
// Add resolve and reject functionalities
spy.andResolveWith = function(val) {
@matiboy
matiboy / localCss.js
Created April 10, 2013 13:58
Local CSS directive for Angular. Loads CSS on scope and destroys it together with the scope
'use strict';
angular.module('assetsApp')
.directive('localCss', function () {
return {
template: '',
restrict: 'E',
link: function (scope, element, attrs) {
var style = document.createElement('link');
style.type = 'text/css';
@matiboy
matiboy / localCss.js
Created April 10, 2013 13:47
Angular directive for local loading of CSS file
'use strict';
angular.module('assetsApp')
.directive('localCss', function () {
return {
template: '',
restrict: 'E',
link: function (scope, element, attrs) {
var style = document.createElement('link');
style.type = 'text/css';
@matiboy
matiboy / gist:5354765
Created April 10, 2013 13:46
Angular directive for local loading of CSS file
'use strict';
angular.module('assetsApp')
.directive('localCss', function () {
return {
template: '',
restrict: 'E',
link: function (scope, element, attrs) {
var style = document.createElement('link');
style.type = 'text/css';
@matiboy
matiboy / gist:5354764
Created April 10, 2013 13:46
Angular directive for local loading of CSS file
'use strict';
angular.module('assetsApp')
.directive('localCss', function () {
return {
template: '',
restrict: 'E',
link: function (scope, element, attrs) {
var style = document.createElement('link');
style.type = 'text/css';
'use strict';
deferredApp.controller('MainCtrl', function ($scope, playerService, $timeout, $http, $q) {
// For visualization purposes
$scope.messages = [];
var player, videoId; // initialize variables
var ytQ = playerService.create("ytplayer"); // Returns a deferred object
// Called when the ytQ deferred object is resolved