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 ([email protected]) //
// 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}
@Chalarangelo
Chalarangelo / http-get-async.js
Created July 15, 2017 21:45
AJAX GET request function
// Send a 'GET' request to the specified url and run the callback function when it completes.
function httpGetAsync(url, callback) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
};
xmlHttp.open('GET', url, true);
xmlHttp.send(null);
}
// Functional component for the mail icon.
function SvgMail(props){
return <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"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>;
}
// Functional component for the calendar icon.
function SvgCalendar(props){
return <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"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>;
}
// Functional component for the map pin icon.
function SvgMapPin(props){
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",