Skip to content

Instantly share code, notes, and snippets.

View capJavert's full-sized avatar
🤘
Kicking ass!

Ante Barić capJavert

🤘
Kicking ass!
View GitHub Profile
@capJavert
capJavert / swap.sh
Created July 17, 2018 11:41
Swap function for linux shell.
# https://stackoverflow.com/a/1115909
function swap()
{
local TMPFILE=tmp.$$
mv "$1" $TMPFILE && mv "$2" "$1" && mv $TMPFILE $2
}
@capJavert
capJavert / which-browser.js
Last active July 24, 2018 09:33
Detect browser type
var BrowserEnum = Object.freeze({
chrome: 'CHROME_BROWSER',
firefox: 'FIREFOX_BROWSER',
opera: 'OPERA_BROWSER',
safari: 'SAFARI_BROWSER',
ie: 'SHIT_BROWSER',
edge: 'EDGE_BROWSER'
});
var whichBrowser = function() {
@capJavert
capJavert / webpack.config.js
Last active July 25, 2018 11:25
Webpack config example (js, css, scss, min, assets)
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = env => {
isProduction = env.production || false
@capJavert
capJavert / orphan.sh
Created July 25, 2018 22:11
Orphan branch with no history or files.
git checkout --orphan <branch-name>
git reset
rm -rf *
# now you have no history and no files, like a true orphan ;)
/**
* API providing 2 way binding of JavaScript objects to browser LocalStorage
*
* @type {Object}
*/
/**
* Constructor for creating an object of LocalStorageObject type
*
* @param {object} target object or array defining object properties
@capJavert
capJavert / wallpaper-sticky-banner.js
Last active January 23, 2019 15:51
Wallpaper style banner sticky functionality. Respects header/footer margins.
/**
* Wallpaper style banner sticky functionality
* Respects header/footer margins
*
* [wallpaperStickyBanner banner element handle]
*/
var elementSelector = '#wallpaperStickyBanner'
var headerHeight = 140
var footerHeight = 315
@capJavert
capJavert / withRemoteConfig.js
Created April 2, 2019 20:16
HOC for injecting config props after firebase remote config async call is completed
import React from 'react'
import firebase from 'react-native-firebase'
const withRemoteConfig = (configValues = []) => Component => (
class EnhancedComponent extends React.Component {
state = {
config: {}
}
componentDidMount = async () => {
@capJavert
capJavert / useFetchWithCleanup.js
Created May 2, 2019 09:10
WIP: Uses signal option of fetch method to cleanup request handlers after component unmount
import { useEffect } from 'react'
const noop = () => {}
export default (
url,
options = {},
complete = noop,
error = noop,
final = noop
@capJavert
capJavert / dep-parser.js
Created July 19, 2019 12:43
WIP: Dep parser
const {
dependencies: dependenciesNew,
devDependencies: devDependenciesNew
} = require('../cazmatrans.hr-native-0.59/package.json')
const { dependencies, devDependencies } = require('./package.json')
// const newDeps = Object.keys(devDependenciesNew)
// console.log(newDeps.filter(dep => !devDependencies[dep]).join(' '))
const newDeps = Object.keys(dependenciesNew)
@capJavert
capJavert / DeepLinkService.js
Created September 5, 2019 11:39
Service for cross platform handling of deep links.
import { Logger } from 'core/helpers'
class DeepLinkService {
init(navigation) {
this.navigation = navigation
}
handleUrl = (event, navigation) => {
try {
if (!event?.url) {