Skip to content

Instantly share code, notes, and snippets.

View Chalarangelo's full-sized avatar
💻
JavaScripting

Angelos Chalaris Chalarangelo

💻
JavaScripting
View GitHub Profile
@Chalarangelo
Chalarangelo / brainsource.js
Created March 29, 2017 14:44
Brainsource - regex-based brainfuck interpreter written in functional Javascript
////////////////////////////////////////////////////////////////////////////////
//* *//
// - B R A I N S O U R C E - //
// Regex-based brainfuck interpreter written in functional Javascript //
// Author: Angelos Chalaris (chalarangelo@gmail.com) //
// License: MIT License - https://opensource.org/licenses/MIT //
// Note: Certain parts might be slow, buggy or even not work at all. Use at //
// your own risk. //
//* *//
////////////////////////////////////////////////////////////////////////////////
@Chalarangelo
Chalarangelo / GenerateUniqueId.js
Last active May 29, 2017 10:46
Create unique id with javascript
function g(){for(var r=String.fromCharCode,n=Math.random,o=r(~~(25*n()+65)),a=b=0;b<32;a=~~(42*n()+48))58>a||a>64?(o+=r(a),b++):a;return o}
function UserCard(props) {
var user = props.user;
return React.createElement(
'div',
{ className: 'col-md-offset-1 col-lg-offset-2' },
React.createElement(
'div',
{ className: 'card fluid', id: "user_" + user.login.username },
React.createElement(
'div',
function SvgMapPin(props) {
return React.createElement(
'svg',
{ xmlns: 'http://www.w3.org/2000/svg', width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', stroke: '#424242', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' },
React.createElement('path', { d: 'M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z' }),
React.createElement('circle', { cx: '12', cy: '10', r: '3' })
);
}
// Get page scroll percentage.
function getScrollPercent() {
return (
(document.documentElement.scrollTop || document.body.scrollTop)
/ ( (document.documentElement.scrollHeight || document.body.scrollHeight)
- document.documentElement.clientHeight)
* 100);
}
{
"name": "Mockup Progressive Web App",
"short_name": "Mock PWA",
"description": "A mock progressive web app built with React and mini.css.",
"lang": "en-US",
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#1a237e",
"icons": [
{
// "caches" is a global read-only variable, which is an instance of CacheStorage
caches.open(cacheName).then(function(cache) {
// Do something with your cache
});
// Source: https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage/open
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && npm run build-rename-replace && npm run build-sw",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"build-sw" : "npm run build-replace-sw-refs && npm run build-minify-sw",
"build-rename-replace": "npm run build-rename && npm run build-replace",
"build-rename": "npm run build-rename-js && npm run build-rename-css",
"build-rename-js": "renamer --regex --find main\\.\\w+\\.js --replace main.js build/static/js/*.js",
"build-rename-css": "renamer --regex --find main\\.\\w+\\.css --replace main.css build/static/css/*.css",
var cacheName = 'mockApp-v1.0.0';
var filesToCache = [
'./',
'./index.html',
'./manifest.json',
'./static/js/bundle.js'
];
self.addEventListener('install', function(e) {
e.waitUntil(caches.open(cacheName)
self.addEventListener('activate', function(e) {
e.waitUntil(caches.keys()
.then(function(keyList) {
return Promise.all(keyList.map(function(key) {
if (key !== cacheName)
return caches.delete(key);
}));
}));
return self.clients.claim();
});