Skip to content

Instantly share code, notes, and snippets.

View zettacristiano's full-sized avatar

Cristiano Oliveira zettacristiano

  • Lisbon
View GitHub Profile
@zettacristiano
zettacristiano / anchor_smooth_scroll.js
Created May 29, 2018 09:28 — forked from justinmc/anchor_smooth_scroll.js
Anchor Smooth Scroll - Angular Directive
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Anchor Smooth Scroll - Smooth scroll to the given anchor on click
* adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
angular.module('yourapp').directive('anchorSmoothScroll', function($location) {
'use strict';
return {
restrict: 'A',
replace: false,
@zettacristiano
zettacristiano / gist:0d6b5dde63d1659c94107ca98ea27bb5
Created March 22, 2018 01:53 — forked from aioutecism/gist:2638bb9eaf9ffc13348c
Set up a VPN Server (PPTP) on AWS and use it anywhere

Set up a VPN Server (PPTP) on AWS

  1. Create a EC2 instance using Ubuntu 14.04.
  2. In Secure Group Inbound Rules, add a SSH Rule(TCP, Port 22, 0.0.0.0/0) and a Custom TCP Rule(TCP, Port 1723, 0.0.0.0/0).
  3. Optional: Associate a Elastic IP with the instance.
  4. SSH into the instance.
  5. sudo apt-get install pptpd.
  6. sudo vim /etc/pptpd.conf. Uncomment localip 192.168.0.1 and remoteip 192.168.0.234-238,192.168.0.245.
  7. sudo vim /etc/ppp/pptpd-options. Uncomment ms-dns and ms-wins. Change the IP to Google's DNS like this:
@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]
@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 / 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 / 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);
// 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 / 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

@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