Skip to content

Instantly share code, notes, and snippets.

View EfeAgare's full-sized avatar
🎯
Focusing

Efe Agare EfeAgare

🎯
Focusing
View GitHub Profile
@EfeAgare
EfeAgare / Ruby Lambdas.md
Created January 19, 2021 12:49 — forked from mikekibz59/Ruby Lambdas.md
Ruby lambdas

Lambda: standard

# Creating a lambda
l = lambda { |name| "Hi #{name}!" }

# Executing the lambda
l.call("foo") # => Hi foo!

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@EfeAgare
EfeAgare / .babelrc
Created April 14, 2021 00:23 — forked from andrewmunro/.babelrc
Sequelize cli with ES6
{
"presets": ["es2015"],
"plugins": [
"add-module-exports"
],
}
def split_string(str)
result = []
str = str + "_" if str.length.odd?
len = str.length / 2
for i in 0..len-1
arry = str[2*i, 2]
result << arry
end
result.to_a
end
@EfeAgare
EfeAgare / .js
Created July 1, 2021 18:27 — forked from jmn/.js
React Native Apollo FlatList infinite scroll
import React from 'react';
import { Text, View, SafeAreaView, FlatList, WebView, Dimensions, Button, ScrollView} from 'react-native';
import { ListItem } from 'react-native-elements';
import ApolloClient from "apollo-boost";
import gql from "graphql-tag";
import { ApolloProvider } from "react-apollo";
import { Query } from "react-apollo";
import HTML from 'react-native-render-html';
import { createAppContainer, createStackNavigator} from 'react-navigation';
@EfeAgare
EfeAgare / array.rb
Created August 12, 2021 14:07
splice in ruby
class Array
def splice(start, len, *replace)
self[start, len] = replace
self
end
end
ruby-1.8.7-p352 :008 > initial_array = [:a, :c, :h, :g, :t, :m]
=> [:a, :c, :h, :g, :t, :m]
ruby-1.8.7-p352 :009 > initial_array.splice(2, 2, :test)
@EfeAgare
EfeAgare / install-docker.md
Created September 6, 2021 13:48 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@EfeAgare
EfeAgare / Capfile
Created October 20, 2021 22:45 — forked from hey-audiopin/Capfile
Using Capistrano 3, capistrano-rbenv, and capistrano-rbenv-build together with Rails 5
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
@EfeAgare
EfeAgare / create_document.rb
Created November 3, 2021 20:19 — forked from sulmanweb/create_document.rb
ActiveStorage file uploading in GraphQL API in Rails
# app/graphql/types/objects/document_type.rb
module Mutations
class CreateDocument < BaseMutation
description "creates a document for the user in the system"
argument :doc, ApolloUploadServer::Upload, required: true
field :document, Types::Objects::DocumentType, null: false
@EfeAgare
EfeAgare / Deploy APP to EC2 Ubuntu
Last active December 30, 2022 12:47 — forked from ThomasBush/youtube-video-commands
Ubuntu 20.04 Focal Fossa Rails server setup
# Generate Random Passwords
curl 'https://www.random.org/passwords/?num=2&len=24&format=plain&rnd=new'
# Create deploy user
sudo adduser deploy
sudo adduser deploy sudo
su deploy
cd ../deploy/
mkdir .ssh
touch .ssh/authorized_keys