Skip to content

Instantly share code, notes, and snippets.

View mfferreira's full-sized avatar
🏠
Working from home

Marco Ferreira mfferreira

🏠
Working from home
View GitHub Profile
@joseluisq
joseluisq / stash_dropped.md
Last active March 18, 2025 14:49
How to recover a dropped stash in Git?

How to recover a dropped stash in Git?

1. Find the stash commits

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

@saintplay
saintplay / counter.function.js
Last active October 17, 2021 17:00
Add counter for Firestore Collection
// functions/income/counter.function.js
'use strict'
const functions = require('firebase-functions')
const admin = require('firebase-admin')
// Prevent firebase from initializing twice
try { admin.initializeApp(functions.config().firebase) } catch (e) {}
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@EvanSimpson
EvanSimpson / tessel-ibeacon.js
Created August 7, 2014 23:34
Turn your Tessel BLE module into an iBeacon
var tessel = require('tessel');
var bleLib = require('ble-ble113a');
var bleadvertise = require('bleadvertise');
var uuid = 'D9B9EC1F392543D080A91E39D4CEA95C'; // Apple's example UUID
var major = '01';
var minor = '10';
var iBeaconData = new Buffer(uuid+major+minor, 'hex'); // Create data Buffer
@aaronksaunders
aaronksaunders / app.js
Last active August 29, 2015 14:03
Appcelerator Cloud Services, Promises and Custom Objects
//
//
var Q = require('q'); // add q.js library - https://github.com/kriskowal/q
var Cloud = require("ti.cloud"); // add in tiapp.xml
Cloud.debug = true;
function cloudCreateObjects(_data) {
var deferred = Q.defer();
@johnnyman727
johnnyman727 / ibeacon.js
Created June 27, 2014 01:37
Use Tessel as an iBeacon device
var tessel = require('tessel');
var blePort = tessel.port['A'];
var bleLib = require('ble-ble113a');
var data = new Buffer('0201061aff4c000215e2c56db5dffb48d2b060d0f5a71096e000000000c6','hex');
var ble = bleLib.use(blePort, function(err) {
if (err) return console.log("Error connecting to slave", err);
ble.setAdvertisingData(data, function (e2){
if (e2) console.log("Error set adv", e2);
@hsiboy
hsiboy / wiegand.c
Created March 17, 2014 12:59
Wiegand API for Raspberry Pi
/*
* Wiegand API Raspberry Pi
* By Kyle Mallory All rights reserved.
* 12/01/2013
* Based on previous code by Daniel Smith (www.pagemac.com) and Ben Kent (www.pidoorman.com)
* Depends on the wiringPi library by Gordon Henterson: https://projects.drogon.net/raspberry-pi/wiringpi/
*
* This is linked with -lpthread -lwiringPi -lrt
*
* The Wiegand interface has two data lines, DATA0 and DATA1. These lines are normall held
@rodw
rodw / coffee-as-a-service-via-forever.sh
Created February 12, 2014 00:26
This is an example of a (bash) shell script that uses the forever module to start and stop a CoffeeScript application as if it were a service.
#!/bin/bash
# This is an example of a (bash) shell script that uses the forever module ([1])
# to start and stop a CoffeeScript application as if it were a service.
#
# [1] <https://github.com/nodejitsu/forever>
# ASSUMPTIONS
################################################################################
# 1) You've got a CoffeeScript program you want to run via `forever`.
@jmdobry
jmdobry / Instructions.md
Last active August 31, 2021 18:21
Nginx reverse-proxy for RethinkDB Admin UI

Start your rethinkdb instance with this flag: --bind all (or bind=all in the configuration file for your instance)

Block external access to the web UI with these two commands: sudo iptables -A INPUT -i eth0 -p tcp --dport 8080 -j DROP sudo iptables -I INPUT -i eth0 -s 127.0.0.1 -p tcp --dport 8080 -j ACCEPT

Install nginx: sudo apt-get install nginx

@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active June 19, 2025 10:53
A badass list of frontend development resources I collected over time.