Skip to content

Instantly share code, notes, and snippets.

@kaplanmaxe
kaplanmaxe / selectors.js
Created February 19, 2017 13:11
You don't need jQuery for that
document.querySelector('#exampleId');
document.querySelector('.exampleClass');
document.querySelectorAll('.exampleClass');
@kaplanmaxe
kaplanmaxe / errors.js
Last active February 18, 2017 17:31
Throwing Errors in JS
/**
* The proper way of throwing an error in JavaScript. Even prints a stack trace for you!
*/
throw new Error('I am learning way too much JS in one day');
/**
* Now we can even make our own errors.
*/
function LearningError(message) {
this.message = message;
@kaplanmaxe
kaplanmaxe / speech.js
Last active February 18, 2017 16:36
JS Speech Synthesis
const msg = new SpeechSynthesisUtterance('hello, max');
window.speechSynthesis.speak(msg);
@kaplanmaxe
kaplanmaxe / debug.js
Last active February 18, 2017 16:32
Advanced debugging with js
/**
* Neatly output results of an array into a nice table
* API: https://developer.mozilla.org/en-US/docs/Web/API/Console/table
*/
console.table([
{ name: 'Max', age: 24 },
{ name: 'Susan', age: 52 },
{ name: 'John', age: 33 }
]);
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.groupme.com/v3/bots/post');
curl_setopt($ch, CURLOPT_POST, 1);
//REPLACE YOUR_BOT_ID with BOT_ID FROM GROUPME
curl_setopt($ch, CURLOPT_POSTFIELDS, "text=TESTING&bot_id=YOUR_BOT_ID");
curl_exec($ch);
curl_close($ch);