Skip to content

Instantly share code, notes, and snippets.

View cristobal's full-sized avatar
💭
¯\_(ツ)_/¯

Cristobal Dabed cristobal

💭
¯\_(ツ)_/¯
View GitHub Profile
@cristobal
cristobal / package_json_find_when_introduced.sh
Created April 11, 2022 12:09
Find git commit when a package was introduced in the package.json file in a git repo.
prev_cmt=""
for cmt in $(git lg package.json | awk '{print $2}');
do
git co $cmt >/dev/null 2>&1
cat package.json | grep 'package-name' >/dev/null 2>&1
# will fail if does not find the package-name in the current commit
if [ $? -ne 0 ] ; then
echo "cmt: $cmt"
echo "prev_cmt: $prev_cmt"
git co main
@cristobal
cristobal / script.ps1
Created April 11, 2021 21:41
Setting custom NPM_USER_CONFIG with readonly NPM_TOKEN via Powershell (Tested in TeamCity)
# Write NPM_TOKEN registry without BOM @see https://stackoverflow.com/a/32951824
[IO.File]::WriteAllLines("$(Get-Location)\.npmrc", "//registry.npmjs.org/:_authToken=$env:NPM_TOKEN")
# Set Custom NPM_CONFIG_USERCONFIG Environment variable
$env:NPM_CONFIG_USERCONFIG="$(Get-Location)\.npmrc"
# debug who you are
# npm whoami
# replace * with the npm script you want to run.
const pattern =
new RegExp(
// starts with PT
'^PT' +
// one or more digits followed by the hours designator H
'((\\d+)H){0,1}' +
// one or more digits followed by the minutes designator M
'((\\d+)M){0,1}' +
// one or more digits with precission followed by the seconds designator S
'((\\d+(\\.\\d+){0,1})S){0,1}' +
function parseDesignators (duration) {
return [
{
name: 'hours',
designator: 'H'
},
{
name: 'minutes',
designator: 'M'
},
@cristobal
cristobal / AbstractError.js
Last active December 14, 2016 12:18
AbstractError + CustomError
// @see https://github.com/bjyoungblood/es6-error
// @see http://dailyjs.com/2014/01/30/exception-error/
import {map} from 'lodash';
const defineProperty = (obj, prop, value) => {
Object.defineProperty(obj, prop, {
configurable: true,
enumerable: false,
value
});
@cristobal
cristobal / reduce-promises-over-x.js
Created September 1, 2016 11:42
Reduce a set of promises (S) over a a value x
const reducePromises = (S, x) =>
S.reduce((f, g) => f.then(g), Promise.resolve(x));

Keybase proof

I hereby claim:

  • I am cristobal on github.
  • I am cristobal (https://keybase.io/cristobal) on keybase.
  • I have a public key ASAs5cvXRdcF-ajmMlIOsVqdbEkEVN0SUSEyZUPhWZ0OAgo

To claim this, I am signing this object:

@cristobal
cristobal / # mosml - 2016-03-19_16-50-37.txt
Created March 19, 2016 19:53
mosml on OS X 10.11.3 - Homebrew build logs
Homebrew build logs for mosml on OS X 10.11.3
Build date: 2016-03-19 16:50:37
@cristobal
cristobal / machine-diskutil.sh
Last active February 27, 2024 23:36
Machine Diskutil to mount/unmont external volumes inside docker machines running on Virtualbox
#!/usr/bin/env sh
# @see http://stackoverflow.com/questions/30040708/how-to-mount-local-volumes-in-docker-machine
# @see https://github.com/boot2docker/boot2docker/blob/master/doc/FAQ.md
################################################################################
# Dependency Section #
# #
################################################################################
check_deps() {
## Make sure commands are available
@cristobal
cristobal / propel_session_config.php
Created April 20, 2015 12:20
Silex - Propel + Session in DB
<?php
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
use Propel\Runtime\Propel;
use Propel\Runtime\Connection\ConnectionWrapper;
use Propel\Runtime\Connection\PdoConnection;
use Propel\Silex\PropelServiceProvider;
//--------------------------------------