Skip to content

Instantly share code, notes, and snippets.

View imranariffin's full-sized avatar
🎯
Focusing

Imran Ariffin imranariffin

🎯
Focusing
View GitHub Profile
@imranariffin
imranariffin / django_data_migration_test_example.py
Last active November 16, 2020 02:41
Django Data Migration Test Example
# -----------------------------------------------------------
# data_migration_test_base.py
# -----------------------------------------------------------
from importlib import import_module
from django.test import TestCase
class DataFixTestCaseBase(TestCase):
@imranariffin
imranariffin / navigations.index.js
Last active August 7, 2021 08:51
React Native Private/Public Screen Pattern - Wrap the `@react-navigation/stack` to be auth aware (Note: replace `.` in file names with `/` to make more sense)
import AScreen from 'screens/A'
import BScreen from 'screens/B'
import MainScreen from 'screens/Main'
import SignInScreen from 'screens/SignIn'
import SignUpScreen from 'screens/SignUp'
import SomeNestedScreen from 'screens/SomeNested'
import StackNavigator from './stack-navigator'
const Navigations = () => {
@imranariffin
imranariffin / Solution.py
Created December 14, 2019 15:08
Leetcode 206 - Reverse Linked List
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class SolutionIterative:
def reverseList(self, head: ListNode) -> ListNode:
prev, node, next = None, head, None
@imranariffin
imranariffin / navigation-middleware.js
Last active May 31, 2019 06:29
React Native Navigation Redux Middleware Pattern
import { ToastAndroid } from 'react-native'
import { NavigationActions } from 'react-navigation'
import actions from './actions'
import routes from './routes'
let navigator
export default store => next => action => {
const actionType = action.type
const nextAction = next(action)
@imranariffin
imranariffin / apiMiddleware.js
Last active January 9, 2019 00:24
Redux middlewares: logger, api & persistence-storage
export default (client) => ({ dispatch }) => (next) => async (action) => {
if (!action.types ||
action.types.length !== 3 ||
!action.method ||
!action.data
) {
return next(action)
}
const {
@imranariffin
imranariffin / bar\deeply\nested\index.js
Last active January 5, 2019 04:17
Nodejs/Javascript Better import paths aka no more `import from '../../../'`
export default () => 'bar'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.scroll-wrapper {
/* -webkit-overflow-scrolling: touch; */
/* overflow-y: scroll; */