Skip to content

Instantly share code, notes, and snippets.

@jlis
jlis / v-cloak.css
Created June 8, 2018 11:47
vue.js Cloak Fade
[v-cloak] {
display: none!important;
}
.cloak-fade:not([v-cloak]) {
opacity: 0;
-webkit-animation-name: cloak-fade-in;
animation-name: cloak-fade-in;
-webkit-animation-duration: .3s;
animation-duration: .3s;
@jlis
jlis / index.js
Created May 18, 2018 08:49
AWS Lambda function to save events from SQS into DynamoDB
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({
region: process.env.AWS_REGION
});
var dynamodb = new AWS.DynamoDB();
var REPEAT_THRESHOLD = process.env.REPEAT_THRESHOLD || 20000;
function receiveSQSMessages(callback) {
var params = {
QueueUrl: process.env.TASK_QUEUE_URL,
@jlis
jlis / buildspec.yml
Created May 15, 2018 13:17
AWS CodeBuild Deployment via ECS/ECR
version: 0.2
phases:
pre_build:
commands:
- aws --version
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
build:
commands:
@jlis
jlis / .gitlab-ci.yml
Created May 15, 2018 13:16
AWS ECS and ECR deployment via Docker and Gitlab CI
image: docker:latest
variables:
REPOSITORY_URL: <AWS ACCOUNT ID>.dkr.ecr.eu-central-1.amazonaws.com/<ECS REPOSITORY NAME>
REGION: eu-central-1
TASK_DEFINTION_NAME: <TASK DEFINITION NAME>
CLUSTER_NAME: <CLUSTER NAME>
SERVICE_NAME: <SERVICE NAME>
services:
@jlis
jlis / giffy.json
Last active December 8, 2016 10:57
Giffy
[
"http://i.imgur.com/r8KxCiN.gif",
"http://i.imgur.com/P1cFjrt.gif",
"http://i.imgur.com/e4qryvN.gif",
"http://i.imgur.com/4g2Hh6x.gif",
"http://i.imgur.com/NNEt6ow.gif",
"http://i.imgur.com/AdrfEb2.gif",
"http://i.imgur.com/2KUoLff.gif",
"http://i.imgur.com/H0ebP7I.gif",
"http://i.imgur.com/fMum5pz.gif",
@jlis
jlis / percentage.php
Created December 2, 2016 11:27
Calculate a feature percentage with numeric (incremented) user id
<?php
$feature = 'test';
$limit = 100;
$percentage = 0.5; // ie. 0,5
function calculatePercentage($id) {
$hex = hash('sha256', $id);
$len = min(40, strlen($hex));
$vMax = 1 << $len;

Keybase proof

I hereby claim:

  • I am jlis on github.
  • I am jlis (https://keybase.io/jlis) on keybase.
  • I have a public key whose fingerprint is 012B 483A 3593 D093 665C E1A8 4AD8 9D8E 6D2C 547E

To claim this, I am signing this object:

@jlis
jlis / commit-msg
Created November 11, 2015 16:20
PHP commit-msg git hook which checks your syntax, the code style, runs unit tests and checks for a ticket nummer inside of the commit message.
#!/usr/bin/env php
<?php
/**
* The commit-msg hook script.
* Just create a symlink in your .git/hooks/ folder to this file.
*
* @author Julius Ehrlich <julius.ehrlich@lovoo.com>
*/
@jlis
jlis / gist:5669677
Created May 29, 2013 11:40
Javascript format function to replace placeholders in a string with content
// usage:
// string.format({key: replacement})
//
// example:
// 'Hello {name}, how are you doing? I am doing {mood}.'.format({name: 'Mike', mood: 'fine'});
String.prototype.format = function() {
var formatted = this;
if (arguments.length && typeof arguments[0] == 'object') {
var vars = arguments[0];
for (v in vars) {