Skip to content

Instantly share code, notes, and snippets.

@simenbrekken
simenbrekken / README.md
Last active November 9, 2023 16:56
Hide fetch/XHR in Cypress command log

This novel workaround simply hides any command log entries that originate from fetch/XHR requests.

While I've updated this receipe for Cypress 10 and converted it to TypeScript you should be able to use it in a JavaScript project by ignoring the cypress.d.ts file and placing the snippet from e2e.ts in e2e.js instead.

@simenbrekken
simenbrekken / schema.js
Created December 21, 2016 14:06
Firebase backed GraphQL schema
import firebase from 'firebase'
import { filter, map } from 'lodash'
import { makeExecutableSchema } from 'graphql-tools'
firebase.initializeApp({
databaseURL: 'https://grafire-b1b6e.firebaseio.com',
})
const mapSnapshotToEntity = snapshot => ({ id: snapshot.key, ...snapshot.val() })
const mapSnapshotToEntities = snapshot => map(snapshot.val(), (value, id) => ({ id, ...value }))
@simenbrekken
simenbrekken / README.md
Created March 8, 2012 06:39
Super simple Backbone + Express + MongoDB REST backend application

Requirements:

If you're on OSX you're probably best off using Homebrew to install this stuff:

$ brew install node mongodb

Usage:

@simenbrekken
simenbrekken / .htaccess
Created August 27, 2012 18:53
Apache mod_rewrite cookie based localization
RewriteEngine On
# Set locale cookie if lang query string is set (90 days expiry time)
RewriteCond %{QUERY_STRING} lang=(.*)
RewriteRule .* ?locale=%1 [cookie=locale:%1:.%{HTTP_HOST}:129600:/]
# Append locale to query string if:
# - Query string hasn't already been rewritten
# - Locale cookie is set
# - Request URI isn't a valid file (for assets etc.)
@simenbrekken
simenbrekken / README.md
Created May 9, 2012 08:06
Setting up a local wildcard DNS server

#Installation#

First you'll need [dnsmasq][1], assuming you're on OSX installation is simply:

brew install dnsmasq

#Configuration#

Add 127.0.0.1 to to the top of your DNS server list in your Network Configuration:

@simenbrekken
simenbrekken / uploader.js
Created May 2, 2012 13:38
Fetch, resize via ImageMagick and store image on Amazon S3 with node.js
var spawn = require('child_process').spawn,
aws2js = require('aws2js'),
http = require('http'),
urlutil = require('url')
mime = require('mime'),
Buffers = require('buffers');
var settings = {
s3: {
key: 'key',
@simenbrekken
simenbrekken / CategoryActions.js
Last active May 9, 2020 16:25
Category Actions
'use strict';
var createAsyncActions = require('./createAsyncActions')
var CategoryAPI = require('../api/CategoryAPI')
var CategoryActions = createAsyncActions({
create: function(category) {
CategoryAPI
.create(category)
@simenbrekken
simenbrekken / index.html
Created September 20, 2013 06:41
Real-time multi-series time series chart data
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
@simenbrekken
simenbrekken / gulpfile.js
Created March 14, 2014 08:54
React project gulpfile
var gulp = require('gulp'),
gutil = require('gulp-util')
// HTML
gulp.task('html', function() {
return gulp.src('src/index.html')
.pipe(gulp.dest('build'))
})
// Scripts
@simenbrekken
simenbrekken / README.md
Last active August 7, 2019 15:01
Apollo Client 2.0 withFragments

This HoC gives you a way to work with co-located fragments that is similar to Relay's FragmentContainer

It supports both fragment maps extrapolation of prop names from fragment definitions.

Fragment map

export default withFragments({
  price: gql`
 fragment ProductDetails_price on Product {