Skip to content

Instantly share code, notes, and snippets.

View jacksonfdam's full-sized avatar
💻
Coding...

Jackson F. de A. Mafra jacksonfdam

💻
Coding...
View GitHub Profile
@jacksonfdam
jacksonfdam / index.html
Created February 21, 2017 00:03
Votação
<!-- index.html -->
<html>
<head>
<title>Votacao Real-time</title>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost:5000');
socket.on('toClient', function (votacao) {
console.log(votacao);
@jacksonfdam
jacksonfdam / Filmes.js
Last active February 20, 2017 22:33
Exem
npm install --save mongodb request request-promise
var request = require('request');
var rp = require('request-promise');
var db = require('mongodb').MongoClient;
let key = '246bf886104d519a1d2bf62aef1054ff';
router.get('/update-em-cartaz', function(req, res, next) {
rp('http://api.themoviedb.org/3/movie/now_playing?page=1&api_key='+key)
@jacksonfdam
jacksonfdam / pokemon.json
Last active February 3, 2017 00:24 — forked from shri/pokemon.json
JSON of pokemon to go with my pokemonMoves.json file
[
{
"name":"Bulbasaur",
"attack":49,
"defense":49,
"evolveLevel":16,
"evolveTo":"2",
"type":"grass",
"moves":[
"tackle",
<?php
function curl_get_contents($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
@jacksonfdam
jacksonfdam / CursoBotsLinks.md
Created January 21, 2017 14:38
Links Curso Bots
@jacksonfdam
jacksonfdam / index.js
Created December 17, 2016 17:27
API Server + SPA Static Server
var http = require('http');
var fs = require('fs');
var server = http.createServer(function(request, response) {
fs.readFile(__dirname + '/index.html', function(err, html) {
response.writeHeader(200, {
'Content-Type': 'text/html'
});
response.write(html);
response.end();
});
var fs = require('fs'),
http = require('http');
http.createServer(function (req, res) {
fs.readFile(__dirname + req.url, function (err,data) {
if (err) {
res.writeHead(404);
res.end(JSON.stringify(err));
return;
}
@jacksonfdam
jacksonfdam / filesystem.js
Last active December 17, 2016 16:30
FileSystem no NodeJS
var fs = require('fs');
fs.stat('data.txt', function (err, stats) {
if (err)
throw err;
if (stats.isFile()) {
console.log('É um arquivo!');
}
if (stats.isDirectory()) {
console.log('É um diretório!');
}