Skip to content

Instantly share code, notes, and snippets.

@alanhoff
alanhoff / gist:057ab3a135bafd280abe
Last active August 29, 2015 14:02
twitter stream
{ created_at: 'Sat May 31 20:55:41 +0000 2014',
id: 472843882573860860,
id_str: '472843882573860865',
text: '@paulo_hp #bovify #teste #hashtags',
source: '<a href="https://chrome.google.com/extensions/detail/encaiiljifbdbjlphpgpiimidegddhic" rel="nofollow">Silver Bird</a>',
truncated: false,
in_reply_to_status_id: null,
in_reply_to_status_id_str: null,
in_reply_to_user_id: 153026017,
in_reply_to_user_id_str: '153026017',
var request = require('request');
var cheerio = require('cheerio');
// use [] ao invés de Array()
var posts = [];
// Iniciando o request principal
request('http://www.hardmob.com.br/promocoes', function teste(error, response, html) {
if (error || response.statusCode !== 200)
throw error | new Error('status code ', + response.statusCode);
@alanhoff
alanhoff / center.html
Created June 6, 2014 13:26
Centralizar uma div na tela
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Centralizando divs</title>
</head>
<body>
<div id="youtube" style="width: 560px; height: 315px;">
<iframe width="560" height="315" src="//www.youtube.com/embed/DDpSUqjtrRk?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
var gulp = require('gulp');
var connect = require('gulp-connect');
var livereload = require('gulp-livereload');
var watch = require('gulp-watch');
gulp.task('connect', function() {
connect.server({
root : __dirname
});
});
#!/bin/bash
git add . --all
git commit -am "$2"
git push $1 master
@alanhoff
alanhoff / marked.js
Created June 16, 2014 06:44
marked.js
/*
* angular-marked v0.0.1
* (c) 2013 J. Harshbarger
* License: MIT
*/
/* jshint undef: true, unused: true */
/* global angular:true */
/* global marked:true */
var text = 'Seitan XOXO meh cornhole, before they sold out mustache scenester photo booth. IPhone selvage Pitchfork aesthetic. Polaroid post-ironic Thundercats quinoa, roof party PBR mumblecore cred +1 semiotics scenester freegan organic Godard. Cred Banksy meggings actually, Helvetica kogi gluten-free fap ethical slow-carb flexitarian before they sold out four loko. Fixie ugh yr single-origin coffee mustache. Mumblecore cardigan Helvetica mlkshk iPhone. Biodiesel synth pug Banksy mustache food truck McSweeney\'s, Intelligentsia post-ironic whatever ethnic dreamcatcher.';
var cut = function(text, max, delimiter){
return text.split(' ').reduce(function(arr, word){
if(!Array.isArray(arr))
arr = [new Buffer(arr)];
if(Buffer.concat([arr[arr.length -1], new Buffer(' ' + word)]).length > max)
arr.push(new Buffer(word));
else
Banco de dados (collections)
users
{
_id : uc934uc93ug9fh3409f8
password : iuyg389274gf973g9f7
feeds : [
{
url : 'http://feedlocodedoido.com.br/feed.rss',
},
var http = require('http');
var sockets = 0;
// Loop funcional
(function loop(i){
if(i === 1000)
return;
var req = http.get({
hostname: 'google.com.br',
var rsa = require('rsa-stream');
var fs = require('fs');
var privkey = fs.readFileSync('./minhaPrivKey.key', 'utf8');
var encStream = rsa.dencrypt(privkey);
var inStream = fs.createReadStream('./foto.enc');
var outStream = fs.createWriteStream('./minhafotolocodedoida.jpg');
inStream.pipe(encStream).pipe(outStream);