Skip to content

Instantly share code, notes, and snippets.

Avatar

Łukasz Marek Sielski sielay

View GitHub Profile
View gist:c55ba22428b5b4c719c30065a9a2eb37
'use strict';
const https = require('https');
const API_KEY = 'KEY HERE';
const data = JSON.stringify({
registrationNumber: 'REGNUMBER'
})
@sielay
sielay / devopsjsx.jsx
Last active Apr 27, 2018
JSX to FaaS concept
View devopsjsx.jsx
export const simple = (props) =>
<AWSVPC id={props.vpc}>
<S3Bucket name={props.stage + "-bucket"} />
</AWSVPC>;
export const moreDifficult = (props) => {
const systemBucket = <S3Bucket name={props.stage + "-bucket"}/>
return <AWSVPC id={props.vpc}>
@sielay
sielay / primitives.md
Created Mar 15, 2018
Basic JS tasks for my baby based on JavaScript for Kids book
View primitives.md

String

var pokemon = "tHiS iS pOkEmOnCaSe";
// expected "This is pokemoncase.";
var yuliay = "yuliya";
var lukasz = "łukasz";
@sielay
sielay / foo.js
Last active Jan 25, 2021
Most JS senior candidates didn't know why this won't work
View foo.js
function foo() {
setTimeout(function(){
this.magic();
}, 1);
}
foo.prototype.magic = () => console.log('magic');
new foo();
// it won't work. if you know why and look for VanillaJS/Angular position in London (Wimbledon) then send me your CV on ... (I don't work there anymore)
@sielay
sielay / recurrent.dust.js
Last active Sep 13, 2016
Dust helper for recurrent templates
View recurrent.dust.js
/*
* Dust doesn't really like recurrent templates for various reasons (vars visibility etc). To resolve that issue you can use following helper
*/
engine.helpers.has = function (chunk, context, bodies, params) {
let tested = params.key;
if (tested[params.field] === undefined || tested[params.field] === null || tested[params.field].length === 0) {
return chunk;
}
return chunk.render(bodies.block, context);
};
@sielay
sielay / gist:0aa4077829f35f5e0310f9e0cc9fdc71
Created Aug 10, 2016
Haproxy - Capture client IP when behind CloudFlare or not. Also keep x-forwarded-for in logs
View gist:0aa4077829f35f5e0310f9e0cc9fdc71
frontend www-http
bind :80
bind *:443 ssl crt /etc/haproxy/certs no-sslv3
capture request header X-Forwarded-For len 50
acl is_cf req.hdr(cf-connecting-ip) -m found
http-request set-header X-Client-IP %[src] if !is_cf
http-request set-header X-Client-IP %[hdr(cf-connecting-ip)] if is_cf
View bootstrap_namespaced
/*!
* Bootstrap v3.3.2 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/.bs3{/*! normalize.css v3.0.2 | MIT License | git.io/normalize *//*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */}.bs3 html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}.bs3 body{margin:0}.bs3 article,.bs3 aside,.bs3 details,.bs3 figcaption,.bs3 figure,.bs3 footer,.bs3 header,.bs3 hgroup,.bs3 main,.bs3 menu,.bs3 nav,.bs3 section,.bs3 summary{display:block}.bs3 audio,.bs3 canvas,.bs3 progress,.bs3 video{display:inline-block;vertical-align:baseline}.bs3 audio:not([controls]){display:none;height:0}.bs3 [hidden],.bs3 template{display:none}.bs3 a{background-color:transparent}.bs3 a:active,.bs3 a:hover{outline:0}.bs3 abbr[title]{border-bottom:1px dotted}.bs3 b,.bs3 strong{font-weight:700}.bs3 dfn{font-style:italic}.bs3 h1{margin:.67em 0;font-size:2em}.bs3 mark{color:#000;backgroun
@sielay
sielay / Combine JS
Created Dec 3, 2014
MEAN.js change default setup to use LESS and combine all JavaScripts
View Combine JS
From 458e46425a7f70408df97f0a58bb3fc28b1df5cb Mon Sep 17 00:00:00 2001
From: Lukasz Sielski <lukaszsielski@gmail.com>
Date: Wed, 3 Dec 2014 22:18:15 +0000
Subject: [PATCH 3/3] Combine JS
---
app/views/layout.server.view.html | 10 +++++++++-
gruntfile.js | 25 ++++++++++++++++++++++---
package.json | 3 ++-
3 files changed, 33 insertions(+), 5 deletions(-)
@sielay
sielay / modal.js
Created Sep 17, 2014
I have spent days trying to understand how to add new controllers to page with Angular. Their documentation sucks, but I have found that finally
View modal.js
// https://github.com/angular-ui/bootstrap/blob/7b7cdf842278e86a677980d29bd74a1afd467ff1/src/modal/modal.js
angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
// ... some lines
// here $compile gets in by dependency injection... also spent hours debugging that :/
.factory('$modalStack', ['$transition', '$timeout', '$document', '$compile', '$rootScope', '$$stackedMap',
function ($transition, $timeout, $document, $compile, $rootScope, $$stackedMap) {