Skip to content

Instantly share code, notes, and snippets.

View kasunvimarshana's full-sized avatar

kasun vimarshana kasunvimarshana

View GitHub Profile
@kasunvimarshana
kasunvimarshana / App.js
Created May 23, 2023 05:52 — forked from darryl-davidson/App.js
Example Expo 35 App that registers Background Fetch and Location Updates
import React, { useEffect } from "react";
import { StyleSheet, Text, View } from "react-native";
import * as BackgroundFetch from "expo-background-fetch";
import * as TaskManager from "expo-task-manager";
import * as Permissions from "expo-permissions";
import * as Location from "expo-location";
import { Notifications } from "expo";
import { Button } from "react-native";
const LOCATION_FETCH_TASK = "upload-job-task-with-location";
@kasunvimarshana
kasunvimarshana / StringBladeRenderer.php
Created December 5, 2022 09:16 — forked from n1215/StringBladeRenderer.php
Compile string by Blade template engine.
<?php
declare(strict_types=1);
namespace App\View;
use Illuminate\View\Compilers\BladeCompiler;
use Illuminate\View\Factory;
use Symfony\Component\Debug\Exception\FatalThrowableError;
/**
@AlejandroYanes
AlejandroYanes / get-current-cart.ts
Last active June 16, 2023 11:25
A simpler action
import { CartModel } from 'models/cart';
import authApi from 'api/auth';
import cartsApi from 'api/carts';
import { addTimeStamp } from 'helpers/time-trace';
export default async function getCurrentCart(): Promise<CartModel> {
let currentSession = await authApi.getCurrentSession();
if (!currentSession) {
currentSession = await authApi.createAnonymousSession();
}
@AlejandroYanes
AlejandroYanes / add-to-cart.ts
Created October 10, 2022 10:18
An examplo of how to create an action for the state mangagement
import { NotificationType, showNotification } from '@devland-ui/components';
import { CartItemModel } from 'models/cart-item';
import { ProductModel } from 'models/product';
import cartsItemsApi from 'api/cart-items';
import { addTimeStamp } from 'helpers/time-trace';
import { CustomDispatch, State } from '../types';
import getCurrentCart from './get-current-cart';
export default function addToCart(
dispatch: CustomDispatch,
@elvinlari
elvinlari / docker-compose.yml
Last active July 31, 2023 09:10
Docker Compose yaml file
version: '3'
networks:
laravel:
services:
nginx:
build:
context: ./docker
dockerfile: nginx.dockerfile
@DarkGhostHunter
DarkGhostHunter / ExtendableScope.php
Last active March 17, 2023 09:29
An Eloquent Scope that extends the builder with private/protected methods.
<?php
namespace App\Scopes;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
use Illuminate\Support\Collection;
use ReflectionClass
use SplFixedArray;
{
"expo": {
// ...
"jsEngine": "hermes",
"ios": {
"jsEngine": "jsc"
}
// ...
}
}
{
"cli": {
"version": ">= 0.54.1"
},
"build": {
"base": {
"env": {}
},
"development": {
"extends": "base",
import { Suspense, lazy } from 'react';
import LoadingScreen from './components/LoadingScreen';
import type { RouteObject } from 'react-router';
const Loadable = (Component: any) => (props: JSX.IntrinsicAttributes) =>
(
<Suspense fallback={<LoadingScreen />}>
<Component {...props} />
</Suspense>
);
@savitapatel
savitapatel / Animation.js
Last active March 9, 2023 18:19
Animation using requestAnimationFrame
import React from 'react';
export function Animation() {
const animationByInterval = () => {
// Animation using setInterval
const start = Date.now();
const animatedText = document.querySelector('.myDiv');
const timer = setInterval(() => {
const interval = Date.now() - start;