Skip to content

Instantly share code, notes, and snippets.

View jobrac's full-sized avatar
🏠
Working from home

Jobel Racines jobrac

🏠
Working from home
View GitHub Profile
@jobrac
jobrac / read_csv.php
Created May 19, 2020 15:02 — forked from selwynpolit/read_csv.php
Php code to read a csv file of any size without exhausting memory and let you process it in chunks
/*
Reads a CSV file in chunks of 10 lines at a time
and returns them in an array of objects for processing.
Assumes the first line of the CSV file has headings
that will be used as the object name for the item you are
processing. i.e. the heading is CurrentURL then refer to
$item->CurrentURL
@jobrac
jobrac / abstract-unique-validator.ts
Created June 4, 2020 03:41 — forked from zarv1k/abstract-unique-validator.ts
Unique Validator Example for NestJS
import { ValidationArguments, ValidatorConstraintInterface } from 'class-validator';
import { Connection, EntitySchema, FindConditions, ObjectType } from 'typeorm';
interface UniqueValidationArguments<E> extends ValidationArguments {
constraints: [
ObjectType<E> | EntitySchema<E> | string,
((validationArguments: ValidationArguments) => FindConditions<E>) | keyof E,
];
}
@jobrac
jobrac / data.ts
Created June 12, 2020 09:12 — forked from prateekkathal/data.ts
Seeding Databases Using NestJS
export const languages: ILanguage[] = [
{ name: 'English' },
{ name: 'French' },
{ name: 'Spanish' },
{ name: 'Russian' },
// ... and others ...
];
@jobrac
jobrac / Select.js
Created July 6, 2020 05:01 — forked from c-moss-talk/Select.js
how to create a material-ui placeholder for react-select
import React from 'react';
import styled from '@emotion/styled';
import Select from 'react-select';
import colors from './someCustomColorScheme'
import Text from '../Text'; // We use react-primitives
import View from '../View'; // We use react-primitives
const PlaceholderText = styled(Text)(({ placeholderUp }) => ({
position: 'absolute',
transition: 'all .25s',
@jobrac
jobrac / init.vim
Created August 10, 2020 00:58 — forked from benawad/init.vim
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
@jobrac
jobrac / 1.mongodb-aws-setup-guide.md
Created October 12, 2020 12:18 — forked from calvinh8/1.mongodb-aws-setup-guide.md
MongoDB Setup Guide for AWS EC2 Instances with Auth Enabled

MongoDB AWS EC2 Setup Guide

You can see my latest update in my blog here https://medium.com/@calvin.hsieh/steps-to-install-mongodb-on-aws-ec2-instance-62db66981218

Credits:

Big thanks to Elad Nava and Shane Rainville for writing the above articles that allow me to conduct this guide. If by all means that I violated original post's copyright, please contact me.

@jobrac
jobrac / cloudflareworker-verifyjwt.js
Created October 15, 2020 03:58 — forked from bcnzer/cloudflareworker-verifyjwt.js
Sample Cloudflare worker that gets the JWT, ensures it hasn't expired, decrypts it and returns a result
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
// Following code is a modified version of that found at https://blog.cloudflare.com/dronedeploy-and-cloudflare-workers/
/**
* Fetch and log a request
* @param {Request} request
*/
@jobrac
jobrac / tunnel
Created November 2, 2020 08:29
Tunnel Google Cloud Shell for VSCode
#!/bin/bash
PORT=8090
if lsof -ti:${PORT} >> /dev/null ; then
echo "PORT ${PORT} is in use";
else
gcloud cloud-shell ssh --ssh-flag="-N" --ssh-flag="-f" --ssh-flag="-L ${PORT}:localhost:22" --authorize-session
echo "cloud-shell successfully forwarded to port ${PORT}"
fi
@jobrac
jobrac / aws-cdk-s3-notification-from-existing-bucket.ts
Created June 17, 2021 12:44 — forked from archisgore/aws-cdk-s3-notification-from-existing-bucket.ts
AWS CDK add notification from existing S3 bucket to SQS queue
import * as cr from '@aws-cdk/custom-resources';
import * as logs from '@aws-cdk/aws-logs';
import * as s3 from '@aws-cdk/aws-s3';
import * as sqs from '@aws-cdk/aws-sqs';
import * as iam from '@aws-cdk/aws-iam';
import {Construct} from '@aws-cdk/core';
// You can drop this construct anywhere, and in your stack, invoke it like this:
// const s3ToSQSNotification = new S3NotificationToSQSCustomResource(this, 's3ToSQSNotification', existingBucket, queue);
@jobrac
jobrac / pre-signup.ts
Created July 12, 2021 07:07 — forked from onhate/pre-signup.ts
Merge AWS Cognito External Provider User with Cognito User on Pre SignUp
import { PreSignUpTriggerEvent, PreSignUpTriggerHandler } from 'aws-lambda';
import { CognitoIdentityServiceProvider } from 'aws-sdk';
const providerName = {
google: 'Google',
facebook: 'Facebook'
};
const tryMergeUserAccounts = async (event: PreSignUpTriggerEvent) => {
const { userPoolId, userName } = event;