Skip to content

Instantly share code, notes, and snippets.

View sinsunsan's full-sized avatar

Sébastien LUCAS sinsunsan

View GitHub Profile
@sinsunsan
sinsunsan / conditions-vs-switch.js
Created March 20, 2018 09:38
comparison of else-if vs switch style
// if / else if style (not very readable)
if (filter.status === 'closed') {
return _.isDate(topic.archived);
} else if (filter.status === 'opened') {
return !_.isDate(topic.archived);
} else {
return true;
}
// switch style more space the case are more identified
@sinsunsan
sinsunsan / typescript.example.ts
Created March 8, 2018 11:31
Typescript / Interface with a parameter type
// V is a type that can be passed as a parameter in the interface
// so in this case the V can be passed to customize the interface
interface EntityState<V> {
ids: string[] | number[];
entities: { [id: string | id: number]: V };
}
// https://platform.ultimateangular.com/courses/ngrx-store-effects/lectures/3788533
const character = { name: "Han Solo"};
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
// Do not work for deep clone
const characterUpdated = Object.assign({}, character, { function: "captain"});
const characterUpdatedAlt = {
...character,
function: "captain"
// Angular Ngrx lesson where I saw this code
// https://platform.ultimateangular.com/courses/ngrx-store-effects/lectures/3919399
// Documentation of Object keys function
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
const pizzas = { 1: {id: 1, name: 'marguerita'}, 2: { id: 2, name: 'valentina'}};
// parseInt is necessary because, Object.keys return the property as a string
// and our object porperties are in our example number
@sinsunsan
sinsunsan / array.reduce.example.ts
Last active March 8, 2018 10:20
array.reduce example
// Angular Ngrx lesson where I saw this code
// https://platform.ultimateangular.com/courses/ngrx-store-effects/lectures/3919399
// Documentation of array reduce function
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce
interface Pizza {
id: number;
name: string;
@sinsunsan
sinsunsan / visual-studio.windows.json
Created March 7, 2018 14:25
My visual studio preferences on windows
{
"editor.formatOnSave": false,
"beautify.tabSize": 2,
"sasslint.enable": true,
"editor.minimap.enabled": false,
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}
[vc_row]
[vc_column]
[qodef_call_to_action full_width="no" content_in_grid="yes" grid_size="75" type="normal" show_button="yes" button_link="https://bricks.typeform.com/to/Zx8q2D" button_type="solid" button_hover_animation="hover-animation" button_icon_pack="" color="#ffffff" background_color="#b2dd4c" button_text="Join Bricks Beta" border_color="#b2dd4c" hover_background_color="#282828"hover_border_color="#282828"]
<h4 style="color: #777777;">Want to try agile method with one of your architecture projects?</h4>
[/qodef_call_to_action]
[/vc_column]
[/vc_row]
@sinsunsan
sinsunsan / parametrized-jasmine-test.js
Created March 1, 2018 13:16
parametrized jasmine test / traduction of https://gist.github.com/basti1302/5051200 in javascript
describe("The suit", function() {
var parameterized;
beforeEach(function() {
return console.log('non-parameterized#beforeEach');
});
afterEach(function() {
return console.log('non-parameterized#afterEach');
});
it("should execute specs in the non-parameterized part", function() {
console.log('spec in non-parameterized');
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
@sinsunsan
sinsunsan / animation-on-accordion.scss
Last active December 8, 2017 10:20
To make a transition on a height, we need to use max-height and not height
.item-childrens {
transition: max-height 0.75s ease-in;
max-height: 0;
overflow: hidden; // To hide elements if item-childrens is a wrapper like in menu / sub-menus
&.item-childrens-opened {
max-height: 1000000px;
transition: max-height 0.75s ease-out;
}
}