Skip to content

Instantly share code, notes, and snippets.

View abhilashak's full-sized avatar
🎯
Focusing

Abhilash A K abhilashak

🎯
Focusing
View GitHub Profile
@abhilashak
abhilashak / rspec_model_testing_template.rb
Created August 29, 2016 09:11 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@abhilashak
abhilashak / media-queries.scss
Created July 17, 2017 12:39 — forked from chrisjlee/media-queries.scss
All Media Queries breakpoints
@media (min-width:320px) { /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */ }
@media (min-width:480px) { /* smartphones, Android phones, landscape iPhone */ }
@media (min-width:600px) { /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */ }
@media (min-width:801px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ }
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* hi-res laptops and desktops */ }
@abhilashak
abhilashak / Gemfile
Created August 16, 2017 05:19
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@abhilashak
abhilashak / rbenv-howto.md
Created August 16, 2017 06:21 — forked from MicahElliott/rbenv-howto.md
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

@abhilashak
abhilashak / gist:8f3f3da07588c472aee43b50bf46ab14
Created August 28, 2017 10:04 — forked from mattconnolly/gist:4158961
RSpec basic authentication helper module for request and controller specs
module AuthHelper
def http_login
user = 'username'
pw = 'password'
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw)
end
end
module AuthRequestHelper
#
@abhilashak
abhilashak / gist:3077e3e6d03713620c30eb5b9baef2df
Created April 14, 2018 05:55 — forked from tagrudev/gist:4276467
Add custom fonts to your rails application
##
Lets say we have YoloFont.otf
1. We add it to vendor/assets/fonts/ folder
2. Me personaly creates a file named fonts.css.scss in app/assets/stylesheets
In it I have
@font-face{
font-family: 'YoloFont';
@abhilashak
abhilashak / web-fonts-asset-pipeline.md
Created April 14, 2018 06:51 — 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.

@abhilashak
abhilashak / redux_setup.md
Created May 3, 2018 10:16 — forked from kiok46/redux_setup.md
Redux, store, actions and reducers setup along with explanation.

Redux Setup

Implementation of redux inside any react.js or react-native application,

  • we will create an instance of the redux store.
  • We are going to create a provider tag from react redux library
  • Then render that provider tag passing in the store as a prop, then any child component to this provider tag will have access to this store through the context system inside of react.
  • import { Provider } from ‘react-redux’; // In main.js
  • to create a store create one in a separate folder.
@abhilashak
abhilashak / gist:c39c23024ef7a882cddcd893cff15b0d
Created May 25, 2018 09:53 — forked from kindohm/gist:4643056
converts .wav files to base64 encoded text
//crude and incomplete but it works
var fs = require('fs');
var Buffer = require('buffer').Buffer;
var constants = require('constants');
var size = 0;
var encoded = '';
var fileName = '';
var wavFileName = '';
var base64FileName = '';