Skip to content

Instantly share code, notes, and snippets.

😌

Iulia Maria Lungu iuliaL

😌
Block or report user

Report or block iuliaL

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View palindromeCheck.elm
transformer word =
String.toLower word
|> String.split " "
|> String.join ""
|> String.filter (\char -> char /= ',')
palindrome w = transformer w == (String.reverse <| transformer w)
isPalindrome = if palindrome "As I pee sir, I see Pisa " == True then "PALINDROME" else "NOT PALINDROME"
@iuliaL
iuliaL / snippet.tsx
Last active Sep 5, 2019
redux-loop Cmd.map()
View snippet.tsx
// from a navigation view
function reducer(
state: State,
action: Action
): [State, reduxLoop.CmdType<Action>] {
switch (action.type) {
case "INIT OPERATOR VIEW": {
const newState: State = {
...state,
page: {
@iuliaL
iuliaL / excelFilterRegEx.md
Created Jul 15, 2019
excel filter formula
View excelFilterRegEx.md

=filter(A:B, (regexmatch(B:B, " an.")) + (regexmatch(B:B, "/ an")) + (regexmatch(B:B, "/an")) + (regexmatch(B:B, " an ")) + (regexmatch(B:B, "an)")))

=filter(A:B, regexmatch(B:B, "[\W|\s]an[\W|\s]*"))

View isMatchingBrackets.js
function isMatchingBrackets(str) {
let stack = [];
const map = {
'(': ')',
'[': ']',
'{': '}'
};
let answer = false;
for (let c of [...str]) {
@iuliaL
iuliaL / day1-advent-of-code.py
Last active Dec 8, 2018
advent of code day 1
View day1-advent-of-code.py
import datetime
input = "+15 -7 +16 +5 +12 +16 -4 +10 -1 +14 -16 +6 +4 +11 -2 +5 +4 +12 +13 +5 +16 +18 -3 -2 +9 -10 +12 -10 -17 +12 -14 -14 +11 +1 -16 +11 -5 +20 -1 +14 -15 -10 -5 +4 -17 -13 -2 -12 -15 +12 +8 -3 +13 +17 +21 +21 +8 +9 -5 -15 -19 -9 -17 -5 +15 +12 +14 +19 -2 +15 -6 +19 -2 +4 -5 -8 -4 +10 +1 -5 +10 +12 +14 -2 +11 -3 -15 -6 +14 +3 +8 +10 +14 +11 +18 +3 -4 -5 -13 +17 -12 -8 -5 +7 +7 -10 -19 +17 +1 +17 -5 -9 -10 -9 -1 -3 -14 +11 +1 +11 +1 +2 -17 +4 +19 +17 +6 +18 -4 +3 -13 +7 -3 +19 +5 +2 +6 +12 +5 -7 +10 +16 -9 -16 +11 +10 +2 +7 -16 +6 +16 +17 +11 +11 -14 +11 -16 -13 +6 +8 +10 -4 -5 +2 +5 -18 +19 -11 -5 -5 -5 -16 -5 +16 +7 -10 -20 -14 -18 +13 +9 -10 +18 -7 -8 -4 +13 +9 +18 +20 -10 -14 -22 -21 -10 +20 -7 -9 +1 +11 +6 +12 +14 -5 +16 +13 +8 -2 -13 -2 +11 +21 +9 -5 +1 +18 +6 +18 -17 +3 +7 -2 -3 +1 +7 +17 +16 +4 +13 +7 +17 -18 +17 +2 +19 -11 +2 +2 +1 -16 -19 -4 -17 -8 -5 +12 -8 +19 +3 +17 +3 +3 +8 +3 -13 +12 -7 +9 +16 +15 +3 -6 -10 +14 -13 -8 +4 +12 +19 +17 +18 -12 -11 +7 -1 -7 -28 -19 -6 +2 +15 +3 -1
@iuliaL
iuliaL / react-font-face.tsx
Created May 4, 2018
react-font-face rewritten in typescript
View react-font-face.tsx
import * as React from 'react';
import { Helmet } from 'react-helmet';
import { Maybe } from 'tsmonad';
export {
ReactFontFace as OurReactFontFace
};
interface Config {
readonly google?: ReadonlyArray<string>;
@iuliaL
iuliaL / duration.ts
Last active Mar 28, 2018
Duration or time elapsed formatter using moment js (i.e 34 hours and 5 minutes, 1 hour 1 minute)
View duration.ts
function getDuration(startTime: Date, endTime: Date): string {
const milliseconds = moment(endTime).diff(startTime);
const duration = moment.duration(milliseconds);
const durationAsHours: number = Math.floor(duration.asHours());
const restInMinutes: number = duration.minutes();
const hours: string =
durationAsHours > 1
? `${durationAsHours} hours and `
: durationAsHours > 0
? `${durationAsHours} hour and `
View momentToLocalAndbackToUTC.js
const moment = require('moment');
const dateFromElastic = 1521806390519;
let dateUTC = moment.utc(dateFromElastic).format('YYYY-MM-DD HH:mm');
// for interface display
let dateLocal = moment.utc(dateUTC).local().format('YYYY-MM-DD HH:mm');
// for timeFilter to use as query
let dateBackToUTC = moment(dateLocal).utc().format('YYYY-MM-DD HH:mm');
View gist:03abfd3a9752a972ca03a06c72b54c4b
function splitArrayInArraysBySection (arr) {
const returnsObject = arr.reduce((newArrSofar, item) => {
const toAdd = newArrSofar[item.section] ? [...newArrSofar[item.section], item] : [item]
return {
...newArrSofar,
[item.section]: toAdd
}
},{});
return Object.values(returnsObject); // to return array actually
}
@iuliaL
iuliaL / .bash_profile
Last active Jan 9, 2018
Append git branch name to prompt (only) when in git repository
View .bash_profile
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\[\033[32m\]\w\[\033[33m\]\$(git_branch)\[\033[00m\]\$ "
You can’t perform that action at this time.