Skip to content

Instantly share code, notes, and snippets.

View drt-server-openapi.yml
openapi: 3.0.2
info:
version: 0.0.1
title: Rideshare API
description: |
The Rideshare API provides access to the rideshare service runned by [door2door](https://www.door2door.io/).
# Environments
This API can be consumed in two different environments, staging and production.
View my-gist
hello
world
from
berlin
@nicolasiensen
nicolasiensen / test-material-ui-event-simulation.js
Created Dec 20, 2016
Simulating events with Jest and Material UI
View test-material-ui-event-simulation.js
// Simulating clicks
const dashboardMount = mount(
<Dashboard />, {
context: { muiTheme },
childContextTypes: { muiTheme: React.PropTypes.object }
}
)
const menuButton = ReactDOM.findDOMNode(dashboardMount.find(AppBar).find(IconButton).find('button').node)
TestUtils.Simulate.touchTap(menuButton)
View extendComponentWithMUITheme.js
// This helper is required to test any component that renders material-ui components.
// If you are getting a message saying:
// 'undefined is not an object (evaluating this.context.muiTheme.prepareStyles)'
// you should use this helper.
// The usage is simple, you pass a component class to extendComponentWithMUITheme
// and it will return a new component class capable of rendering material-ui
// components
// const MyExtendedComponent = extendComponentWithMUITheme(MyComponent)
View create_view_facts.rb
class CreateViewFacts < ActiveRecord::Migration
def up
create_view :facts, "
SELECT c.id, c.created_at, c.name, c.description_html, c.link, c.mobilization_id, 'campaigns' as relname FROM campaigns c
UNION ALL
SELECT p.id, p.created_at, p.name, p.description as description_html, p.link, p.mobilization_id, 'problems' as relname FROM problems p;"
end
def down
drop_view :facts
@nicolasiensen
nicolasiensen / gist:6196787
Created Aug 9, 2013
Distance between two geospatial points in MySql
View gist:6196787
SET @orig_lat = "50";
SET @orig_lng = "5";
SET @dest_lat = "45";
SET @dest_lng = "30";
SELECT 3956 * 2 * ASIN(SQRT( POWER(SIN((@orig_lat - @dest_lat) * pi()/180 / 2), 2) + COS(@orig_lat * pi()/180) * COS(@dest_lat * pi()/180) * POWER(SIN((@orig_lng - @dest_lng) * pi()/180 / 2), 2) ));
@nicolasiensen
nicolasiensen / .bash_profile
Last active Dec 16, 2015
My .bash_profile
View .bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}
export PATH="/usr/local/bin:$PATH"
export PS1="\[\e[1;29;42m\]\w\$(parse_git_branch_and_add_brackets)\[\e[m\] "
export CLICOLOR=1
View .vimrc
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'wincent/Command-T.git'
Bundle 'bbommarito/vim-slim.git'
Bundle 'digitaltoad/vim-jade.git'
Bundle 'pangloss/vim-javascript.git'
Bundle 'vim-ruby/vim-ruby.git'
Bundle 'https://github.com/tpope/vim-fugitive.git'
@nicolasiensen
nicolasiensen / game.rb
Last active Dec 14, 2015
Ordering games by achievements completeness
View game.rb
# by @diogob
def self.by_completeness user
user.games.order("
CASE WHEN (SELECT count(*) FROM achievements a WHERE a.game_id = games.id) = 0 THEN 0 ELSE
(SELECT count(DISTINCT a.id)
FROM
achievements_users au
JOIN achievements a ON a.id = au.achievement_id
WHERE a.game_id = games.id AND au.user_id = #{user.id})::numeric /
(SELECT count(*)
View index.html
<html>
<head>
<title>ao vivo </title>
<!--JS JW6-->
<script type="text/javascript" src="http://a123.g.akamai.net/f/123/214238/1d/214258g.download.akamai.com/214238/_player/jwplayer6/6_9/jwplayer.js" ></script>
<script type="text/javascript">jwplayer.key = "ZfKOArQz+u1vxoCkwM9cihPjTUoVodJwgUCFZRpZLis=";</script>
</head>
<body>
<div id="dPlayer">
<div class="dTitulo_video"></div>