Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Schlensker foxyblocks

View GitHub Profile
View expand_sass_glob.rb
## 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 Aug 4, 2018
ClickBoundary react component implementation used inside the Bugsnag dashboard.
View ClickBoundary.jsx
// 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 = {
View rename.rb
#!/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 Aug 1, 2016
A simple isomorphic bugsnag module. (requires that process.env.IS_BROWSER be present in browser build)
View bugsnag.js
// 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 Jun 29, 2016
Automatic angular http error tracking with Bugsnag
View setup.js
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})
View fix.diff
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
View sorting_hat.rb
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
View stop_event.directive.js
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>
//
View compass_convert.rb
PROPS = %w{
appearance
align-content
align-items
backface-visibility
background-size
border-radius
box-orient
box-shadow
box-sizing
@foxyblocks
foxyblocks / classic.js
Created Jan 25, 2015
Elevator Saga (classic elevator strategy)
View classic.js
{
init: function(elevators, floors) {
var floorsWaiting = {
up: [],
down: []
};
var self = this;
var distance = function(num1, num2) {
You can’t perform that action at this time.