Skip to content

Instantly share code, notes, and snippets.

@brantwedel
brantwedel / server.js
Created May 19, 2024 23:32
CSS scoped modules (Express, React)
import express from 'express';
import path from 'path';
import fs from 'fs';
const app = express();
const transformCssModule = (cssFilePath, cssUrlPath, scopeId, isolated = true) => {
const cssContent = fs.readFileSync(cssFilePath, 'utf8');
const classNames = new Set(cssContent.match(/\.[\w-_]+/g) || []);
let exportedClasses = `const isolated = ${isolated ? 'true' : 'false'};\nconst _styles = { $scoped: '__scoped', scoped: '__scoped', ':scoped': '__scoped', root: '__root', $root: '__root', ':root': '__root', host: '__root', $host: '__root', ':host': '__root' };\n`;
@brantwedel
brantwedel / xcode-sync.swift
Last active May 14, 2024 05:02
XCode project file sync script
#!/usr/bin/env swift
import Foundation
// usage:
// swift xcode-sync.swift XCodeProject.xcodeproj --sync FolderToSync
struct ANSI {
// Foreground Colors
static let black = "\u{001B}[30m"
static let red = "\u{001B}[31m"
// ----
// Sass (v3.4.25)
// Compass (v1.0.3)
// ----
////////////////////////////////////////////////////////////////////////////////
// Sass Expression Eval
// Brant Wedel
// bitbased.net
// https://gist.github.com/brantwedel/3bba625840e247438c9770aa46881718
@brantwedel
brantwedel / app.html
Last active May 3, 2018 04:47
template-binding shorthand css property bug
<template>
<h1>${message}</h1>
<div ref="borderDiv" click.delegate="toggleBorder()" css="${borderCss}">
<h2>Click to toggle my border</h2>
<hr>
<h4>css binding:</h4>
<code>${borderCss}</code>
<hr>
<h4>actual style attribute:</h4>
@brantwedel
brantwedel / btt-chrome-cycle-tabs.scpt
Last active October 4, 2018 02:58
TouchBar "Dock" using Better Touch Tool
# cycle through Google Chrome tabs and windows
tell application "System Events"
set activeApp to name of first application process whose frontmost is true
try
set activeChrome to first application process whose name is "Google Chrome"
set appName to name of window 1 of activeChrome
on error errMsg
tell application "Google Chrome" to make new window
tell application "Google Chrome" to activate
@brantwedel
brantwedel / select-all.js
Created March 20, 2017 16:05
Script for adding select-all functionality to jscut.org using tampermonkey.net browser plugin
// ==UserScript==
// @name JSCUT Select All
// @namespace http://bitbased.net/
// @version 0.1
// @description Add double click select all to jscut.org
// @author Brant Wedel - bitbased.net
// @match http://jscut.org/jscut.html
// @grant none
// ==/UserScript==
@brantwedel
brantwedel / dremel200.stl
Created February 23, 2016 15:57
Dremel 200 Model
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brantwedel
brantwedel / keyboard-focus.js.coffee
Last active August 29, 2015 13:57
Detect keyboard in PhoneGap/HTML5 app to modify UI and keep text input in view
setInterval ->
return if $("#footer-region").length == 0
window.last_width |= 0
window.last_height |= 0
width = $("#footer-region").width()
height = $("#footer-region").offset().top + $("#footer-region").height()
unless window.active_input_listeners
window.active_input_listeners = true
@brantwedel
brantwedel / seeds.rb
Last active December 25, 2015 19:49
Sequential ID's for ActiveRecord Fixtures. For using fixtures in db/seeds.rb
# Open and override ActiveRecord::FixtureSet with new identify method implementation to support sequentual ID's
module ActiveRecord
class FixtureSet
@@seq_id = 0
@@seq_keys = {}
def self.identify(label)
@@seq_keys[label] ||= begin
@@seq_id += 1
@@seq_id
end