Skip to content

Instantly share code, notes, and snippets.

View jeswinsimon's full-sized avatar

Jeswin Simon jeswinsimon

View GitHub Profile
@jeswinsimon
jeswinsimon / schema.graphql.js
Created September 20, 2020 16:06
Strapi delete uploaded media files using GraphQL
/**
* GraphQL resolver for deleting uploaded media in Strapi
* extensions/upload/config/schema.graphql.js
*/
module.exports = {
resolver: {
Mutation: {
deleteFile: {
description: 'Delete one file',
resolverOf: 'plugins::upload.upload.destroy',
@jeswinsimon
jeswinsimon / drop-all-collections.js
Created August 22, 2020 02:03
Drop all collections in a MongoDB Database
var dbName = 'DatabaseName';
db.getSiblingDB(dbName).getCollectionNames().forEach(function(collName) {
if (!collName.startsWith("system.")) {
db[collName].drop();
print('Dropped Collection: ' + collName);
}
})
@jeswinsimon
jeswinsimon / post-receive
Created June 17, 2020 11:07
post-receive Git hook for building and serving React application
#!/bin/bash
TARGET="<target-location>"
DEPLOY="<deployment-location>"
GIT_DIR="<repo-location>"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ];
@jeswinsimon
jeswinsimon / post-receive
Last active June 16, 2020 07:16
post-receive hook for deploying a Node PM2 app to server
#!/bin/bash
TARGET="<deployment-location>"
GIT_DIR="<repo-location>"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ];
then
@jeswinsimon
jeswinsimon / HoistingController.swift
Created April 29, 2020 05:30
Customizing Status Bar Style in SwiftUI
import SwiftUI
class HostingController<ContentView: View>: UIHostingController<ContentView> {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent // Set preferred status bar style here
}
}
@jeswinsimon
jeswinsimon / sha256.sh
Created May 28, 2019 03:42
Find the smallest integer where the SHA256 hash of 'catch-me-if-you-can'+integer will start with 9 zeroes.
#!/bin/bash
counter=1
key=catch-me-if-you-can
value=0
while [[ $value != 000000000* ]]
do
value=$(echo -n $key+$counter | shasum -a 256)
echo $counter