Skip to content

Instantly share code, notes, and snippets.

View OlivierJM's full-sized avatar

ojm OlivierJM

View GitHub Profile
@OlivierJM
OlivierJM / nil_empty_blank_present_ffdierence_in_ruby
Created December 2, 2020 09:16 — forked from pythonicrubyist/nil_empty_blank_present_ffdierence_in_ruby
Difference between nil?, empty?, blank? and present? in Ruby and Ruby on Rasils.
# nil? can be used on any Ruby object. It returns true only if the object is nil.
nil.nil? # => true
[].nil? # => false
{}.nil? # => false
"".nil? # => false
" ".nil? # => false
true.nil? # => false
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero.
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass
@OlivierJM
OlivierJM / directUploading.ts
Created October 13, 2020 12:31 — forked from saionaro/directUploading.ts
A direct file uploading, react native edition
//...
// some interfaces imports skipped
//...
const createDirectUploadMutation = `
mutation createDirectUploadMutation(
$filename: String!
$byteSize: Int!
$contentType: String!
) {
function generateColor() {
return (
"#" +
Math.random()
.toString(16)
.substr(-6)
)
}
CraigMaslowski.erb
dbaeumer.vscode-eslint
esbenp.prettier-vscode
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
rebornix.ruby
vscode-icons-team.vscode-icons
wingrunr21.vscode-ruby
CraigMaslowski.erb
{
"cSpell.words": [
"dateutil", "refetch"
],
"editor.formatOnPaste": true,
// "editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.fontFamily": "'Fira Code iScript', 'Fira Code', Consolas, 'Courier New', monospace",
"editor.fontLigatures": true,
"editor.tokenColorCustomizations": {
# frozen_string_literal: true
module Mutations
module Message
# Updating message for the user
class MessageUpdate < BaseMutation
argument :id, ID, required: true
field :message, Types::MessageType, null: true
@OlivierJM
OlivierJM / System Design.md
Created July 8, 2019 10:34 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@OlivierJM
OlivierJM / auth-server.js
Last active May 27, 2019 16:58
demo on how to perform basic authentication and authorization in graphql
const { ApolloServer, gql } = require("apollo-server");
const jwt = require("jsonwebtoken");
const mongoose = require("mongoose");
const bcrypt = require("bcrypt");
const pick = require("lodash").pick;
// configure the user collection
const userSchema = mongoose.Schema({
email: String,
password: String
const SECRET="createaverystrongsecretthatalsoincludes2423412wdsa324e34e"
const server = new ApolloServer({
schema,
context: ({ req }) => {
const { user } = req
// the user and secret we are passing here is what we access in every resolver
return {
user,
SECRET,