Skip to content

Instantly share code, notes, and snippets.

// First, extract just the one table.
var table = document.querySelector("table");
// Then get all the rows from that table.
var tableRows = table.querySelectorAll("tr");
// I used `reduce` here, because the number of returned
// items might be different than the original array.
// It's probably possible to improve this. It was coded quickly.
var catArray = [...tableRows].slice(1).reduce((acc, row) => {
const el = row.querySelector("th[scope='row']");
@j127
j127 / cat-scraper.js
Last active June 16, 2022 14:00
Scrapes cat breed names from Wikipedia
// Scrapes cat breed names from https://en.wikipedia.org/wiki/List_of_cat_breeds
// Run it in the browser console on that page.
var table = document.querySelector("table");
var catNameArray =
[...table.querySelectorAll("th[scope='row']")]
.map((tr) => {
return tr
.innerText
@j127
j127 / auth_controller.rb
Last active October 28, 2019 15:10
Rails 5.2 with Discourse SSO Authentication
# This is just a sketch. Please leave a comment if you have suggestions.
class AuthController < ApplicationController
# Generate and SSO URL and redirect the user to Discourse
def authenticate
# Save the ?destination=some_url parameter if it exists
destination = request.query_parameters['destination'] || root_url
session[:destination] = destination
# `nonce` here will have `:value` and `:created_at` keys
nonce = generate_nonce
@j127
j127 / AFrameExporterScript.py
Created November 23, 2018 19:25 — forked from Utopiah/AFrameExporterScript.py
from Blender to WebVR in 1 click
'''
from Blender to WebVR in 1 click (warning: you need your own backend but a 1 php file is enough)
demo https://www.youtube.com/watch?v=PD1qTKp5DZ4
improvments
JS traverser to start/stop animations and change morph target values
render as 360 rather than mesh, either as an option and/or beyond a threshold
for addon proper https://docs.blender.org/manual/en/dev/advanced/scripting/addon_tutorial.html
@j127
j127 / sso_login_discourse.php
Created July 24, 2018 01:01 — forked from paxmanchris/sso_login_discourse.php
Discourse sso provider login
<?php
require('mysql.php'); // see https://gist.github.com/paxmanchris/f5d4b94f67a8acd8cefc
$me = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
$sso_secret = 'YOUR_SSO_PROVIDER_KEY_HERE';
$discourse_url = 'http://example.com';
if(!empty($_GET) and isset($_GET['sso'])){
@j127
j127 / org-mode-reference-in.org
Created November 26, 2017 07:39 — forked from drj42/org-mode-reference-in.org
This is a cheat sheet for Emacs org-mode... in org-mode format!
# @see http://editorconfig.org/
# This is the top-most .editorconfig file; do not search in parent directories.
root = true
# All files.
[*]
end_of_line = lf
indent_style = space
indent_size = 4
@j127
j127 / index.html
Last active February 13, 2017 11:21
fit
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<title>Website</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css">
@j127
j127 / index.html
Created January 13, 2017 05:24
Template for Bootstrap 4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Website</title>
@j127
j127 / index.html
Created October 31, 2016 17:54
Semantic UI Template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>Website</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.6/semantic.min.css" />