Skip to content

Instantly share code, notes, and snippets.

View SylarRuby's full-sized avatar

Daveyon Mayne SylarRuby

  • UK
View GitHub Profile
@SylarRuby
SylarRuby / _custom_application.html.erb
Last active August 5, 2016 18:51
Custom Faq page for Spree Store
<%# app/views/custom/_custom_application.html.erb %>
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie ie6" lang="<%= I18n.locale %>"> <![endif]-->
<!--[if IE 7 ]> <html class="ie ie7" lang="<%= I18n.locale %>"> <![endif]-->
<!--[if IE 8 ]> <html class="ie ie8" lang="<%= I18n.locale %>"> <![endif]-->
<!--[if IE 9 ]> <html class="ie ie9" lang="<%= I18n.locale %>"> <![endif]-->
<!--[if gt IE 9]><!--><html lang="<%= I18n.locale %>"><!--<![endif]-->
<html>
<head data-hook="inside_head">
@SylarRuby
SylarRuby / AppDelegate.swift
Created January 12, 2017 08:00
Redirects user to loginVC if not currently logged in
/**
* If any issues, be sure to import Firebase or FirebaseAuth and check your Podfile
*
*/
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let root = UIApplication.shared.keyWindow?.rootViewController
let lc: LoginVC = storyboard.instantiateViewController(withIdentifier: "loginVC") as! LoginVC
@SylarRuby
SylarRuby / LoginVC.swift
Created January 12, 2017 08:27
LoginVC with a passed params as string
import UIKit
import Firebase
import SwiftKeychainWrapper // I use this
class LoginVC: UIViewController, UITextFieldDelegate {
// Where our shortcutItem.type is stored
var params: String! = ""
// Your @IBAction button function
@SylarRuby
SylarRuby / .rb
Created March 13, 2017 06:52
Catch error for Facebook Messenger
class NotificationWorker
include Sidekiq::Worker
include Facebook::Messenger
def perform
token = ENV["ACCESS_TOKEN"]
sender_id = '12345'
text = # "Your reminder to brush your teeth is in 5 mins"
standard_text(sender_id, text, token)
end
@SylarRuby
SylarRuby / railsapi_response_header.rb
Created May 23, 2017 07:58
railsapi_response_header.rb
#<ActionDispatch::Http::Headers:0x007fb2ee2e01c8 @req=#<ActionDispatch::Request:0x007fb2ee353600 @env={"rack.version"=>[1, 3], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 3.8.2 Sassy Salamander", "GATEWAY_INTERFACE"=>"CGI/1.2", "REQUEST_METHOD"=>"GET", "REQUEST_PATH"=>"/fake", "REQUEST_URI"=>"/fake", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_ACCEPT"=>"application/json, text/plain, */*", "HTTP_USER_AGENT"=>"axios/0.16.1", "HTTP_HOST"=>"localhost:3001", "HTTP_CONNECTION"=>"close", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3001", "PATH_INFO"=>"/fake", "REMOTE_ADDR"=>"127.0.0.1", "puma.socket"=>#<TCPSocket:fd 22>, "rack.hijack?"=>true, "rack.hijack"=>#<Puma::Client:0x3fd9769617cc @ready=true>, "rack.input"=>#<Puma::NullIO:0x007fb2ee332ab8>, "rack.url_scheme"=>"http", "rack.after_reply"=>[], "puma.config"=>#<Puma::Configuration:0x007fb2eeba88c8 @options=#<Puma::U
@SylarRuby
SylarRuby / .rb
Last active August 8, 2017 19:03
Spree Checkout Controller
Spree::CheckoutController.class_eval do
before_filter :get_xero
# https://github.com/spree/spree/blob/master/frontend/app/controllers/spree/checkout_controller.rb
# Updates the order and advances to the next state (when possible.)
# Modified to use Xeroizer
def update
if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)
@order.temporary_address = !params[:save_user_address]
unless @order.next
@SylarRuby
SylarRuby / dem.html
Created September 4, 2017 13:33
BEM HTML Demo
<nav class="navbar">
<div class="navbar__container">
<div class="navbar__container__logo">
<a class="navbar__container__logo--svg" href="#">Logo</a>
</div>
<div class="navbar__container__links">
<a class="navbar__container__links--home" href="#">Home</a>
<a class="navbar__container__links--about" href="#">About</a>
<a class="navbar__container__links--terms" href="#">Terms</a>
</div>
@SylarRuby
SylarRuby / bem.scss
Last active September 4, 2017 21:30
BEM SASS Demo
/*
* .navbar is the name of our component
*
*/
.navbar {
height: 90px;
// .navbar__container
&__container {
display: flex;
@SylarRuby
SylarRuby / application.yml
Created September 5, 2017 05:49
encrypt and decrypt in Rails 5
# Generated from your Rails Console
# salt = SecureRandom.random_bytes(64)
# key = ActiveSupport::KeyGenerator.new('password').generate_key(salt)
SALT: "\xF9\x9B:\xB6\x0F\xAE\xD9\t(\xA2\xB9\nC&\xF6|\xDC\b\b\xA3\x96\x83\xF4\xDE,\xE1\x86{\xFE\e\x16\x8B'\x1DR\v\x10\x11?v\xE4\xB1A\xEEG^X\x8B\xF3\xCE\x9AQ\xCDyJ\xEC\xF4\x01\xB1\xBD\x9CU\xE2\xAE"
KEY: "x\xFF=o\xF3\x90p\xA6)\x13p\x8B\x9A\xB7tU\xDF\xC2\xDF2=s\xA4[\x80\xCA\xBF\x1A|\x0E\xEEq\xE0\xFC\xBDq\x85i\xC5\xE1 \xE5\xE5+Nm;\xAA\x99\xFF9\x13\xBFdh\x97\xBC\x942\xBF\x10\xF3\xAC\xAE"