Skip to content

Instantly share code, notes, and snippets.

View organom's full-sized avatar
👨‍💻
Fixing the world, one issue at a time

Ricardo Gomes organom

👨‍💻
Fixing the world, one issue at a time
View GitHub Profile
@organom
organom / keybase.md
Created February 26, 2018 14:04
keybase

Keybase proof

I hereby claim:

  • I am organom on github.
  • I am organom (https://keybase.io/organom) on keybase.
  • I have a public key ASD9OeGV8n1jfDx5kcrtq8C28fw0s0nI30I8saNtgUrINwo

To claim this, I am signing this object:

@organom
organom / CloneOrgGitHubRepos.sh
Last active July 1, 2018 23:03
Clones all the git repos from an organization
#!/bin/bash
if [ $# -lt 2 ]
then
echo "No arguments supplied"
echo "USAGE: $0 {organization} {accesstoken}"
echo ""
else
organization=$1
acesstoken=$2
@organom
organom / CallbackToPromiseWithAdapter.js
Created February 26, 2019 15:27
Callback to promise with adapter - easiest way to convert a function that relies on a callback that is not the last argument
const util = require('util');
postRequest(url, postData, cb, authToken, retries, inOptions) { (...) }
postRequestAsync(url, postData, authToken, retries, inOptions) {
const adapter = (url, postData, authToken, retries, inOptions, cb) => {
this.postRequest(url, postData, cb, authToken, retries, inOptions);
};
return util.promisify(adapter)(url, postData, authToken, retries, inOptions);
@organom
organom / addQueryToUrl.js
Last active June 27, 2022 20:37
util code for nodejs
"use strict";
/**
* adds an object as query to the given url
* @param url
* @param {object} query
* @returns {string} url with the extra query parameters
*/
function addQueryToUrl(url, query) {
if(!url) return '';
@organom
organom / FlattenFilesOfExtension
Last active December 2, 2020 14:30
Flattern folder and file structure by extension, files will be moved to the current folder with the name being $DIR-$FILENAME.EXTENSION
EXTENSION=hl7
find . -type f -name "*.$EXTENSION" -printf "/%P\n" | while read FILE ; do DIR=$(dirname "$FILE" ); NAME=$(basename "$FILE" ); mv ."$FILE" ."$DIR-$NAME".$EXTENSION; done
@organom
organom / git-status.sh
Created October 20, 2020 17:28
Lists all changes from all repositories present in the current folder
#!/bin/bash
find . -name .git -type d -exec sh -c '(cd {}; cd ..; git_temp=`git status -s`; if [ -n "${git_temp}" ]; then (echo $PWD && git status -s && echo); fi;)' \;
@organom
organom / git-rename.sh
Created October 20, 2020 17:29
Renames a git branch
#!/bin/bash
if [ $# -lt 2 ]
then
echo "Usage: $0 old_branch_name new_branch_name";
else
git branch -m $1 $2
git push origin :$1 $2
fi
@organom
organom / git-unset-filemode.sh
Created December 2, 2020 14:37
git-unset-filemode
#!/bin/bash
git config --global --unset-all core.filemode
git config --global core.filemode false
find . -name .git -type d -exec sh -c '(cd {}; cd ..; git config --unset-all core.filemode; git_temp=`git status -s`; if [ -n "${git_temp}" ]; then (echo $PWD && git status -s && echo); fi;)' \;
@organom
organom / git-branch-cleanup
Last active August 24, 2021 12:13
Remove local git branches not in remote
#!/bin/bash
git remote prune origin
git branch -vv | grep ': gone]'| grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -d
@organom
organom / easy-ngs-install.sh
Last active April 6, 2021 11:59
Easy ngs install
NGS_TMP_FOLDER=ngs_$RANDOM
mkdir $NGS_TMP_FOLDER
cd $NGS_TMP_FOLDER
curl $(curl -s https://api.github.com/repos/ngs-lang/ngs/releases | grep tarball_url | head -n 1 | cut -d '"' -f 4) -L -o ngs.tgz
tar -xvzf ngs.tgz --strip-components=1
OS=`uname`
if [ "$OS" = "Darwin" ]; then