Skip to content

Instantly share code, notes, and snippets.

@rmarscher
rmarscher / waku.cloudflare-dev-server.ts
Last active July 20, 2024 16:36
Waku Cloudflare Pages Dev Server Middleware
import type { GetPlatformProxyOptions } from "wrangler"
import type { Middleware } from "waku/config"
type Handler = ReturnType<Middleware>
export const cloudflareDevServer = (cfOptions: GetPlatformProxyOptions) => {
const middleware: Middleware = (options) => {
if (import.meta.env && import.meta.env.MODE === "production") {
// pass through
return (_ctx, next) => next()
@rmarscher
rmarscher / fetch-graphql-schema.js
Created September 16, 2016 21:04
fetch-graphql-schema.js
// A script that can pull down the result of the introspection query
// from a running graphql server.
// Dependencies:
// npm i -S isomorphic-fetch graphql-tag graphql apollo-client
// Usage:
// node fetch-graphql-schema [graphql url]
// Example:
@rmarscher
rmarscher / openbr.rb
Created July 21, 2016 03:48
Homebrew formula for OpenBR with pull #486
class Openbr < Formula
# This should just temporarily override the official homebrew formula
# until the next release. And it is pointing to a commit on the
# master git branch, so use at your own risk. It does seem
# to get things working with the latest Qt version on homebrew.
# See https://github.com/biometrics/openbr/pull/486
# Copy the contents of this file to
# /usr/local/Library/Taps/homebrew/homebrew-science/openbr.rb
desc "Open Source Biometric Recognition"
@rmarscher
rmarscher / iscrollHandler.js
Last active January 15, 2018 04:07
scrollOverflowHandler for fullPage.js using iscroll
// Usage: requires a version of fullPage.js that incorporates
// pull request #1498: https://github.com/alvarotrigo/fullPage.js/pull/1498
//
// Then initialize fullPage.js and set this object to the
// scrollOverflowHandler option.
// ```
// scrollOverflow: true,
// scrollOverflowHandler: iscrollHandler,
// ```
@rmarscher
rmarscher / Modules.php
Last active August 29, 2015 13:58
Joomla! Template Module Positions In Lithium PHP
<?php
namespace app\extensions\helper;
use lithium\core\Libraries;
use lithium\template\view\TemplateException;
use lithium\template\View;
/**
* An implementation of Joomla! template module positions for Lithium.
@rmarscher
rmarscher / index.js
Created October 18, 2013 17:17
Invoke a shotgun.js shell from command-line without opening prompt. Put these files in a directory, run npm install, then run `node . help` to see it work.
var readline = require('readline'),
shotgun = require('shotgun'),
shell = new shotgun.Shell(),
context = {}; // Declare empty context object.
// Create interface that reads from console and outputs to console.
var rl = readline.createInterface(process.stdin, process.stdout);
// Configure shotgun.
shell
@rmarscher
rmarscher / DownloadsController.php
Created October 14, 2013 04:38
Lithium PHP framework CSV media handler - blacklists data not intended for export. See StackOverflow question "How do you remove specific fields from all entities of a record set in Lithium?": http://stackoverflow.com/questions/17189664/how-do-you-remove-specific-fields-from-all-entities-of-a-record-set-in-lithium/17202455
<?php
namespace app\controllers;
use app\models\Downloads;
class DownloadsController extends \lithium\action\Controller {
public function index() {
$this->request->privateKeys = array('id', 'user_id');
@rmarscher
rmarscher / MongoLogger.php
Created October 8, 2012 05:24
MongoDB logging in Lithium PHP
<?php
namespace li3_common\analysis;
use lithium\action\Request;
use lithium\console\Request as ConsoleRequest;
use lithium\core\Environment;
use lithium\data\Connections;
use lithium\util\String;
use MongoDate;
@rmarscher
rmarscher / errors.php
Created August 24, 2012 03:58
li3 airbrake in errors bootstrap
<?php
use lithium\action\Response;
use lithium\core\Environment;
use lithium\core\ErrorHandler;
use lithium\core\Libraries;
use lithium\console\Response as ConsoleResponse;
use lithium\net\http\Media;
use lithium\analysis\Logger;
use lithium\net\http\Service;
@rmarscher
rmarscher / uglify-watch.js
Created June 23, 2012 14:59 — forked from makeusabrew/1) uglify.js
Watch a specified directory's JavaScript files and recompile a specified output file if any changes are detected
/**
* Sample usage - note that the trailing slash on the watch directory is important!
*
* node uglify.js /path/to/my/src/directory/ /path/to/my/output/file.js
*/
var jsp = require('uglify-js').parser,
pro = require('uglify-js').uglify,
fs = require('fs');