Skip to content

Instantly share code, notes, and snippets.

View xavhan's full-sized avatar
💭
Hello

Xavier Haniquaut xavhan

💭
Hello
View GitHub Profile
@xavhan
xavhan / deprecated.ts
Created December 1, 2021 14:02
Use TS to force document your deprecations
const log = true; // comming from logging service (dont log in prod)
//
type Deprecation = {
what: string;
because: string;
recommendation: string;
adr_link: string;
}
#!/usr/bin/env zx
// you need zx installed
// run with `zx smoketest.mjs`
const BASEURL = 'http://localhost:3000';
const COMMON = [
'header',
'footer',
]
@xavhan
xavhan / machine.js
Last active October 15, 2020 15:21
Generated by XState Viz: https://xstate.js.org/viz
const sharedStates = {
initial: 'pending',
states: {
pending: {
on: {
'': {
target: 'active',
cond: 'isActivated'
},
}
@xavhan
xavhan / machine.js
Last active October 15, 2020 14:40
Generated by XState Viz: https://xstate.js.org/viz
const sharedStates = {
initial: 'pending',
states: {
pending: {
on: {
ACTIVATE: 'active',
}
},
active: {
@xavhan
xavhan / machine.js
Last active October 15, 2020 13:57
Generated by XState Viz: https://xstate.js.org/viz
const campaignStateMachine = Machine({
id: 'Campaign state',
initial: 'draft',
guards: {
beforeActivation: (c,e) => false,
inActivation: (c,e) => true,
afterDeactivation: (c,e) => false,
},
states: {
@xavhan
xavhan / machine.js
Last active May 27, 2020 14:23
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'report',
initial: 'idle',
context: {
answers: 0,
},
states: {
idle: {
on: {
CREATE_REPORT: 'filled'

Financiers

Need

| Nom     | Qté       |      |     |     |     |
|---------|-----------|------|     |     |     |
| sucreGla| 60g       |  105 |  92 | 265 | 220 |culdepoule1
| pamande | 30g       |  53  |  41 | 118 | 98  |culdepoule1
| farine  | 20g       |  35  |  27 | 78  | 65  |culdepoule1
| beurre | 50g | 87 | 76 | 220 | 183 |casserole1
@xavhan
xavhan / circlecistatus.js
Created November 19, 2015 16:08
Circle CI status + karma-coverage link
var REPO = 'githubUsername/repoName';
var TOKEN = 'token';
getCircleStatus(TOKEN, REPO);
function getCircleStatus() {
var endpoint = 'project/' + REPO;
httpGetAsync(endpoint, printStatus)
}
@xavhan
xavhan / ytmp3.zsh
Last active January 10, 2016 14:56
Alias for downloading youtube music and automatically tag it
# Nice alias for youtube-dl for downloading mp3 from youtube
# and other media services, parse the title and the thumbnail
# to add the adequate metadatas.
# You need to provide a youtube id.
# > ytmp3 venrUQLZ87M
# or
# > ytmp3 https://www.youtube.com/watch?v=venrUQLZ87M
# It works with playlists too !
#
//count($0); for counting watchers on the selected dom element
//count($0, true); for counting watchers on the selected dom element + childrens
function count(el, recurs) {
var root = $(el);
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);