Skip to content

Instantly share code, notes, and snippets.

View daliborgogic's full-sized avatar
:octocat:
In Git we trust!

Dalibor Gogic daliborgogic

:octocat:
In Git we trust!
View GitHub Profile
@daliborgogic
daliborgogic / delay.js
Created December 16, 2016 15:26
Node.js Async/Await delay
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {
@daliborgogic
daliborgogic / gist:58f1f4867736fb4b787f18b300023501
Created December 17, 2016 17:07
Common HTTP status codes and their friendly names
$ node
> http.STATUS_CODE
{
'100': 'Continue',
'101': 'Switching Protocols',
'102': 'Processing',
'200': 'OK',
'201': 'Created',
'202': 'Accepted',
'203': 'Non-Authoritative Information',
module.exports = function (req, res, next) {
var render = res.render;
res.render = function () {
var viewName = arguments[0],
withoutExtension = viewName.replace(/\.[a-z]+$/i, ""),
bodyClass = withoutExtension.replace(/\//g, "-");
res.locals.bodyClass = bodyClass;
render.apply(this, arguments);
@daliborgogic
daliborgogic / Dockerfile
Created January 29, 2017 17:31
Alpine with dependencies that rely on node-gyp
FROM node:alpine
RUN apk add --no-cache --virtual .gyp \
python \
make \
g++ \
&& npm install \
[ your npm dependencies here ] \
&& apk del .gyp
@daliborgogic
daliborgogic / Terminal.sublime-settings
Last active February 3, 2017 16:44
Launch Hyperterm from the current file or the root project folder
// https://packagecontrol.io/packages/Terminal
{
"terminal": "/opt/Hyper/hyper",
"parameters": ["%CWD%"]
}
@daliborgogic
daliborgogic / index.pug
Last active May 10, 2020 07:30
Product Social Media Tags
//- https://search.google.com/structured-data/testing-tool#url=daliborgogic.com
//- https://cards-dev.twitter.com/validator
//- https://developers.facebook.com/tools/debug/
html(itemscope itemtype="http://schema.org/Product")
title Page Title. Maximum length 60-70 characters
meta(name="description" content="Page description. No longer than 155 characters.")
//- Schema.org markup for Google+
@daliborgogic
daliborgogic / index.js
Last active February 12, 2017 14:32
Input-specific event handling by using a single pointer event you can use the pointerType property
// https://w3c.github.io/pointerevents/
foo.addEventListener('pointerdown', e => {
switch (e.pointerType) {
case 'mouse':
// mouse detected
break
case 'pen':
// pen / stylus detected
break;
@daliborgogic
daliborgogic / install-postman.sh
Last active April 28, 2017 21:50 — forked from pierremonico/Postman.desktop
Install Postman
#!/bin/bash
cd /tmp || exit
echo "Downloading Postman ..."
wget -q https://dl.pstmn.io/download/latest/linux?arch=64 -O postman.tar.gz
tar -xzf postman.tar.gz
rm postman.tar.gz
echo "Installing to opt..."
if [ -d "/opt/Postman" ];then
sudo rm -rf /opt/Postman
@daliborgogic
daliborgogic / shot.sh
Created May 1, 2017 20:24
Headless Chrome Taking screenshots
# https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
# --disable-gpu currently required, see link above
google-chrome --headless --screenshot --disable-gpu --window-size=1440,900 https://daliborgogic.com/
@daliborgogic
daliborgogic / gist:f5603e178b7d9d8a50843e8471dcf8f6
Created May 31, 2017 20:11
Native string.padStart() and string.padEnd()
$ node -v
> v8.0.0
$ node
> let codeName = 'carbon'
undefined
> codeName.padStart(10)
' carbon'
> codeName.padEnd(10)
'carbon '