Skip to content

Instantly share code, notes, and snippets.

<?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);
@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 / mail.php
Last active May 7, 2020 05:02
PHP Recaptcha PHP tutorial
<?php
$sender_name = stripslashes($_POST["sender_name"]);
$sender_email = stripslashes($_POST["sender_email"]);
$sender_message = stripslashes($_POST["sender_message"]);
$response = $_POST["g-recaptcha-response"];
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
'secret' => 'YOUR_SECRET',
'response' => $_POST["g-recaptcha-response"]
@kaplanmaxe
kaplanmaxe / index.html
Created February 18, 2017 13:52
PHP ReCAPTCHA Form
<form action="mail.php" method="post" enctype="multipart/form-data">
<input name="sender_name" placeholder="Your Name..."/>
<input name="sender_email" placeholder="Your email..."/>
<textarea placeholder="Your Message..." name="sender_message">
<div class="captcha_wrapper">
<div class="g-recaptcha" data-sitekey="YOUR_KEY"></div>
</div>
<button type="submit" id="send_message">Send Message!</button>
</form>
@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 }
]);
@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 / 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 / arraysbyref.js
Created February 19, 2017 13:20
JS Arrays are By Reference by default
const a = [0, 1, 2, 3];
const b = a;
b.push(10);
console.log(b); // [0, 1, 2, 3, 10]
console.log(a); // [0, 1, 2, 3, 10] (10 got pushed to a even though we only pushed to b)
// To AVOID passing by reference
const foo = [0, 1, 2, 3];
const bar = foo.concat([10]);
console.log(bar); // [0, 1, 2, 3, 10]
@kaplanmaxe
kaplanmaxe / objectsbyref.js
Last active February 19, 2017 13:27
JS Objects are By Reference by default
const a = { name: 'Max', age: 24 };
const b = a;
b.name = 'Barbara';
console.log(b); // { name: 'Barbara', age: 24 }
console.log(a); // { name: 'Barbara', age: 24 } (a.name was overwritten as well by b.name)
// To avoid passing by reference
const foo = { name: 'Max', age: 24 };
const bar = Object.assign({}, foo);
bar.name = 'Barbara';
@kaplanmaxe
kaplanmaxe / speechrecognition.js
Last active February 19, 2017 14:14
JS Speech Recognition
// API: https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API
const recognition = new webkitSpeechRecognition();
recognition.onresult = function(event) {
for (let i = event.resultIndex; i < event.results.length; ++i) {
console.log(event.results[i][0].transcript);
}
}
recognition.start(); // Click allow when browser prompts to use your microphone
recognition.stop(); // Call this when done talking.