Skip to content

Instantly share code, notes, and snippets.

View zettacristiano's full-sized avatar

Cristiano Oliveira zettacristiano

  • Lisbon
View GitHub Profile
@zettacristiano
zettacristiano / httpsExpressApp.js
Created December 22, 2016 21:16 — forked from ryanhanwu/httpsExpressApp.js
Express JS HTTP + HTTPs server (including auto redirect)
var express = require('express'),
routes = require('./routes'),
upload = require('./routes/upload'),
http = require('http'),
https = require('https'),
fs = require('fs'),
path = require('path'),
httpApp = express(),
app = express(),
certPath = "cert";
@zettacristiano
zettacristiano / node-and-npm-in-30-seconds.sh
Created August 9, 2017 23:41 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@zettacristiano
zettacristiano / node-and-npm-in-30-seconds.sh
Created August 9, 2017 23:41 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@zettacristiano
zettacristiano / JSON with JS.md
Created October 16, 2017 11:14
Access local JSON data with Javascript

What

An updated guide/collection of guides on how to access JSON data with JavaScript

Original Question on Stack Exchange.


Example 1

For reading the external Local JSON file (data.json) using java script

// Usage:
// OfflineListener.init(true);
define(['angular', 'core'], function(angular){
// Some concepts from: https://github.com/HubSpot/offline
var module = angular.module('utils.offline', []);
module.service('OfflineListener', function ($rootScope, $window, $alert) {
var offlineAlert;
// Usage:
// OfflineListener.init(true);
define(['angular', 'core'], function(angular){
// Some concepts from: https://github.com/HubSpot/offline
var module = angular.module('utils.offline', []);
module.service('OfflineListener', function ($rootScope, $window, $alert) {
var offlineAlert;
@zettacristiano
zettacristiano / node-pdf-generator.js
Created November 15, 2017 10:35 — forked from adamgibbons/node-pdf-generator.js
Display or download PDF from node.js server
var restify = require('restify')
, port = process.env.PORT || 3000
, Phantom = require('phantom')
, tmpdir = require('os').tmpdir()
, fs = require('fs');
var server = restify.createServer();
function setResponseHeaders(res, filename) {
res.header('Content-disposition', 'inline; filename=' + filename);
@zettacristiano
zettacristiano / api-provider.js
Created January 31, 2018 10:11 — forked from jelbourn/api-provider.js
Example of using an angular provider to build an api service. Subject of August 20th 2013 talk at the NYC AngularJS Meetup. http://www.meetup.com/AngularJS-NYC/events/134578452/See in jsbin: http://jsbin.com/iWUlANe/5/editSlides: https://docs.google.com/presentation/d/1RMbddKB7warqbPOlluC7kP0y16kbWqGzcAAP6TYchdw
/**
* Example of using an angular provider to build an api service.
* @author Jeremy Elbourn (@jelbourn)
*/
/** Namespace for the application. */
var app = {};
/******************************************************************************/
@zettacristiano
zettacristiano / angularjs_coinbase_button
Created February 27, 2018 02:05 — forked from ryanemmm/angularjs_coinbase_button
Implement coinbase button (html + js tag) in Angularjs view
# Used a directive to inject a 'hook' element
# + javascript tag that consumes/acts on said
# 'hook' via an anon, self-exececuting fn that
# fires when the script loads.
#
# The problem this solves is a race condition
# where the javascript executes prematurely
# and throws a SAMEORIGIN error.
<!-- html/directive call -->
@zettacristiano
zettacristiano / http-get-dos.conf
Created March 11, 2018 15:33 — forked from petarnikolovski/http-get-dos.conf
Fail2ban Configuration
# Fail2Ban configuration file
#
# NOTE
# You should set up in the jail.conf file, the maxretry and findtime carefully in order to avoid false positives.
#
# Author: http://www.go2linux.org
# Modified by: samnicholls.net
# * Mon 6 Jun 2016 - Updated failregex to capture HOST group correctly
[Definition]