Skip to content

Instantly share code, notes, and snippets.

View guillim's full-sized avatar

Guillim guillim

View GitHub Profile
@guillim
guillim / .bash_prompt
Last active April 9, 2020 07:35
Terminal colorisation: write "source ~/.bash_prompt" at the end of your ~./bash_profile #bash
#!/usr/bin/env bash
# Sexy bash prompt by twolfson
# https://github.com/twolfson/sexy-bash-prompt
# Forked from gf3, https://gist.github.com/gf3/306785
# If we are on a colored terminal
if tput setaf 1 &> /dev/null; then
# Reset the shell from our `if` check
tput sgr0 &> /dev/null
@guillim
guillim / git-completion.bash
Last active April 9, 2020 07:36
script to enable auto-completion for git commands in your terminal. Add this file at this path: cd ~ #bash
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
@guillim
guillim / docker-completion.bash
Last active April 9, 2020 07:35
script to enable docker completion in terminal using 'tab' command #bash
#!/usr/bin/env bash
# shellcheck disable=SC2016,SC2119,SC2155
#
# Shellcheck ignore list:
# - SC2016: Expressions don't expand in single quotes, use double quotes for that.
# - SC2119: Use foo "$@" if function's $1 should mean script's $1.
# - SC2155: Declare and assign separately to avoid masking return values.
#
# You can find more details for each warning at the following page:
# https://github.com/koalaman/shellcheck/wiki/<SCXXXX>
@guillim
guillim / jq-insert-var.sh
Created June 11, 2018 11:52 — forked from joar/jq-insert-var.sh
Add a field to an object with JQ
# Add field
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}'
# {
# "hello": "world",
# "foo": "bar"
# }
# Override field value
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}'
{
@guillim
guillim / flattenObject.js
Last active March 23, 2020 18:49
flattenObject.js | A simple function to flatten a javascript object #js
//A simple function to flatten a javascript object, with a '.' delimiter between nested levels
const flatten = (objectOrArray, prefix = '', formatter = (k) => (k)) => {
const nestedFormatter = (k) => ('.' + k)
const nestElement = (prev, value, key) => (
(value && typeof value === 'object')
? { ...prev, ...flatten(value, `${prefix}${formatter(key)}`, nestedFormatter) }
: { ...prev, ...{ [`${prefix}${formatter(key)}`]: value } });
return Array.isArray(objectOrArray)
? objectOrArray.reduce(nestElement, {})
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@guillim
guillim / Boulanger.js
Last active February 3, 2023 16:16
Boulanger #dgm #boulanger
//------------START------------------------------------------------------------------------------------------------
function start(context,$,_,site,typeDeCrawl){
site = (context.customData && context.customData.site) ? context.customData.site : site
typeDeCrawl = (context.customData && context.customData.typeDeCrawl) ? context.customData.typeDeCrawl : typeDeCrawl
switch (context.request.label) {
case 'home':
case_home(context,site,typeDeCrawl);
break;
case 'search':
case_search(context,$,_,site,typeDeCrawl);
@guillim
guillim / Cdiscount_V2.js
Last active March 28, 2023 06:58
#cdiscount #dgm
//------------START------------------------------------------------------------------------------------------------
async function start(context,$,site,typeDeCrawl){
context.log.info('remote file => start')
site = (context.customData && context.customData.site) ? context.customData.site : site
typeDeCrawl = (context.customData && context.customData.typeDeCrawl) ? context.customData.typeDeCrawl : typeDeCrawl
switch (context.request.userData.label) {
case 'home':
return await case_home(context,site,typeDeCrawl);
case 'search':