Skip to content

Instantly share code, notes, and snippets.

View MissaouiChedy's full-sized avatar

Chedy Missaoui MissaouiChedy

View GitHub Profile
configuration config {
Import-DSCResource -module "nx"
Node localhost {
nxFile content
{
DestinationPath = "/home/chedy/content.txt"
Mode = "644"
Type = "file"
Contents = "KABLAM!"
public override bool Equals(object obj)
{
if (obj.GetType() == typeof(FingerPrint))
{
FingerPrint other = obj as FingerPrint;
return GetType()
.GetProperties()
.Aggregate(true, (acc, p) =>
{
var val = p.GetValue(this);
defmodule Solution do
def get_stream_of_duplicated_evens() do
Stream.iterate(2, &(&1+2))
|> Stream.flat_map(&List.duplicate(&1, 4))
end
def get_result_list(n) do
Enum.take(get_stream_of_duplicated_evens, n)
|> get_result_list([1])
end
//file: main.js
import {Vegetable} from "./mylib"
//alternatively
import * as mylib from "./mylib"
let vegi = new Vegetable();
...
//file: mylib.js
export class Vegetable {
...
}
export function increment(n) {
...
}
function format(n) {
let numbers = [1, 2, 3];
// a = 1, b = 2, c = 3
let [a, b, c] = numbers;
let obj = {name: 'Michael', lastName: 'Kael'};
// n = 'Michael', ln = 'Kael'
let {name: n, lastName: ln} = obj;
let numbers = [1, 2, 3, 4, 5, 6, 7, 8];
// returns [2, 3, 4, 5, 6, 7, 8, 9]
let incremented = numbers.map((n) => (n + 1));
console.log(incremented);
//returns [4, 5, 6, 7, 8]
let filtered = numbers.filter((n) => (n > 3));
console.log(filtered);
let numbers = [1, 2, 3, 4, 5];
for (let n of numbers) {
console.log(n);
}
class Person {
constructor(name) {
this._name = name;
}
set name(newName) { this._name = newName; }
get name() { return this._name; }
say_hello() {
console.log(`Hi my name is ${this._name}!`);
(0..16)
|> Enum.reduce({[1], 0}, fn counter, {[h | _] = result, incr} ->
incr = if rem(counter, 4) == 0, do: incr + 2, else: incr
{[h + incr | result], incr}
end)
|> elem(0)
|> Enum.reverse