Skip to content

Instantly share code, notes, and snippets.

View Tazaf's full-sized avatar

Mathias Oberson Tazaf

  • SquareServices Sàrl
  • Suisse
View GitHub Profile
@Tazaf
Tazaf / geolocation.ts
Last active June 12, 2023 11:37
Geolocation module
import { Observable } from 'rxjs';
const hasApi = 'geolocation' in navigator;
export const Geolocation = {
getCurrentPosition(
options: PositionOptions = {}
): Promise<GeolocationPosition> {
return new Promise((resolve, reject) => {
if (!hasApi) {
@Tazaf
Tazaf / index.html
Last active April 24, 2023 15:17
MAS-RAD - Final example for "JavaScript - DOM API"
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap initiation</title>
<!-- Add here the link to Bootstrap -->
@Tazaf
Tazaf / cache-service.ts
Created January 13, 2020 15:55
Simple cache service base class
/**
* Extends this class to make any class a temporary-cache-like class.
*
* Especially useful for Angular services, so that you can store any value in it from _e.g._ a component,
* and retrieve this stored value from another component.
*
* This is a generic class to which you can specify the type of data that this cache should accept.
*/
export class CacheService<T> {
@Tazaf
Tazaf / wamp.service.ts
Created January 8, 2020 19:05
Minimal Angular WAMP Service
import { Injectable } from '@angular/core';
import { Connection, Session } from 'autobahn-browser';
import { Observable, Observer, ReplaySubject } from 'rxjs';
import { switchMap } from 'rxjs/operators';
const wampUrl = '<YOUR_WAMP_SERVER_URL>';
const wampRealm = '<YOUR_REALM_NAME>';
@Injectable({ providedIn: 'root' })
export class WampService {
@Tazaf
Tazaf / websocket.service.ts
Last active December 20, 2021 09:53
Minimal Angular WebSocket Service
import { Injectable } from '@angular/core';
import { Observable, Observer, ReplaySubject } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
const WS_SERVER_URL = '<YOUR_WEBSOCKET_URL>';
@Injectable({ providedIn: 'root' })
export class WebsocketService {
private ws$ = new ReplaySubject<WebSocket>(1);
@Tazaf
Tazaf / get-menu-item.js
Last active April 15, 2017 23:22 — forked from rawnly/getMenuItem.js
Get an item, by its label, from an electron menu or trayMenu
module.exports = function getItem(label, menu) {
for ( i in menu.items ) {
if ( menu.items[i].submenu && menu.items[i].submenu.items ) {
var subItem = menu.items[i].submenu.items.find((item) => {
return item.label === label
})
if (subItem) {
return subItem
} else {
@Tazaf
Tazaf / index.html
Last active May 4, 2023 14:26
MAS-RAD - Correct version of the Bootstrap Practice
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible"
content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1" />
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
@Tazaf
Tazaf / index.html
Last active April 24, 2023 11:51
MAS-RAD - Final example file for "Bootstrap - Layout management"
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap initiation</title>
<!-- Add here the link to Bootstrap -->
@Tazaf
Tazaf / index.html
Last active April 24, 2023 11:47
MAS-RAD - Final example file for "Bootstrap - Basics"
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap initiation</title>
<!-- Add here the link to Bootstrap -->
@Tazaf
Tazaf / index.html
Last active February 24, 2017 17:27
Bootstrap basic HTML template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap initiation</title>
<!-- Add here the link to Bootstrap -->