Skip to content

Instantly share code, notes, and snippets.

View adrai's full-sized avatar

Adriano Raiano adrai

View GitHub Profile
@adrai
adrai / example.js
Created September 17, 2014 14:08
oboe + restify
var restify = require('restify'),
oboe = require('oboe');
var client = restify.createClient({
url: 'http://localhost:3000',
version: '*'
});
client.get('/data', function (err, req) {
if (err) {
@adrai
adrai / blob_storage_spike.js
Last active August 29, 2015 14:06
atmos (s3) + local (fs)
'use strict';
var aws = require('aws-sdk'),
s3blobs = require('s3-blob-store'),
fsblobs = require('fs-blob-store'),
fs = require('fs'),
path = require('path');
var workLocally = false;
@adrai
adrai / blob_meta_infos_while_streaming.js
Last active August 29, 2015 14:07
blob meta infos while streaming
var url = require('url');
var http = require('http');
//var imgUrl = 'http://upload.wikimedia.org/wikipedia/commons/9/95/Big_Pine_landscape.jpg';
var imgUrl = 'http://downloads.xenproject.org/Branding/Images/Mascot/Xen%20Big%20Panda%204242x3129.png';
//var imgUrl = 'http://stackoverflow.com/questions/19934406/verify-mime-type-of-uploaded-files-in-node-js';
var options = url.parse(imgUrl);
http.get(options, function (response) {
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);
@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",
@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"
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 / 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>
@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 / 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);