Skip to content

Instantly share code, notes, and snippets.

View ydaniju's full-sized avatar
🎉
Moving things to make them whole.

Yusuf Daniju ydaniju

🎉
Moving things to make them whole.
View GitHub Profile
RSpec::Matchers.define :validate_with do |expected_validator|
match do |subject|
@validator = current_validator(subject, expected_validator)
if @validator.options.present?
@validator.options.all? do |_, condition|
subject.instance_eval(&condition)
end
end
end
# frozen_string_literal: true
require "httparty"
class FirebaseMessaging
include HTTParty
default_timeout 30
format :json
base_uri "https://fcm.googleapis.com/fcm"
@ydaniju
ydaniju / deflate.rb
Last active January 1, 2018 17:10
Another implementation for Array.flatten
def deflate(arr, container = [])
arr.each do |a|
push(a, container)
end
container
end
def push(a, container)
if a.is_a? Integer
@ydaniju
ydaniju / gist:fbc251332eaba94cfa130bd39c579ec4
Created December 20, 2016 21:36 — forked from jedi4ever/gist:7677d62f1414c28a1a8c
Some notes on travisci remote debugging via ssh or screenshot or remote desktop of Mac VM builds
Some notes on remote debugging mac builds on Travisci. It's hard to tell when something hangs what the cause it. Trial and error via commits is tedious. And on Mac , sometimes it's the gui asking for input. So I worked my around to get the access I needed for faster debugging a build.
#################################################
# Enable remote ssh access to travisci build for debugging
#################################################
# Add a key so we can login to travisci vm
- cat ssh/travisci.pub >> ~/.ssh/authorized_keys
- chmod 600 ssh/travisci
# Install netcat
@ydaniju
ydaniju / authentication_with_bcrypt_in_rails_4.md
Created December 7, 2016 06:32 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@ydaniju
ydaniju / gist:eb448ed89169dfb65ce0d0946d0a9e65
Created August 13, 2016 22:57 — forked from tylerchesley/gist:6198074
Function to recursively copy files from an Android asset directory
public void copyFileOrDir(String path) {
AssetManager assetManager = this.getAssets();
String assets[] = null;
try {
assets = assetManager.list(path);
if (assets.length == 0) {
copyFile(path);
} else {
String fullPath = "/data/data/" + this.getPackageName() + "/" + path;
File dir = new File(fullPath);
brew cask install skype
brew cask install MacDown
brew cask install screenhero
brew cask install virtualbox
brew cask install font-inconsolata
brew cask install font-Consolas
brew cask install font-source-code-pro
brew cask install swiggle
brew cask install vlc
brew cask install geektool
@ydaniju
ydaniju / rspec_model_testing_template.rb
Created March 8, 2016 05:19 — 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: