Skip to content

Instantly share code, notes, and snippets.

View igoralves1's full-sized avatar

Igor Alves igoralves1

View GitHub Profile
@igoralves1
igoralves1 / gist:8401888c29e027a6e1363decc53d1279
Created December 6, 2016 03:40
Node vs Apache vs Lighttpd vs Nginx
http://risebird.tumblr.com/post/140322249595/node-vs-apache-vs-lighttpd-vs-nginx
So you’re trying to build apps huh? You’re going to need to serve them from somewhere, so do you go with Apache? Perhaps something lighter like Lighttpd or Nginx? What about picking a server-side language? Java? PHP? Or perhaps we just go with a JavaScript solution and pick Node? Let’s examine the differences in these choices…
When it comes to process-based servers, Apache is undoubtedly the most popular. In a process-based server, each simultaneous connection requires a thread, which in turn, requires some overhead. On the other hand, an asynchronous server is event-driven, and mostly handles all requests in a single thread. Asynchronous web servers include the more lightweight Lighttpd and Nginx, as well as Node’s HTTP server. They use a non-blocking I/O event loop running in a single process to serve requests.
As far as languages go, you would typically use something like Java or PHP on a synchronous server like Apache. Th
http://risebird.tumblr.com/post/142205462000/node-microservices
A couple of months ago, I saw a great presentation by Laurie Voss (@seldo), cofounder of NPM, on Node Microservices. Here’s a nice summary of what I got out of it:
Microservices (AKA Service Oriented Architecture) work well in the Node environment. The microservices paradigm essentially splits your ginormous monolithic app into smaller applications that run on separate machines, and interface with each other. Such a distributed system usually comes with technical and organizational advantages, as well some some improvements in resource efficiency. It does, at the same time, introduce some new problems, most of them stemming from the need for concurrency/synchronization between services.
http://risebird.tumblr.com/post/147473986500/d3-react-awesome
I recently saw a presentation by Swizec Teller, a geek with a hat (@Swizec), about brining React into D3 and it was awesome! I mean, D3 and React fit together really really well. React improves a lot of things for D3: a component-like syntax, more understandable structuring, ease of modification and maintenance, and others…
For instance, you don’t need to use the complicated D3 data-setup functions, such as enter() anymore. This is because React takes over the DOM manipulation, and all you need to add are basic D3 shapes to render your data visually in a familiar React component structure. This makes things easier since React is declarative and resembles HTML. You can also take advantage of Dev Tool’s React panel on Chrome to easily see where all of your visual data components are being rendered. But let’s look at how D3 actually integrates with React. Is it really worth adding another technology to D3? We still need to use D3 for anything number
@igoralves1
igoralves1 / gist:2ddbad20278aaa2835d08403663b5a53
Last active December 6, 2016 03:18
Ubuntu 16.10: teamviewer:i386
"Teamviewer depends on libpng12-0, which is replace in yakkety (16.10) with libpng16-16. You can try using the libpng12-0 package from the xenial repository:"
http://askubuntu.com/questions/838949/ubuntu-16-10-teamvieweri386-depends-on-libpng12-0
Download version 12 at https://www.teamviewer.com/en/download/linux/
ila@ig:~$ cd Downloads/
ila@ig:~/Downloads$ ll
total 45476
@igoralves1
igoralves1 / patientmovementstatus.php
Last active December 22, 2016 14:27
API that interacts with IoT devices.
<?php
header('Content-Type:application/json');
$verb=$_SERVER['REQUEST_METHOD'];
include_once '../../../class/db.php';
if ($verb=="GET") {
@igoralves1
igoralves1 / api.php
Created December 5, 2016 16:03
API class to grab info in the database using a sql query sent trough the URL
//API
public static function get_list($table,$displayType,$fields=NULL,$complement=NULL) {//Default = JSON
try {
$db=new db();
if(isset($fields) && isset($complement)){
$db->sql = "SELECT $fields FROM $table $complement;";
}
else{
$db->sql = "SELECT * FROM $table;";
@igoralves1
igoralves1 / get_list.php
Created December 5, 2016 16:00
API/v1/get/get_list.php
//This API was ispired by White House Web API Standards => https://github.com/WhiteHouse/api-standards
//This method should provide more flexibility to the front-end team.
//We can create queries directly in the URL and grab the result in JSON to be used to render DOM objects or arr to debug prupose.
<?php
header('Content-Type:application/json');
include_once '../../../class/db.php';
$verb=$_SERVER['REQUEST_METHOD'];
if($verb=="GET"){
@igoralves1
igoralves1 / gist:0613600830e990bffdd36e08264e3dc9
Created December 5, 2016 15:51
Form to insert a new resource (Staff user).
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="../assets/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="../assets/js/jquery-3.1.1.min.js"></script>
@igoralves1
igoralves1 / gist:008c59d32bf7a3957404dd3a57ad7a92
Created December 5, 2016 15:44
db Class ... constructor
//This is a constructor that will return a handle to deal with a connection to the database MySQL
public function __construct() {
$this->dsn = "xxxxxxxx";
$this->username = "xxxxxxx";
$this->password = "xxxxx";
$this->db = "xxxxx";
try {
$this->conn = new PDO("mysql:host=$this->dsn; dbname=$this->db", $this->username, $this->password);
@igoralves1
igoralves1 / gist:e1bd9a37fd4c75977caed30ed2463263
Created December 5, 2016 15:41
API/v1 ... update_manageResources($jsonInfo)
//This is an method of an API that will create new resources in the database.
//Insert new users (STAFF).
public static function update_manageResources($jsonInfo) {
try {
$arrData=json_decode($jsonInfo, true);
$arrMapProfession=[
"1"=>"assistant",