Skip to content

Instantly share code, notes, and snippets.

View msuzoagu's full-sized avatar

MUA msuzoagu

  • Space
View GitHub Profile
@msuzoagu
msuzoagu / 1-server.md
Created July 25, 2017 22:01 — forked from dragonjet/1-server.md
Setup Web Server on EC2 Amazon Linux AMI

Step 1: Server Credentials

This assumes you are now connected to the server via SSH.

  • sudo -s Enter root mode for admin access
  • groupadd devgroup Create new group to be later granted access to /var/www/html

Creating a new Root User

  • useradd -G root,devgroup masterdev Create new root user. Also add to the devgroup
  • passwd masterdev Change password for the new root user
  • At this point, you'll need to input your new root user's new password
@msuzoagu
msuzoagu / flex_with_autoscroll.html
Created May 27, 2017 04:28 — forked from readingtype/flex_with_autoscroll.html
A CSS flexbox layout with a fixed header, a fixed footer, and an expanding centre section which scrolls if its content height is greater than its own height.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test fixed and scrolling divs in a flexbox layout</title>
<style media="screen">
* {
border: 0;
margin: 0;
padding: 0;
@msuzoagu
msuzoagu / generate_source_tracker.rb
Created April 22, 2017 19:07 — forked from jhjguxin/generate_source_tracker.rb
delegate demo, use helpers and url_helper outside controller or helpers ....
## rails runner script/generate_source_tracker_link.rb
#eg: version_number: 20130116-1-1 #data-1(早)/2(晚)-1(article_number)
class GeneraterSourceTracker
#include ActionView::Helpers
#include ActionView::Helpers::UrlHelper
include Rails.application.routes.url_helpers
delegate :url_helpers, to: 'Rails.application.routes'
delegate :helpers, to: 'ActionController::Base'
def tracker_url(source_tracker)
@msuzoagu
msuzoagu / rspec_model_testing_template.rb
Created February 6, 2017 17:33 — 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:
class PurchasePower
def self.base
500
end
def process_request(request)
raise NotImplementedError
end
private
@msuzoagu
msuzoagu / api_content_type.rb
Created December 29, 2016 02:44 — forked from tstachl/api_content_type.rb
This is a simple Rack Middleware to set the request content type for specific routes. It checks if a content type is set and does not override the existing one. The options allow you to specify the request methods, path (with a string or a regular expression) and the content type to be set.
module Rack
class ApiContentType
def initialize(app, methods = [:post, :patch], path = /^\/api\/v2+/, content_type = 'application/json')
@app = app
@methods = (methods.is_a?(Array) ? methods : [methods]).map{ |item| item.to_s.upcase }
@path = path
@content_type = content_type
end
def call(env)

Font Face

A mixin for writing @font-face rules in SCSS.

_maxin.scss Code Source

  @mixin font-face($style-name, $file, $family, $category:"") {
      $filepath: "fonts/" + $family + "/" + $file;
 @font-face {
@msuzoagu
msuzoagu / DefaultLayout.jsx
Created December 14, 2016 21:11
React.js (ReactJS) Page and Layout components. For a complete sample visit https://github.com/kriasoft/react-starter-kit and http://reactjs.kriasoft.com (demo)
/**
* Page layout, reused across multiple Page components
* @jsx React.DOM
*/
var React = require('react');
var ExecutionEnvironment = require('react/lib/ExecutionEnvironment');
var Navigation = require('../components/Navigation.jsx');
var DefaultLayout = React.createClass({
@msuzoagu
msuzoagu / delayed_tasks.markdown
Created December 7, 2016 22:41 — forked from romul/delayed_tasks.markdown
Running rake tasks in background
  1. Add gem 'delayed_job', '2.1.4' to your Gemfile

  2. Run bundle install

  3. Run rails g migration create_delayed_jobs

  4. Edit the created migration to contain:

     class CreateDelayedJobs < ActiveRecord::Migration
       def self.up
         create_table :delayed_jobs, :force => true do |table|
           table.integer  :priority, :default => 0      # jobs can jump to the front of
    

table.integer :attempts, :default => 0 # retries, but still fail eventually

@msuzoagu
msuzoagu / DependencyInjectionInRuby.md
Created October 30, 2016 16:14 — forked from blairanderson/DependencyInjectionInRuby.md
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache.

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?