Skip to content

Instantly share code, notes, and snippets.

View adrai's full-sized avatar

Adriano Raiano adrai

View GitHub Profile
@adrai
adrai / dummyTest.js
Last active January 11, 2022 09:26
aws-lambda-fastify (ESM optimization)
// import { handler } from './lambda.js' // let's import it dynamically, so we can measure...
const evt = {
httpMethod: 'GET',
path: '/test',
headers: {}
}
const ctx = {}
let st = Date.now()
@adrai
adrai / app.js
Created June 5, 2021 22:30
vue-i18next for vue v3
const i18nextPromise = i18next.use(i18nextHttpBackend).init({
debug: true,
lng: 'en',
fallbackLng: 'en',
backend: {
loadPath: './locales/{{lng}}/{{ns}}.json'
}
});
const app = Vue.createApp({});
@adrai
adrai / app.js
Created August 27, 2018 17:19
vue-i18next
/* eslint-disable no-undef, new-cap */
i18next
.use(i18nextXHRBackend)
.use(i18nextBrowserLanguageDetector)
.init({
fallbackLng: 'en',
backend: {
loadPath: '../locales/{{lng}}/{{ns}}.json'
},
ns: ['translations'],
@adrai
adrai / App.js
Last active August 27, 2018 17:17
react-i18next
import React, { Component } from 'react';
import { translate } from 'react-i18next';
import './App.css';
class App extends Component {
render() {
const { t, i18n } = this.props;
const changeLanguage = (lng) => {
i18n.changeLanguage(lng);
@adrai
adrai / directive.js
Last active August 27, 2018 17:12
ng-i18next
if (window.i18next) {
window.i18next
.use(window.i18nextXHRBackend)
.use(window.i18nextBrowserLanguageDetector)
.init({
debug: false,
fallbackLng: 'en',
backend: {
loadPath: '../locales/{{lng}}/{{ns}}.json'
@adrai
adrai / index.html
Last active August 27, 2018 17:02
jquery-i18next
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<title>jQuery App</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/i18next/11.6.0/i18next.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-i18next/1.2.1/jquery-i18next.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/i18next-browser-languagedetector/2.2.3/i18nextBrowserLanguageDetector.min.js"></script>
const util = require('util');
const Transform = require('stream').Transform;
function Slicer (options) {
if (!(this instanceof Slicer)) {
return new Slicer(options);
}
Transform.call(this, options);
}
@adrai
adrai / app.js
Last active November 13, 2023 08:40
aws-serverless-fastify
const fastify = require('fastify');
function init(serverFactory) {
const app = fastify({ serverFactory });
app.get('/', (request, reply) => reply.send({ hello: 'world' }));
return app;
}
if (require.main === module) {
// called directly i.e. "node app"
@adrai
adrai / gist:4efb524bb34a21595625
Last active August 29, 2015 14:24
elasticsearch spike snippets
PUT db1
PUT db1/table1/_mapping
{
"dynamic_templates": [{
"non_analyzed_string": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "string",
var CloudFoundryApi = require('cloud-foundry');
var _ = require('lodash');
var cf_api = new CloudFoundryApi('https....', {
token: '.... refresh token'
});
cf_api.organizations.list({}, function (err, page) {
if (err) {
return console.log(err);