Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
In case of fire: git commit, git push, leave the building!

Dalibor Gogic daliborgogic

🔥
In case of fire: git commit, git push, leave the building!
View GitHub Profile
View users-03022020.json
[
{
"password": {
"iterations": 10
},
"username": null,
"role": "admin",
"provider": "email",
"token": null,
"resetToken": null,
View dumb.json
{
"data": {
"firstName": "Foo",
"lastName": "Bar",
"email": "foo@bar.com"
}
}
@daliborgogic
daliborgogic / translate.js
Last active Jan 9, 2020
Cloud Translation v2
View translate.js
const { Translate } = require('@google-cloud/translate').v2
const translate = new Translate()
const text = 'Hello, world!'
const target = 'da'
async function translateText() {
// Translates the text into the target language. "text" can be a string for
// translating a single piece of text, or an array of strings for translating
// multiple texts.
@daliborgogic
daliborgogic / line_item.json
Last active Dec 21, 2019
Line Item JSON API specification (v1.0)
View line_item.json
{
"data": {
"id": "5c70a48c318ce30ebd00c14c",
"type": "line_items",
"links": {
"self": "https://foo.example.com/api/line_items/5c70a48c318ce30ebd00c14c"
},
"attributes": {
"type": "sku",
"sku": "7J237-410",
@daliborgogic
daliborgogic / Img.vue
Last active Nov 12, 2019
Conditionaly load img based on current users download speed and users choice to save data.
View Img.vue
<template>
<img :src="srcImage" :loading="loading" :alt="alt">
</template>
<script>
export default {
props: {
src: {
type: Object,
default: () => ({
@daliborgogic
daliborgogic / backup-files.sh
Last active Nov 8, 2019
I like to move it move it Google Cloud Bucket
View backup-files.sh
#!/bin/bash
# . ./backup-files.sh from to
# Variables
WHAT=`date +%d%m%y%H%M%S`.tar.gz
WHERE=gs://$2/$WHAT
SMALLER_ARE_BETTER="tar -czvf $WHAT $1"
targz(){
View index.js
async function foo (method, url, body) {
if (!url) throw new Error()
let config = {
headers: { accept: 'application/json' }
}
if (method && body) {
config.body = JSON.stringify(body)
config.method = method
}
const res = await fetch(url, { config })
View debounce.js
export default function (func, wait, immediate) {
var timeout
return function() {
var context = this, args = arguments
var later = function() {
timeout = null
if (!immediate) func.apply(context, args)
}
var callNow = immediate && !timeout
clearTimeout(timeout)
@daliborgogic
daliborgogic / instagram.js
Last active Oct 4, 2019
Instagram Graph API Media
View instagram.js
const fetch = require('node-fetch')
const { FB_PAGE_ID, FB_ACCESS_TOKEN } = process.env
const { getParams } = require('./helpers')
const GRAPH_URL = 'https://graph.facebook.com/v4.0'
const headers = { 'content-type': 'application/json' }
const options = { headers }
let params = { access_token: FB_ACCESS_TOKEN }
You can’t perform that action at this time.