Skip to content

Instantly share code, notes, and snippets.

View iamnasirudeen's full-sized avatar
🎯
Busy

Nasirudeen Olohundare iamnasirudeen

🎯
Busy
View GitHub Profile
@fullstackjedi
fullstackjedi / countries.json
Created July 15, 2021 09:37
JSON of country codes, dial codes and their flags
[
{
"name":"Afghanistan",
"flag":"🇦🇫",
"code":"AF",
"dial_code":"+93"
},
{
"name":"Åland Islands",
"flag":"🇦🇽",
@cassidoo
cassidoo / copilot-suggestions.js
Last active December 11, 2021 19:05
A gist of all of the functions that Copilot wrote for me
/**
As seen on twitch.tv/cassidoo
*/
// A function that validates an email address
function validateEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function flattenFolderTree(folders) {
return folders.reduce((acc, folder) => {
const {children, ...rest} = folder;
if (!children || !children.length) {
return [...acc, rest];
}
return [...acc, rest, ...flattenFolderTree(children)];
}, []);
import AWS from "aws-sdk";
import { v2 as cloudinary } from "cloudinary";
import crypto from "crypto";
import fs from "fs";
import Jimp from "jimp";
import path from "path";
import gifsicle from "gifsicle";
import { execFile } from "child_process";
import sizeOf from "image-size";
import Settings from "../models/settings";
@limistah
limistah / nextTick.js
Created May 1, 2020 08:05 — forked from mmalecki/nextTick.js
process.nextTick vs setTimeout(fn, 0)
for (var i = 0; i < 1024 * 1024; i++) {
process.nextTick(function () { Math.sqrt(i) } )
}
@limistah
limistah / App.js
Last active September 5, 2021 16:39
ReactJS InplaceEdit component and consumption
import InplaceEdit from "./InplaceEdit"
class App extends React.Component {
render() {
return (
<InplaceEdit
isUpdatingId={true || false}
id={idForTheField || ""}
updateKey={keyToReturnAnObjectWith || ""}
onUpdate={functionToCallForTheUpdate || (() => {})}
@kosson
kosson / redincredid.ctrl.js
Created October 21, 2019 08:25
This is how content data generated by Editor.js could be transformed back into html.
const resursaModel = require('../../models/resursa-red');
const competenteS = require('../../models/competenta-specifica');
module.exports = (params) => {
return resursaModel.find({_id: params.idres}).populate({
path: 'competenteS'
}).exec().then( (resursa) => {
// console.log(resursa);
if (resursa[0].content) {
let articleHTML = '';
resursa[0].content.blocks.map(obj => {
@iamnasirudeen
iamnasirudeen / paystack.js
Created July 10, 2019 16:04
Paystack recurring payment
import axios from 'axios';
const createCustomer = async form => {
const options = {
url: "https://api.paystack.co/customer",
headers: {
'authorization': `Bearer ${process.env.PAYSTACK_SECRET_KEY}`,
'content-type': 'application/json',
'cache-control': 'no-cache'
},
@whoisryosuke
whoisryosuke / nextjs-hoc-authorization.js
Created June 26, 2018 22:24
ReactJS - NextJS - A HOC for wrapping NextJS pages in an authentication check. Checks for getInitialProps on the child component and runs it, so you still get SSR from the page. Also includes a user agent for Material UI.
import React, {Component} from 'react'
import Router from 'next/router'
import AuthService from './AuthService'
export default function withAuth(AuthComponent) {
const Auth = new AuthService('http://localhost')
return class Authenticated extends Component {
static async getInitialProps(ctx) {
// Ensures material-ui renders the correct css prefixes server-side

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8