Skip to content

Instantly share code, notes, and snippets.

View rogeliog's full-sized avatar

Rogelio Guzman rogeliog

  • Netflix
  • San Francisco
View GitHub Profile

Keybase proof

I hereby claim:

  • I am rogeliog on github.
  • I am rogeliog (https://keybase.io/rogeliog) on keybase.
  • I have a public key ASCWRv3hVVvUM79InDyDTvCsmzYtbeMVuoyy2C5cSTG8FQo

To claim this, I am signing this object:

@rogeliog
rogeliog / regex.test.js
Created December 7, 2016 18:36
files not having a JS extension + files with no extension at all
const r = new RegExp('^(?!.*\.js$).*$');
it('Does not matches .js files', () => {
expect(r.test('dir/myFile.js')).toBeFalsy();
expect(r.test('dir.ext/myFile.js')).toBeFalsy();
expect(r.test('myFile.js')).toBeFalsy();
})
it('Matchs other extensions', () => {
expect(r.test('dir.something/myFile.other')).toBeTruthy();
@rogeliog
rogeliog / App.js
Created December 6, 2016 19:15
Composition and filters in React
/*
This is a minimal working example
*/
import React, { Component } from 'react';
import Filters from './Filters';
import InputFilter from './InputFilter';
import allMovies from './movies';
class App extends Component {
configure: creating cache auto/config.cache
checking whether make sets $(MAKE)... yes
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
$(function () {
//Color Stat UI component
var ColorStat = flight.component(function () {
this.updateColorStat = function (event, data) {
var count = parseInt(this.$node.text(), 10);
if (this.$node.data('color') == data.color) {
this.$node.text(count + 4);
} else {
@rogeliog
rogeliog / layout.html.erb
Created April 11, 2013 20:11
Public setup
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "Awesomeness" %></title>
<%= csrf_meta_tags %>
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
@rogeliog
rogeliog / user.rb
Created April 11, 2013 16:43
Gravatar
application_helper.rb
def avatar_url(user)
if user.avatar_url.present?
user.avatar_url
else
default_url = "#{root_url}images/guest.png"
gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
"http://gravatar.com/avatar/#{gravatar_id}.png?s=48&d=#{CGI.escape(default_url)}"
end
end
@rogeliog
rogeliog / replace_exception.rb
Created April 3, 2013 19:59
Replaces any given exception that happens inside a block with a new one. @garybernhardt "if this call raises exception Foo, I want you to raise exception Bar".
def replace_exception original_exception, new_exception
begin
yield
rescue original_exception
raise new_exception
end
end
class OtherException < Exception; end