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 / 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
/**
* 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 / 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 ;)
@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 / 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 / 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 / test-server.js
Last active April 19, 2018 09:39
Custom json server using https://github.com/typicode/json-server and enables custom pk assignment for resources.
const jsonServer = require('json-server');
const server = jsonServer.create();
const path = require('path');
const router = jsonServer.router(path.join(__dirname, 'db.json'));
const middlewares = jsonServer.defaults();
// define primary key columns for each resource
const primaryKeys = {
"countries": "code",
"towns": "id",
@capJavert
capJavert / push-endpoints.txt
Last active March 22, 2018 00:22
Push service endpoints
POST /push - subscribe user by user_id with device_token
param: device_token: String
param: user_id: Int
Authorization: token: String - user Auth token
returns:
{
...
data: {
user_id: Int,
@capJavert
capJavert / rpg.owl
Last active April 26, 2024 02:23
Simple Dungeon & Dragons ontology
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/javert/ontologies/2017/10/dungeons-and-dragons#"
xml:base="http://www.semanticweb.org/javert/ontologies/2017/10/dungeons-and-dragons"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/javert/ontologies/2017/10/dungeons-and-dragons"/>
# all Items that belong to Characters
PREFIX rpg: <http://www.semanticweb.org/javert/ontologies/2017/10/dungeons-and-dragons#>
SELECT ?Character ?Item
WHERE { ?Character rpg:hasItem ?Item }
# all Characters that know Healing Spells
PREFIX rpg: <http://www.semanticweb.org/javert/ontologies/2017/10/dungeons-and-dragons#>
SELECT ?Character ?Spell
WHERE { ?Character rpg:knowsSpell ?Spell .
?Spell rdf:type rpg:Healing }