Skip to content

Instantly share code, notes, and snippets.

Pontus Lundin hontas

Block or report user

Report or block hontas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hontas
hontas / Edited.md
Last active Jun 11, 2019
Notes from React Europe in Paris 2019
View Edited.md

ReactEurope

Thursday 23/5-19

Jared Palmer - State of React

2019 roadmap

  • Suspense for data fetching
  • A new server renderer
View vs code JS snippets.json
{
"console.log": {
"prefix": "c",
"body": [
"console.log('$1', ${2:$1});"
]
},
"import": {
"prefix": "imp",
"body": [
@hontas
hontas / pre-push
Created Dec 1, 2017
pre-push hook linting changed files and running test + checkstyle
View pre-push
#!/usr/bin/env bash
printf "<pre-push>\n";
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$BRANCH" = "master" ]]; then
cd frontend;
FRONTEND_DIFF=`git diff-index --name-only --relative origin/master`;
if [ "$FRONTEND_DIFF" ];
then
printf "Frontend files changed: \n$FRONTEND_DIFF\n";
@hontas
hontas / index.js
Created May 24, 2017
fetch handler
View index.js
const NO_CONTENT = 204;
const getHeaders = {
'accept': 'application/json'
};
const postHeaders = {
'Content-Type': 'application/json'
};
export function getJSON(url) {
return fetch(url, { headers: getHeaders })
View notifications.styl
.notifications {
// Used for calculations
$defaultWidth = 320;
$success = $brand-happy;
$error = $brand-angry;
$warning = $warning;
$info = $brand-turquoise;
$defaultShadowOpacity = "0.9";
&-wrapper {}
@hontas
hontas / ES7.js
Created Jan 21, 2016
Some snippets of ES7
View ES7.js
function makeRequest(id) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (id % 2) {
resolve(id);
} else {
reject(id);
}
}, 400);
});
@hontas
hontas / README.md
Last active Aug 29, 2015
Base project README
View README.md

Project name

optional tagline

Short description of what it is and what it does. Possibly even what it does not.

Local setup

  • Minimum possible steps
  • developer need take to start developing
@hontas
hontas / uniq.js
Last active Aug 29, 2015
Uniq implementation using Array.prototype.reduce
View uniq.js
/* more functional version using concat */
function uniq(array) {
return array.reduce(function(result, currentElement) {
if (result.indexOf(currentElement) < 0) {
return results.concat([currentElement]);
}
return result;
}, []);
}
@hontas
hontas / validateYears.js
Created Jun 9, 2014
Good example of bad method naming
View validateYears.js
validateYears: function(Class, prop) {
var input = Ember.get(Class, prop),
regex = /\D*(\d*)\.?(\d{2}).*/,
result;
if (input.length > 0) {
this.set('errorMsg', null);
if (input.match(regex)) {
result = input.replace(regex, "$1,$2").replace(/[,]/g, '.');
@hontas
hontas / bootstrapButtonComponent.js
Created May 28, 2014
Ember Bootstrap Button Component
View bootstrapButtonComponent.js
(function() {
"use strict";
var layout =
"{{yield}}" +
"{{currentText}}" +
"<span {{bind-attr class='iconClass loadingWhen:hide'}}></span>" +
"<span {{bind-attr class=':glyphicon :glyphicon-refresh loadingWhen:glyphicon-spin:hide'}}></span>";
App.BootstrapButtonComponent = Ember.Component.extend({
You can’t perform that action at this time.