Skip to content

Instantly share code, notes, and snippets.

View menjaraz's full-sized avatar

Menjanahary menjaraz

View GitHub Profile
@menjaraz
menjaraz / hapi.js
Created February 16, 2016 06:49 — forked from lwe/hapi.js
Server-sent-events with trial for hapi and one with a plain node.js http server.
var Hapi = require('hapi');
var stream = require('stream');
// Create a server
var server = Hapi.createServer('localhost', 8000);
// Add a route
server.route({
method: 'GET',
path: '/hello',
@menjaraz
menjaraz / gist:9e71d2bea2dfbcdd59ce
Created February 16, 2016 06:45 — forked from iampeter/gist:5af9c9e113e41c954364
Simple proxy with hapi.js to fix your CORS problems

Problem

While building a JavaScript single page app that acts as a front-end to multiple backend servers, even if they are on the same host as the web app - but on different ports, you come across CORS issues.

Solution

Use a simple node.js + hapi.js server to:

  1. Serve your static single page app
  2. Act as proxy to the backend servers
@menjaraz
menjaraz / hapijs-rest-api-tutorial.md
Created November 26, 2015 12:09 — forked from agendor/hapijs-rest-api-tutorial.md
A practical introduction to building a RESTful API with the hapi.js server framework for Node.js
@menjaraz
menjaraz / laravel-5-homestead-win.md
Last active August 29, 2015 14:27 — forked from prograhammer/laravel-lumen-5-homestead-win.md
Laravel 5 (and Lumen) Homestead for Windows (includes fixes for shared-folder related slowness, npm install problems, HHVM, etc)

Laravel/Lumen Homestead for Windows (w/ fixes)

###Initial installation and configuration Install Git for Windows which includes Git Bash.

Install VirtualBox and Vagrant.

Note: Do not install VirtualBox 5.0 and Vagrant 1.7.4. At the moment these versions are causing problems that I've been unable to solve with this Gist. Use the previous versions instead. VirtualBox 4.3.30 and Vagrant 1.7.3.

# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.provision "shell", path: "vagrant-android-build.sh"
config.vm.provider :virtualbox do |vb|
<?php
class ZipImages
{
private $folder;
private $url;
private $html;
private $fileName;
private $status;
<?php
/*
|--------------------------------------------------------------------------
| Sharing Laravel's session and checking authentication
|--------------------------------------------------------------------------
|
| Use the following code in any CMS (WordPress, Joomla, etc), filemanager (CKFinder,
| KCFinder, simogeos's Filemanager, etc), or any other non-Laravel project to boot into
| the Laravel framework, with session support, and check if the user is authenticated.
artoo.scrape('.subscriptions .subscription', {
name: function() {
return $.trim($(this).find('.productLink a').text());
},
price: function() {
var match = $(this).find('.priceInformation').text().match(/Current price:\s+\$(\d+\.\d+)/);
return match ? match[1] : '';
},
"interval in months": function() {
var match = $(this).find('.frequency').text().match(/every\s+(?:(\d)\s+)?month/);
var urls = ['url', 'url2'];
artoo.ajaxSpider(
function(i) {
return urls[i];
},
{
process: function(data, i) {
var inv = $(data).find('.classname').text();
var url = urls[i];
return [url, inv];
(function(artoo) {
// Artoo Spider for http://www.immobiliare.it/info/ufficio-stampa
var scrape = {
iterator: '#wrapTestoStatiche',
data: {
'id': function() {
var id = artoo.$(this).find('.text-align_left a:last-child').attr('href');
if (id) {
id = id.match(/ImmoNews\-(\d+)\.pdf$/);