Skip to content

Instantly share code, notes, and snippets.

@daemonsy
daemonsy / schema-design-notes.md
Created September 30, 2019 19:24
Notes on Talk by Marc Andre Giroux on GraphQL Schema design

https://www.youtube.com/watch?v=pJamhW2xPYw&feature=youtu.be

GraphQL in Github

  • API first (each feature comes with its GraphQL API now)
  • GraphQL schema designed and built by product team (domain experts)
  • API team supports the process (technology experts)

Guiding Principles

  • Design for use cases / behavior over data
  • Anemic GraphQL (all data exposed but the schema is not useful to anyone)
@daemonsy
daemonsy / native-vs-babel.js
Last active April 5, 2018 03:54
Webpack Natve Import example. Babel modules on vs off
// ES6 Code
import { hi } from './greetings';
hi();
// Babel transpiled
var _greetings = __webpack_require__(/*! ./greetings */ "./src/greetings.js");
(0, _greetings.hi)();
// Webpack Syntax (with { modules: false })
/* harmony import */ var _greetings__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./greetings */ "./src/greetings.js");
@daemonsy
daemonsy / testing-using-lamba-tester.es6
Last active February 12, 2017 16:08
A simple example of testing using lambda-tester
// The event is saved as a JSON file
const statusOfLineEvent = JSON.parse(fs.readFileSync(process.cwd() + '/tests/fixtures/events/status-of-line.json'));
// This is the lambda handler function
import { handler } from '../index.js';
// Mocking the MTA API status network request
fetchMock.once(process.env.MTA_STATUS_URL, fs.readFileSync(process.cwd() + '/tests/fixtures/mta-status.xml', 'utf-8'));
// Using lamba tester to exercise the handler
@daemonsy
daemonsy / Alphasights_technical_challenge.md
Created August 26, 2016 18:04 — forked from tadast/Alphasights_technical_challenge.md
A technical challenge we give to our Ruby on Rails applicants in order to evaluate their coding proficiency. Job description: http://www.alphasights.com/positions/ruby-developer-london or http://www.alphasights.com/positions/ruby-developer-new-york

Alphasights Technical Challenge

Using Ruby on Rails we would like you to create a simple expert search tool. The application should fulfill the requirements below. The source code must be placed in a public repo on GitHub. The application should be deployable on Heroku.

  • I enter a name and a personal website address and a member is created.
  • When a member is created, all the heading (h1-h3) values are pulled in from the website to that members profile.
  • The website url is shortened (e.g. using http://goo.gl)
  • After the member has been added, I can define their friendships with other existing members. Friendships are bi-directional i.e. If David is a friend of Oliver, Oliver is always a friend of David as well.
  • The interface should list all members with their name, short url and the number of friends e.g. Alan http://goo.gl/3io1P (3)
@daemonsy
daemonsy / snippet-headers.json
Last active May 3, 2016 04:12
Snippet with headers from static.json
"headers": {
"/": {
"Cache-Control": "no-store, no-cache"
},
"**.js": {
"Cache-Control": "public, max-age=31536000",
"Access-Control-Allow-Origin": "cdn-instance.example.com"
},
"**.css": {
"Cache-Control": "public, max-age=31536000",
@daemonsy
daemonsy / proxies.json
Created May 3, 2016 03:46
Snippet of static.json
"proxies": {
"/api/": {
"origin": "https://backend.example.com/api"
}
}
@daemonsy
daemonsy / snippet-nginx.conf.erb
Created May 3, 2016 01:56
Proxy Config of Heroku Static Buildpack
<% proxies.each do |location, hash| %>
location <%= location %> {
proxy_pass <%= hash['origin'] %>;
}
<% end %>
@daemonsy
daemonsy / nginx.conf.erb
Created May 3, 2016 01:53
NGINX Configuration Template on Heroku's Static Buildpack
daemon off;
worker_processes auto;
events {
use epoll;
accept_mutex on;
worker_connections <%= worker_connections %>;
}
http {
@daemonsy
daemonsy / static.json
Last active May 3, 2016 04:12
Dragon's static.json with information redacted
{
"root": "dist/",
"https_only": true,
"routes": {
"/**": "index.html"
},
"proxies": {
"/api/": {
"origin": "https://backend.example.com/api"
}
ct_browser = function(){
var ua= navigator.userAgent, tem,
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
}
if(M[1]=== 'Chrome'){
tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');