Skip to content

Instantly share code, notes, and snippets.

Avatar

Helder S Ribeiro hsribei

View GitHub Profile
@hsribei
hsribei / teachable-markdown-example.min.js
Last active Nov 14, 2018
Sample code to render markdown client-side on Teachable
View teachable-markdown-example.min.js
parcelRequire=function(e,r,n,t){var i="function"==typeof parcelRequire&&parcelRequire,o="function"==typeof require&&require;function u(n,t){if(!r[n]){if(!e[n]){var f="function"==typeof parcelRequire&&parcelRequire;if(!t&&f)return f(n,!0);if(i)return i(n,!0);if(o&&"string"==typeof n)return o(n);var c=new Error("Cannot find module '"+n+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[n][1][r]||r},p.cache={};var l=r[n]=new u.Module(n);e[n][0].call(l.exports,p,l,l.exports,this)}return r[n].exports;function p(e){return u(p.resolve(e))}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=r,u.parent=i,u.register=function(r,n){e[r]=[function(e,r){r.exports=n},{}]};for(var f=0;f<n.length;f++)u(n[f]);if(n.length){var c=u(n[n.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=c:"function"==typeof define&&define.amd?define(function(){return c}):t&&(this[t]=c)}return u}({"5bmg":[function(require,module,exports) {
"use stric
@hsribei
hsribei / get-files-recursive-sync.js
Created Jul 11, 2018
List files recursively in nodejs then do some ad-hoc filtering and renaming
View get-files-recursive-sync.js
const fs = require('fs')
const path = require('path')
const child_process = require('child_process')
function getFilesRecursiveSync(folder) {
const fileContents = fs.readdirSync(folder)
return fileContents.reduce(function(matches, fileName) {
const filePath = path.join(folder, fileName)
const stats = fs.lstatSync(filePath)
@hsribei
hsribei / offline-emoji.md
Created Nov 26, 2017
Offline / no signal / lost connection emoji sequence
View keybase.md

Keybase proof

I hereby claim:

  • I am hsribei on github.
  • I am hsribei (https://keybase.io/hsribei) on keybase.
  • I have a public key whose fingerprint is CE60 7647 EE99 E678 D4BB 509A BDEE B41F 5ACF CF91

To claim this, I am signing this object:

@hsribei
hsribei / npm-yarn-global-without-sudo.md
Created May 4, 2017
Remove need for sudo for npm install -g and yarn global add
View npm-yarn-global-without-sudo.md
@hsribei
hsribei / catarse_pendentes.js
Last active Aug 29, 2015
Somar contribuições pendentes no Catarse
View catarse_pendentes.js
// Clica no botão de rádio dos pendentes, rola a página até o fim para carregar todas as contribuições,
// abre o console, digita isso e dá Enter:
_.chain($('.value')).map(function(el){ return parseFloat($(el).text()); }).reduce(function(sum, el){ return sum + el; }, 0).value();
@hsribei
hsribei / read-later-plus-spaced-repetition-for-language-learners.md
Last active Aug 29, 2015
Wish: "Read it later" plus "spaced repetition" app for language learners
View read-later-plus-spaced-repetition-for-language-learners.md

Update: found something close enough: http://readlang.com/.

Wish: "Read it later" plus "spaced repetition" app for language learners

  • All the usual ways of sending articles to this "Pocket" app: email, browser extensions, the app itself.
  • While reading, select word of phrase, have it translated and added to app as a flashcard. Front: word/phrase highlighted in context; Back: translation + optional notes.
  • Batch mode: toggle batch mode, select multiple words/phrases, have their definitions/translations all added as flashcards.
  • Optionally, go through those new cards right away (as opposed to studying them only in the random-ish order of the whole set's spaced repetition) and, when finished, go back to text. This way you can quickly go through a paragraph in batch mode, mark everything you don't understand, study it, then go back to read it with the necessary vocabulary.
  • When not reading, user can go through flashcards with a spaced repetition algorithm and interface similar to Brainscape's. From
@hsribei
hsribei / putting-the-tor-back-in-torrent.md
Last active Jan 18, 2017
Putting the "Tor" back in Torrent
View putting-the-tor-back-in-torrent.md

Putting the "Tor" back in Torrent

How a Popcorn Time fork patch could incentivize people to run thousands of new Tor relays

This is a follow-up to this discussion: Can NAT traversal be Tor's killer feature?

If torrents are P2P's killer application, and NAT traversal/"static IP" are Tor's (via hidden services), putting them together could prove to be the best incentivization scheme for growing the Tor network other than cold crypto cash.

You're stupid

Everybody knows you're not supposed to use torrents with tor, right?

@hsribei
hsribei / can-nat-traversal-be-tor-s-killer-feature.md
Last active Jul 12, 2018
Can NAT traversal be Tor's killer feature?
View can-nat-traversal-be-tor-s-killer-feature.md

Can NAT traversal be Tor's killer feature?

tl;dr: how about a virtual global flat LAN that maps static IPs to onion addresses?

[We all know the story][1]. Random feature gets unintentionally picked up as the main reason for buying/using a certain product, despite the creator's intention being different or more general. (PC: spreadsheets; Internet: porn; smartphones: messaging.)

@hsribei
hsribei / parse-url-params.js
Created Nov 25, 2012
Parse url parameters from any string given or from current URL otherwise
View parse-url-params.js
// Adapted from http://stackoverflow.com/a/901144/105132
function parseUrlParams(queryString) {
var params = {},
match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = queryString || window.location.search.substring(1);