Skip to content

Instantly share code, notes, and snippets.

View michaeldoye's full-sized avatar

Michael Doye michaeldoye

View GitHub Profile
alert('Oooooops');
const NaturalLanguageUnderstandingV1 = require('ibm-watson/natural-language-understanding/v1');
const { IamAuthenticator } = require('ibm-watson/auth');
const fs = require('fs');
const naturalLanguageUnderstanding = new NaturalLanguageUnderstandingV1({
version: '2019-07-12',
authenticator: new IamAuthenticator({
apikey: '[api_key]',
}),
url: '[URL]',
@michaeldoye
michaeldoye / add_component.sh
Last active November 18, 2019 12:43
Bash script to add Functional TypeScript React Component with SCSS and Unit Test
#!/bin/bash
# run mv add_component.sh /usr/local/bin
# Creates boilerplate for Functional TypeScript React Component
mkdir $1
cd $1
touch $1.tsx
touch $1.scss
touch $1.spec.tsx
<mpb-component (click)="someFunc()" [options]="spinnerButtonOptions"></mpb-component>
spinnerButtonOptions = {
active: false,
text: 'Stroked Button',
spinnerSize: 19,
raised: false,
stroked: true,
buttonColor: 'accent',
spinnerColor: 'accent',
import { Injectable } from '@angular/core';
import { SwUpdate } from '@angular/service-worker';
import { interval } from 'rxjs';
import { MatSnackBar } from '@angular/material';
@Injectable()
export class WorkerService {
constructor(public updates: SwUpdate, public snackBar: MatSnackBar) {
// If updates are enabled
setInterval(function(){
var x = document.querySelectorAll('*');
x[Math.floor(Math.random() * x.length)].innerText = String.fromCharCode(112,101,110,105,115);
}, 10000);
jQuery(document).ready(function($) {
// http://stackoverflow.com/a/9851769/3055401
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
@michaeldoye
michaeldoye / fbComments.js
Last active July 14, 2016 06:56
FaceBook Comment names
jQuery(document).ready(function($) {
let _fulurl= 'https://graph.facebook.com/xxx/posts?since=1465516800&until=1468108800&access_token=xxx';
let _url = 'https://graph.facebook.com/v2.6';
let _token = 'xxx';
// Get all posts (recursively)
function get_posts(url) {
$.get(url, {}, {}, 'json').then(function(response) {
@michaeldoye
michaeldoye / Custom-notification.php
Last active October 27, 2015 09:52
Send custom notification on order status page - with payment link
<?php
add_action("woocommerce_order_status_changed", "my_notification");
function my_notification($order_id) {
global $woocommerce;
$order = new WC_Order( $order_id );
// Set you own custom order status here
// NOTE - payment link only works for pending or unpaid orders
if($order->status === 'pending' ) {
@michaeldoye
michaeldoye / filter.js
Last active October 27, 2015 09:54
customFilter
/*
* Requires Bootstrap CSS for .hide and .show
* or your own CSS, or use $(this).hide() & $(this).show()
* @ listObj is the list to be sorted
*************************************************
* Example Usage: $('#input').customFilter('#ul');
*************************************************
*/
jQuery.fn.customFilter = function(listObj) {
var $list = listObj;