Skip to content

Instantly share code, notes, and snippets.

View pierrejoubert73's full-sized avatar
💭
Moved over to a private GitLab

Pierre Joubert pierrejoubert73

💭
Moved over to a private GitLab
View GitHub Profile
@pierrejoubert73
pierrejoubert73 / commit-hook-intro.md
Last active January 23, 2024 15:07
How to add a git commit hook
View commit-hook-intro.md

Git Hooks - A very basic guide

The aim of this guide is to create the basic idea of how to set up a very basic hook. Once you've read through this guide, please read through the Git Hooks Documentation. But first...

What is a Git Hook?

In very basic terms, it's a thing that "fires off custom scripts when certain important actions occur". For example, each time we make a commit, a git hook will run some code that does some cool stuff automatically. Because sometimes we want stuff to happen automatically and Git Hooks help us do that!

Give me an example!

Oh, sure. Imagine a conversation between you and your supervisor that goes like this:

@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active February 27, 2024 15:59
How to add a collapsible section in markdown.
View markdown-details-collapsible.md

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@pierrejoubert73
pierrejoubert73 / get-file-list.js
Created June 29, 2017 10:36
Get the list of files uploaded.
View get-file-list.js
var fileList = $("#comment-attachment").get(0).files;
@pierrejoubert73
pierrejoubert73 / file-check.html
Last active July 17, 2022 22:58
JS file upload.
View file-check.html
<script>
var form = $('#attach-local-doc-form');
/*
* Note that variable `data` will not show anything due to hidden properties.
* It's purpose is to be passed to the server for parsing.
*/
var data = new FormData(form.get(0));
var fileNames = documentData.getAll("userfile").map(function (file) {
return file.name;
});
@pierrejoubert73
pierrejoubert73 / psql-import-db-dump.md
Last active January 4, 2023 11:08
How to import a dump file in PSQL.
View psql-import-db-dump.md

Open terminal.

Connect to psql:

psql -p 5433

I find it easier to delete and recreate the DB to which you want to import. So ensure the databse you want to delete is listed:

\l

@pierrejoubert73
pierrejoubert73 / enums.sql
Last active November 21, 2016 12:43
How to view and alter enumerated types in PostgeSQL.
View enums.sql
-- To view all values in the enum:
SELECT unnest(enum_range(NULL::schema.enum_name));
-- To add a value to the enum:
ALTER TYPE schema.enum_name ADD VALUE 'new_enum_value';
-- For more operation see: https://www.postgresql.org/docs/9.1/static/sql-altertype.html
@pierrejoubert73
pierrejoubert73 / array_agg_example.sql
Last active July 17, 2022 23:00
An example of using the array_agg() PostgreSQL function.
View array_agg_example.sql
select
pc_games.title,
to_char(pc_games.release_date, 'YYYY-MM-DD') as release_date
array_to_string(array_agg(avid_fans.firstname || ' ' || avid_fans.surname), ', ', null) as fans
from
schema_A.pc_games as pc_games
inner join schema_A.avid_fans as avid_fans on (pc_games.id = avid_fans.fk_pc_game_id)
where
pc_games.release_date > '2004-12-31'
group by
@pierrejoubert73
pierrejoubert73 / arrayOfFunctions.php
Last active October 14, 2016 08:43
How to dynamically call functions with x amount of parameters.
View arrayOfFunctions.php
<?php
$results = array();
# The "$selected_functions" array will be constructed on the client side and posted to the PHP controller function.
# Populate the "$selected_functions" array based on user interaction with the UI.
$selected_functions = array(
"function_1" => array("parameter_1_1", "parameter_1_2", "parameter_1_3"),
"function_2" => array("parameter_2_1"),
@pierrejoubert73
pierrejoubert73 / ng-class-multiple.js
Created October 12, 2016 10:38
How to add multiple classes and expressions to the ng-class attribute.
View ng-class-multiple.js
<span class="label" ng-class="{'possibleValue1' : 'class1', 'possibleValue2' : 'class2', 'possibleValue3' : 'class3'}[object.value]" ng-bind-html='object.value'></span>