Skip to content

Instantly share code, notes, and snippets.

@michaseel
michaseel / index.js
Created November 13, 2017 22:12
Moment.js get the first Tuesday of month (in Future)
const moment = require("moment")
// string date to test
const now = '2017-11-2';
function getFirstTuesday(date) {
result = moment(date).startOf('month');
while (result.day() !== 2) {
result.add(1, 'day');
}
function speak(textToSpeak) {
const synth = window.speechSynthesis;
// Create a new instance of SpeechSynthesisUtterance
var utterance = new SpeechSynthesisUtterance();
// Set the text
utterance.text = textToSpeak;
var voices = synth.getVoices();
function fib(n) {
if (n <= 2) return 1;
return fib(n-1) + fib(n-2);
}
function _fib(n) {
if (n <= 2) return 1;
return mfib(n-1) + mfib(n-2);
}
@michaseel
michaseel / VanillaJS Helpers
Last active December 29, 2020 02:06
VanillaJS Helpers
This is a set of vanillaJS helpers to pass on without jquery easier.
@michaseel
michaseel / bs-gridgenerator.js
Last active August 29, 2015 14:16
Bootstrap3 Gridgenerator
(function() {
var views = {xs:0,sm:768,md:992,lg:1200};
var css = '*,:after,:before{box-sizing:border-box}.container{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.row{margin-right:-15px;margin-left:-15px}[class^=col-]{position:relative;min-height:1px;padding-right:15px;padding-left:15px;float:left}';
for(var key in views) {
if (views.hasOwnProperty(key)) {
var value = views[key];
if (value!=0) css+='@media(min-width:'+ value +'px){.container{width:'+ parseInt(value-30,10) +'px}';
for (var i = 12; i > 0; i--) {
css+='.col-'+key+'-'+i+'{width:'+(i/12)*100+'%}';
css+='.col-'+key+'-pull-'+i+'{right:'+(i/12)*100+'%}';
@michaseel
michaseel / gist:d27a238164b7a69185e5
Created December 8, 2014 14:07
Speech Synthesis API
function speak(textToSpeak) {
// Create a new instance of SpeechSynthesisUtterance
var utterance = new SpeechSynthesisUtterance();
// Set the text
utterance.text = textToSpeak;
var voices = window.speechSynthesis.getVoices();
utterance.voice = voices.filter(function(voice) { return voice.name == 'Anna'; })[0];
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.1.min.js"></script>
</head>
<body>
<div id="map" style="width: 500px; height: 400px;"></div>