Skip to content

Instantly share code, notes, and snippets.

View foxyblocks's full-sized avatar

Chris Schlensker foxyblocks

View GitHub Profile
@foxyblocks
foxyblocks / javascript.json
Last active February 2, 2021 17:31
Paste this into your vscode javascript user snippets. Activate it by typing 'nim+TAB'. It will focus the path part of the import statement first which will cause autocomplete to work on the named import.
{
"Completeable named import": {
"prefix": ["nim"],
"body": ["import { ${2:value} } from \"${1:path}\";$0"],
"description": "A javascript named import statement that works with autocomplete by making you type the path statement first"
}
}
## Given a glob pattern and a base directory expands that into a list of sass @import statements for files in that directory
glob = ARGV[0]
basedir = ARGV[0]
Dir.chdir(basedir) do
Dir[glob].each do |f|
puts "@import '#{f.gsub(/.scss$/, '')}';"
end
@foxyblocks
foxyblocks / ClickBoundary.jsx
Last active August 4, 2018 22:02
ClickBoundary react component implementation used inside the Bugsnag dashboard.
// Author: Christian Schlensker for Bugsnag.
// @flow
import { omit } from 'lodash';
import * as React from 'react';
// Creates a React context to track track the tree of ClickBoundaries down the component hierarchy.
const NodeContext = React.createContext();
type Props = {
#!/usr/bin/env ruby
ROOT_PATH = File.dirname(__FILE__) + '/js/dashboard/'
COMPONENT_REGEX = /window\.(\w+) =.+(React|Reflux)/
files = Dir.glob(ROOT_PATH + "**/*.{js,jsx,coffee,cjsx}")
# hard coded modules that we want to require. This list will be amended by searching for
# `window.X = (React|Redux)` definitions in the code base
components = [
{name: 'UserActions', import_path: 'user_actions'},
{name: 'UrlService', import_path: 'services/url_service'},
@foxyblocks
foxyblocks / bugsnag.js
Last active August 1, 2016 23:52
A simple isomorphic bugsnag module. (requires that process.env.IS_BROWSER be present in browser build)
// The bugsnag javascript libraries are not isomorphic so we need to specify which one we want to use depending on environment.
let Bugsnag;
if (process.env.IS_BROWSER) {
Bugsnag = require('bugsnag-js');
Bugsnag.apiKey = process.env.MY_BROWSER_PROJECT_API_KEY;
} else {
Bugsnag = require('bugsnag-node');
Bugsnag.register(process.env.MY_NODE_PROJECT_API_KEY);
}
@foxyblocks
foxyblocks / setup.js
Created June 29, 2016 22:21
Automatic angular http error tracking with Bugsnag
angular.module('myApp').config(['$httpProvider', function ($httpProvider) {
var interceptor = ['$q', function ($q) {
function success(response) {
return response;
}
function error(response) {
// Here we decide when and how to notify Bugsnag
if (response.status != 400) { // skip notification for form validation errors
Bugsnag.notify(response.statusText, response.config.url, {response: response})
8fa668c - (HEAD, origin/master, origin/HEAD, master) fix landing spec (4 minutes ago) <Christian Schlensker>
diff --git a/spec/features/landing_spec.rb b/spec/features/landing_spec.rb
index 13a5cc5..167cdae 100644
--- a/spec/features/landing_spec.rb
+++ b/spec/features/landing_spec.rb
@@ -42,7 +42,7 @@ describe 'Course Landing Pages', :js do

within container do
fill_in :email, with: email
- click_on button
if student == :brave
puts "Griffindor!"
elsif student == :smart
puts "Ravenclaw!"
elsif student == :asshole
puts "Slytherin!"
else
puts "Shit... I don't know... Hufflepuff! ... I guess..."
end
var angular = require('angular');
// Simple directive that prevents an event from propagating to
// up the dom tree.
//
// ex:
// <div ng-click='doSomething()'>
// <a stop-event='click'>Some link</a>
// </div>
//
PROPS = %w{
appearance
align-content
align-items
backface-visibility
background-size
border-radius
box-orient
box-shadow
box-sizing