Skip to content

Instantly share code, notes, and snippets.

View Sylvance's full-sized avatar
:octocat:
Shipping it 🚀

omusamurai Sylvance

:octocat:
Shipping it 🚀
  • Nairobi
View GitHub Profile
@Sylvance
Sylvance / base_type.rb
Created March 10, 2023 16:35
Base class type for entity classes in ruby
# frozen_string_literal: true
require "json"
require "nokogiri"
module Types
class BaseType
def to_hash
hash = {}
@Sylvance
Sylvance / grpc.js
Created January 10, 2023 14:18
Grpc web client
import React, { useEffect, useState } from 'react';
import { createClient } from 'grpc-web-client';
import { DataService } from './generated/data_pb_service';
const DataClient = createClient(DataService);
function DataFetching({ url }) {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
@Sylvance
Sylvance / gem_create.sh
Last active January 7, 2023 21:08
Bash script to create a ruby gem
#!/usr/bin/env bash
### Usage
# Ensure your shell has access to your github account and rubygems account.
# Install github cli. In mac do;
# ```sh
# brew install gh
@Sylvance
Sylvance / USAGE
Created May 20, 2021 12:23
MMVCR_Generator
Description:
Generator for Model, Migration, View, Controller and Relationships.
Example:
bin/rails generate peparizer some_model_in_plural [options]
--search_fields ':field1, :field2' # only two fields
This will create:
search service
controller
@Sylvance
Sylvance / README.md
Created January 31, 2020 18:46
Template to setup a rails app with authentication and users seed data

Setup

To set this up you will need to download this gist. Change into the directory this gist is in then;

  • rails new your_app_name --database=postgresql -m ./template.rb
@Sylvance
Sylvance / node_nginx_ssl.md
Created September 23, 2019 22:36 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to Digital Ocean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

module AlbumConcern
private
def set_album
@album = Album.find(params[:id])
end
def filter_albums(albums)
filter = params[:filter]
return albums unless filter
@Sylvance
Sylvance / ruby_install.md
Last active February 4, 2019 23:28
Install Rbenv, ruby-build, Ruby and Ruby on Rails on a codeanywhere Blank Ubuntu 14 container

Install gnupg2 and set keys

$ sudo apt-get install gnupg2 -y $ sudo gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Install RBENV

$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv $ cd ~/.rbenv/ $ sudo src/configure $ sudo ./configure $ sudo make

@Sylvance
Sylvance / calc.py
Last active December 5, 2018 23:15
code that takes in two numbers and adds, subtracts, multiplies and divides them and displays the result on the terminal
# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
# Add two numbers
summ = float(num1) + float(num2)
# Subtract two numbers
diff = float(num1) - float(num2)
from flask import Flask
from flask_restplus import Api, Resource, fields
from werkzeug.contrib.fixers import ProxyFix
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app)
api = Api(app, version='1.0', title='Todo API',
description='A simple Todo API',
)