Skip to content

Instantly share code, notes, and snippets.

View tbeseda's full-sized avatar
🐀
womp rat

Taylor Beseda tbeseda

🐀
womp rat
View GitHub Profile
@sjorsrijsdam
sjorsrijsdam / README.MD
Last active February 23, 2024 17:39
Server-side code highlighting for Enhance.dev

Server-side highlighting of code in HTML

Basically you place you code examples in your HTML code in the <code-example> custom element with a language attribute for the language. Then, in the API handler you run the entire HTML blob through the highlightCode() function. This will use the existing @begin/parse5 package to parse the HTML. It will then traverse the DOM tree, find the <code-example> elements, do PrismJS magic on its contents and then places them back. At the custom element expansion stage the highlighted code gets put in the <pre> & <code> and adds the correct class name based on the language attribute of the <code-example> element.


Screenshot 2024-02-23 141917
@wesbos
wesbos / logger.js
Created January 8, 2024 15:55
console.log line numbers in Node.js
// Use like this: node --import logger.js yourapp.js
import path from 'path';
const { log } = console;
[`debug`, `log`, `warn`, `error`, `table`, `dir`].forEach((methodName) => {
const originalLoggingMethod = console[methodName];
console[methodName] = (...args) => {
const originalPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = (_, stack) => stack;
@xirkus
xirkus / yubikey+gpupgp+ssh_howto.md
Last active March 10, 2024 13:17
Security Adventures 1. How to get yubikey+gpg+ssh+gitbhub working on MacOS

I've spent the day trying to get this setup working with GitHub and given the number of gotcha's I encountered, it seemed like a good idea to document how I finally got this working with as few hacks as possible. There's a lot of documentation out there (some of it old and misleading) and committing here for posterity will help me remember this when I inevitably need to do this again.

Rationale

Passwords are simply not enough these days. Regardless of the company, breaches (and the associated Personally Identifiable Information harvested) are a matter of not if, but when. There are a number of things you can do to protect yourself, but being on the tin-foil-hat side of paranoia, means there are a few Commandents that I adhere to (and recommend for other folks)[Insert link to Fight Club Rules for the Secure Internet].

That being said, if you use 2-factor authentication and have committed to using a hardware token such as the Yubikey, then you're already ahead of the curve. The problem is that wh

@sj26
sj26 / LICENSE.md
Last active March 8, 2024 18:31
Bash retry function

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit

Visualize data from a SmartThings sensor with Dweet and Freeboard

My SmartThings multisensor is a great little piece of technology. It reports, in real time, motion, temperature, and open/close state of my back door. The iOS app is slick, too, but I wanted a way to view it from my computer and have access to historical data.
Enter Dweet and Freeboard from Buglabs.

The SmartThings SmartApp and Dweet

There's actually no setup required on Dweet (but be sure to check out their nifty demo). It just starts eating data and making it available for use via HTTP/JSON!

@tbeseda
tbeseda / commit-msg
Created March 24, 2014 18:26
Append current Rdio track to commit message
#!/usr/bin/ruby
message_file = ARGV[0]
def app_is_running?(app_name)
`ps aux` =~ /#{app_name}/ ? true : false
end
while true
if app_is_running?('Rdio.app')
@tbeseda
tbeseda / Preferences.sublime-settings
Last active September 27, 2015 05:58
My SublimeText 2 settings. A WIP.
{
"color_scheme": "Packages/Theme - Flatland/Flatland.tmtheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Inconsolata",
"font_size": 20.0,
"highlight_line": true,
"indent_guide_options":
[
"draw_normal",
"draw_active"
@fcalderan
fcalderan / inception-javascript.js
Created November 2, 2010 09:42
inception explained as a 4 nested javascript closures
/*
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02
* I had an idea: could Inception movie be explained by a few javascript closures
* and variable resolution scope (just for fun)?
*
* Activate javascript console =)
*/
<script>
console.group("inception movie");
@HenrikJoreteg
HenrikJoreteg / JS Util solution using underscore.js
Created October 22, 2010 21:20
Rather than creating some other util global, just extend underscore.js with any additional methods you want.
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');