Skip to content

Instantly share code, notes, and snippets.

View carloscasalar's full-sized avatar
💜
Helping make cities a better place to live at @cabify

Carlos Castillo carloscasalar

💜
Helping make cities a better place to live at @cabify
View GitHub Profile
#!/usr/bin/env sh
export CUR="github.com/..."
export NEW="github.com/..."
go mod edit -module ${NEW}
find . -type f -name '*.go' -exec perl -pi -e 's/$ENV{CUR}/$ENV{NEW}/g' {} \;
@carloscasalar
carloscasalar / getfreeport.go
Created February 17, 2025 09:39 — forked from sevkin/getfreeport.go
get free port in golang
// GetFreePort asks the kernel for a free open port that is ready to use.
func GetFreePort() (port int, err error) {
var a *net.TCPAddr
if a, err = net.ResolveTCPAddr("tcp", "localhost:0"); err == nil {
var l *net.TCPListener
if l, err = net.ListenTCP("tcp", a); err == nil {
defer l.Close()
return l.Addr().(*net.TCPAddr).Port, nil
}
}
@carloscasalar
carloscasalar / Steps_to_Terminal_Enlightenment_on_a_Mac.md
Created January 14, 2023 13:04 — forked from GLMeece/Steps_to_Terminal_Enlightenment_on_a_Mac.md
Steps to Terminal Enlightenment on a Mac (tweaking your terminal for fun and profit)
@carloscasalar
carloscasalar / github-emoji-codes.md
Last active February 3, 2021 10:38 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

A small set of emojis with examples

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
@carloscasalar
carloscasalar / background.js
Created March 14, 2019 06:51 — forked from muralikg/background.js
puppeteer screen capture demo. Currently records 10 second video. Change the timeout in background.js with your own logic to stop the recording when necessary. Try with `node export.js`
/* global chrome, MediaRecorder, FileReader */
chrome.runtime.onConnect.addListener(port => {
let recorder = null
port.onMessage.addListener(msg => {
console.log(msg);
switch (msg.type) {
case 'REC_STOP':
console.log('Stopping recording')
if (!port.recorderPlaying || !recorder) {
@carloscasalar
carloscasalar / playground.rs
Last active July 30, 2018 15:50 — forked from rust-play/playground.rs
Sample usage of associative type in rust
pub trait Point{
type Identifier: PartialEq;
fn id(&self) -> Self::Identifier;
}
#[derive(Debug)]
pub struct Connection<T: Point> {
pub to: T
}
@carloscasalar
carloscasalar / ultimate-ut-cheat-sheet.md
Created January 9, 2017 10:59 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@carloscasalar
carloscasalar / exposePriv.js
Created November 25, 2016 11:55 — forked from ssaunders/exposePriv.js
Expose private variables for unit testing in JavaScript
/* The code below takes a constructor and exposes its private functions
Useful for unit testing (not general use). An example usage is below it.
Access to the private functions available through the _privMems property. */
/* Original credit goes to Rob Gravelle
http://www.htmlgoodies.com/beyond/javascript/accessing-private-functions-in-javascript.html */
var Reflection = {};
Reflection.createExposedInstance = function(objectConstructor, args)
{
@carloscasalar
carloscasalar / docx2md.md
Created September 16, 2015 10:23 — forked from aembleton/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in One Move

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

angular
.module('uuidApp', ['lvl.services'])
.controller('uuidCtl', ['$scope', 'uuid', function($scope, uuid){
$scope.generateUuid = function() {
$scope.new = uuid.new();
$scope.nInfo = new Date();
};
$scope.showEmpty = function() {
$scope.empty = uuid.empty();