Skip to content

Instantly share code, notes, and snippets.

View mknepprath's full-sized avatar
🏠
Working from home

Michael Knepprath mknepprath

🏠
Working from home
View GitHub Profile
@mknepprath
mknepprath / lilt-test-1.html
Created January 10, 2016 05:05
First attempt at figuring out a good system for building Lilt.
<ul>Tweet "start" to begin.
<li>start
<ul>You are resting in a glade. There is a waterfall to your right and a pathway to your left. What will you do?
<li>walk down the path | walk down the pathway | take the path | walk the path
<ul>You walk down the path but soon realize your way is blocked by a large felled tree. You walk back.
</ul>
<li>pick up the ladle | pick up the #ladle | pick up ladle | pick the #ladle
<ul>You now have a <b>#ladle</b>.
</ul>
</li>
var position = "start";
var response = "";
$( "#tweet" ).click(function() {
var tweet = $('#move').val();
var move = $('#move').val().toLowerCase().replace(/[.,-\/#!$%\^&\*;:{}=\-_`~()]/g,"");
if (position === "start") {
// init cookie on first visit
if (!(Cookies.get('position'))) {
var position = "start";
Cookies.set('position', 'start');
$( ".command" ).prepend( "<li class='list-group-item list-group-item-warning'>&quot;Start&quot; to play.</li>" );
}
else {
var position = Cookies.get('position');
$( ".command" ).prepend( "<li class='list-group-item list-group-item-warning'>Continue your game or &quot;Reset&quot;. Current position: " + Cookies.get('position') + "</li>" );
};
// get data from Parse for interactions
var Interactions = Parse.Object.extend("Interactions");
var intsquery = new Parse.Query(Interactions).limit(1000);
var interactions = [];
intsquery.find({
success: function(ints) {
console.log("Successfully retrieved " + ints.length + " interactions.");
// create interactions array from Interactions in Parse
for (var i in ints) {
int = ints[i];
@mknepprath
mknepprath / best_animated_features.json
Created March 11, 2018 23:02
Best Animated Feature Films
[
{
"year":"2017",
"films":[
{
"title":"Coco",
"rating":82,
"box_office":208831333
},
{
// Run per page. You will have to hover over some posters before running to ensure `.icon-watched` is rendered.
const watchedActionButtons = [...document.querySelectorAll(".icon-watched")]
for (watchedActionButtonIndex = 0; watchedActionButtonIndex < watchedActionButtons.length; watchedActionButtonIndex++) {
watchedActionButtons[watchedActionButtonIndex].click()
console.log("Deleted movie at index #" + watchedActionButtonIndex + ".")
}
@mknepprath
mknepprath / speed_tracker.js
Last active September 23, 2019 15:53
Open https://fast.com/ and paste into the console to start creating a log of your internet speed.
const recordedSpeeds = []
setInterval(() => {
// Get internet speed
let speed = document.getElementById('speed-value').innerText
// Get speed units
const units = document.getElementById('speed-units').innerText
// Flatten speed if Kbps
if (units === 'Kbps') speed = "0"
// Display in console
console.log('='.repeat(Number(speed) / 5), speed)
@mknepprath
mknepprath / appify
Created January 8, 2020 16:31 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@mknepprath
mknepprath / extract-blog-meta.js
Last active January 10, 2020 02:32
A codemod that moves blog metadata to an object.
const transform = (file, api) => {
// Alias the jscodeshift API for ease of use.
const j = api.jscodeshift;
// Convert the entire file source into a collection of nodes paths.
const root = j(file.source);
const LAST_IMPORT = root.find(j.ImportDeclaration).at(-1);
const blogPageProps = [
@mknepprath
mknepprath / tweet-ids.js
Created February 11, 2020 03:15
Get a list of tweet IDs.
const hrefs = [];
setInterval(function() {
const timestamps = [...document.getElementsByTagName("time")];
timestamps.forEach(timestamp => {
if (timestamp.parentNode.href) {
const tweetId = timestamp.parentNode.href.split("/").pop();
hrefs.push(tweetId);
};
});