Skip to content

Instantly share code, notes, and snippets.

View ospfranco's full-sized avatar

Oscar Franco ospfranco

View GitHub Profile
import { Module, MiddlewaresConsumer, NestModule, RequestMethod } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';
import { GraphQLModule, GraphQLFactory } from '@nestjs/graphql';
import { ApiModule } from './module';
import ormConfig from './ormconfig';
import { AuthModule } from './module/auth/auth.module';
import { AuthMiddleware } from './module/auth/auth.middleware';
@Module({
@ospfranco
ospfranco / ImageViewer.tsx
Last active December 19, 2019 08:32
Exif Image Rotation React Component
import * as React from 'react';
import * as Reactdom from 'react-dom';
import * as loadimage from 'blueimp-load-image';
class ImageViewer extends React.Component<any, any> {
private imageCanvas;
public componentDidMount() {
loadimage('IMAGE_URL', (img) => {
img.className = 'fit_to_parent'; // css class: { max-width: 100%; max-height: 100%; }
Reactdom.findDOMNode(this.imageCanvas).appendChild(img);
@ospfranco
ospfranco / haste_resolver.js
Last active March 18, 2019 08:45
Haste Resolver with @providesModule support for react-native 0.59
/**
* From Oscar:
*
* This entire file is copied from hasteImpl.js from within ReactNative's core repo. if you want a < 0.58 version, ask for it
* I have it on some older project, this is working for 0.59.
* stuff you need to change (for 0.59 to work):
* 1) place this file in the root of your project
* 2) install the cli (it has been removed from react-native core package): yarn add @react-native-community/cli
* 3) on your root folder you should now have a metro.config.js file, add the following keys:
* resolver: {
@ospfranco
ospfranco / crashalytics_js_stack.js
Created July 27, 2020 14:31
Attach Javascript stack to Crashlytics
// If you are using crashlytics and you cannot update to the latest versions of react-native-firebase (or need sourcemaps which is doesn't support) adding middleware to the error handling can at least provide you with an error stack
//Define an error handler to upload thet stack to crashlytics
const defaultHandler = global.ErrorUtils.getGlobalHandler()
const crashlytics = firebase.crashlytics()
global.ErrorUtils.setGlobalHandler((...args) => {
const error = args[0] || 'Unknown'
//console.log('Crashlytics error sent', error);
if (error instanceof Error) {
@ospfranco
ospfranco / useInterval.js
Created July 30, 2020 06:29
ReactJS hook for setting interval
export function useInterval (callback: () => void, delay: number) {
const savedCallback = useRef()
// Remember the latest callback.
useEffect(() => {
savedCallback.current = callback
}, [callback])
// Set up the interval.
useEffect(() => {
@ospfranco
ospfranco / useEventListener.js
Created July 30, 2020 06:32
ReactJS hook for using an event listener
export function useEventListener(eventName: string, handler: () => void) {
let savedHandler = useRef<() => void>()
useEffect(() => {
savedHandler.current = handler
}, [handler])
useEffect(() => {
let eventListener = () => savedHandler.current?.()
[Your event emitter here].addListener(eventName, eventListener)
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Show WiFi Password
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 📶
# @raycast.packageName Show WiFi Password
#!/opt/homebrew/bin/zsh
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title BodyFast Workspaces
# @raycast.mode compact
# Optional parameters:
# @raycast.icon ♻️
const fs = require("fs");
const graph = {};
const file = fs.readFileSync("output2").toString();
file
.split("\n")
.map(l => l.trim())
.map(l => l.split(" -> "))
@ospfranco
ospfranco / WebImage.swift
Created January 16, 2022 12:44
React Native macOS Draggable SDWebImage
import Cocoa
import SDWebImage
class InternalWebImage: NSView, NSDraggingSource, NSPasteboardItemDataProvider {
let image = NSImageView()
@objc var url: NSString = "" {
didSet {
self.setupView()
}