Skip to content

Instantly share code, notes, and snippets.

View LukaszWiktor's full-sized avatar

Łukasz Wiktor LukaszWiktor

View GitHub Profile
// traditional
if (this.currentView == 'gantt') {
this.currentView = 'table';
} else {
this.currentView = 'gantt';
}
// tricky
var toggle = {'gantt' : 'table', 'table' : 'gantt'}
this.currentView = toggle[this.currentView];
@LukaszWiktor
LukaszWiktor / index.html
Last active August 29, 2015 14:25 — forked from jtrussell/index.html
jsbin - AngularJS, basic template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Angular JS</title>
</head>
<body ng-app="jsbin">
<div ng-controller="DemoCtrl as demo">
<h1>Hello {{demo.name}}</h1>
</div>
@LukaszWiktor
LukaszWiktor / logentries_manual_setup.md
Created May 25, 2016 09:23 — forked from ostinelli/logentries_manual_setup.md
How to use a single Logentries account on Heroku

If you have multiple applications on Heroku and would like to use a single Logentries account for all of them, this is how you do it. Basically, do not use add-ons, and send all drains to your account.

  • In your Logentries account, click on Add Log
  • Select Manual
  • In the form that appears, input the following:
    • Log Name: access.log
    • Select Set: new set named myapp-{environment}, for instance myapp-staging (at least, this is how I like to name my entries)
    • Select the Plain TCP, UDP - logs are sent via syslog option
  • Click on Create Log Token
@LukaszWiktor
LukaszWiktor / postgres-remove-field-from-json.sql
Created November 25, 2016 16:20
PostrgreSQL - remove a nested JSON field if it's null
-- before: data_json = {object: {id: 123, result: null}}
-- after: data_json = {object: {id: 123}}
UPDATE events
SET data_json = data_json::jsonb #- '{object,result}'
WHERE json_typeof(data_json->'object'->'result') = 'null';
@LukaszWiktor
LukaszWiktor / vue-focus.js
Last active January 28, 2017 17:40
Vue 2.x directive - automatic focus when element gets visible (works well with v-show)
Vue.directive('focus', {
update: function (el) {
if (!el.offsetParent) { // element not visible
el.dataset.focused=false;
} else if (el.dataset.focused!=="true") { // focus hasn't been forced yet
el.dataset.focused=true;
el.focus();
}
}
})
@LukaszWiktor
LukaszWiktor / AWS_S3_File_Upload.js
Created February 13, 2017 12:17 — forked from homam/AWS_S3_File_Upload.js
How to upload files to AWS S3 with NodeJS SDK
var AWS = require('aws-sdk'),
fs = require('fs');
// For dev purposes only
AWS.config.update({ accessKeyId: '...', secretAccessKey: '...' });
// Read in the file, convert it to base64, store to S3
fs.readFile('del.txt', function (err, data) {
if (err) { throw err; }
@LukaszWiktor
LukaszWiktor / voucherify-dev-signup.md
Created October 9, 2017 12:08
voucherify dev signup
@LukaszWiktor
LukaszWiktor / grab-ih-quotes.js
Last active February 13, 2024 12:02
Indie Hackers quotes
(async () => {
let i = 0;
let quotes = [];
while (true) {
const quoteResp = await fetch(`https://indie-hackers.firebaseio.com/loadingQuotes/${i++}.json`);
const quote = await quoteResp.json();
if (!quote) break;
quotes.push(quote);
console.log(i);
}

Build image

docker build --tag <image tag>

Run container exposing port 4444 and mounting /views directory

docker run -p 4444:4444 /${PWD}/views:/code/views <image tag>

List running containers