Skip to content

Instantly share code, notes, and snippets.

@evaldasg
evaldasg / web-fonts-asset-pipeline.md
Created August 28, 2017 11:50 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@evaldasg
evaldasg / install.sh
Created August 7, 2017 11:56 — forked from ziadoz/install.sh
Install Chrome, ChromeDriver and Selenium on Ubuntu 16.04
#!/usr/bin/env bash
# https://developers.supportbee.com/blog/setting-up-cucumber-to-run-with-Chrome-on-Linux/
# https://gist.github.com/curtismcmullan/7be1a8c1c841a9d8db2c
# http://stackoverflow.com/questions/10792403/how-do-i-get-chrome-working-with-selenium-using-php-webdriver
# http://stackoverflow.com/questions/26133486/how-to-specify-binary-path-for-remote-chromedriver-in-codeception
# http://stackoverflow.com/questions/40262682/how-to-run-selenium-3-x-with-chrome-driver-through-terminal
# http://askubuntu.com/questions/760085/how-do-you-install-google-chrome-on-ubuntu-16-04
# Versions
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
git clone https://github.com/vim/vim.git
sudo apt-get install libncurses-dev
e ~/Downloads/vim/src % ./configure --prefix=/usr/local \ ✭ master ‹2.4.1›
--enable-gui=auto --without-x --disable-nls --enable-multibyte --with-tlib=ncurses --enable-pythoninterp --enable-rubyinterp --with-ruby-command=$(which ruby) --with-features=huge
make
sudo make install
@evaldasg
evaldasg / gist:f1f3c488f1b80ca233fb62a75ab3700e
Created May 18, 2017 06:54 — forked from alex-zige/gist:5795358
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@evaldasg
evaldasg / to_gif.sh
Created April 19, 2017 12:04
create gif from mp4 screen record
ffmpeg -i screen01.mp4 -r 15 output.gif
@evaldasg
evaldasg / cuce.txt
Last active October 12, 2016 05:14
getting cucumber to work on macOS
install https://www.xquartz.org/index.html
brew install chromedrive
gem install cucumber
bundle exec rails s thin -d -p 3333 -P /tmp/main.pid -e cucumber
bundle exec cucumber features/
@evaldasg
evaldasg / rails http status codes
Created September 5, 2016 08:50 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@evaldasg
evaldasg / on-jsx.markdown
Created August 29, 2016 06:17 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'

@evaldasg
evaldasg / app-short.js
Created August 24, 2016 07:21 — forked from jshirley/app-short.js
Code for my loading strategy, documented at http://tech.tdp.me/2012/08/28/better-spa/
var YUI = require('yui').YUI,
Y = YUI(/* Your YUI Config */),
requireAuth = require('./lib/middlware/auth'),
modelLoader = require('./lib/middlware/loader'),
app = /* create express app */;
Y.namespace('TDP').config = {
webservices : global.config.webservices.path
};

source: https://gist.github.com/gaearon/ffd88b0e4f00b22c3159

The “purer” version is O(n2) where the original version is O(n), so it’s not the same as using for loops vs Array#reduce. Here’s a benchmark:

function mapValues1(obj, fn) {
  return Object.keys(obj).reduce((result, key) => {
    result[key] = fn(obj[key], key);
    return result;
 }, {});