Skip to content

Instantly share code, notes, and snippets.

View hsribei's full-sized avatar

Helder S Ribeiro hsribei

View GitHub Profile
@hsribei
hsribei / gist:1313664
Created October 25, 2011 18:00
It's OK to delete branches after merging them

Deleting branches after merging them into other branches can help unclutter your list of branches. If you use a lot of topic branches for features and don't delete them, pretty soon you'll have a very long list of old, unmaintained branches, and that's going to make it harder for you to find the ones you're currently working on.

You can always get back to old branches anyway. When you merge, a merge commit is created on the branch you merged into. Merge commits have two parents, which are referenced by their SHA1s. So if you need to see the old branch, just check out the SHA1 of the corresponding parent on the merge commit. Since it's referenced in a living branch, it's not gonna get garbage-collected by Git.

The only case where the original SHA1 wouldn't be kept around is if it was a fast-forward merge. To prevent that from happening, you can use the option --no-ff on the git merge command, which will create a merge commit even when a fast forward would be possible.

@hsribei
hsribei / gist:1313839
Created October 25, 2011 18:56
Git stash saves your uncommited work on a temporary stack and removes it from the current workspace

Git stash saves your uncommited work on a temporary stack and removes it from the current workspace, allowing you to switch branches without seeing complaints about uncommited changes.

@hsribei
hsribei / gist:1318423
Created October 27, 2011 00:19
A Recorder/Code generator for FireWatir
Abstract
========
This project aims at allowing users to record normal usage on a
website and then have a script generated that can reproduce such
actions.
This script is generated in Ruby and can be changed and mixed with
existing Ruby code to extend its behaviour, using regular Ruby
variables, loop constructs, etc.
@hsribei
hsribei / findPropertyValue.js
Created November 25, 2012 13:02
Find a property that has a certain value and return its object path starting at the root object parameter
// FIXME: this can very rapidly hit the call stack size limit
function findPropertyValue(obj, value) {
if (typeof obj.seenBefore === "undefined") {
// treat for object graph circularity
obj.seenBefore = true;
for (var key in obj) {
if (obj[key] == value) {
return key;
@hsribei
hsribei / parse-url-params.js
Created November 25, 2012 15:06
Parse url parameters from any string given or from current URL otherwise
// 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);
@hsribei
hsribei / putting-the-tor-back-in-torrent.md
Last active January 18, 2017 22:08
Putting the "Tor" back in Torrent

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?

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 / offline-emoji.md
Created November 26, 2017 11:21
Offline / no signal / lost connection emoji sequence

📶🚫

@hsribei
hsribei / get-files-recursive-sync.js
Created July 11, 2018 03:20
List files recursively in nodejs then do some ad-hoc filtering and renaming
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 / can-nat-traversal-be-tor-s-killer-feature.md
Last active July 12, 2018 19:15
Can NAT traversal be Tor's killer feature?

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.)