Skip to content

Instantly share code, notes, and snippets.

😶
Why do we need this feature?

Jonathan IgnusG

😶
Why do we need this feature?
Block or report user

Report or block IgnusG

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
@IgnusG
IgnusG / validations.js
Last active Oct 8, 2018
Playing around with string templates in JS (for validation)
View validations.js
const isArray = (o) => o.map !== undefined;
const generateValidation = (string, ...validationLiterals) => {
const [ head, ...strings ] = isArray(string) ? string : [string];
return (...validationArg) => {
const validationResults = validationLiterals.map((validation) => validation(...validationArg));
if (validationResults.every((e) => e === null)) {
return { valid: true };
}
@IgnusG
IgnusG / parks&rec.md
Created Jul 31, 2018
My favorite quotes from Parks and Rec
View parks&rec.md

Best Quotes

  • Which one citizen described as "Disturbingly Enticing"
  • That's my husband. ... Who's he carying?
  • Either you hire her back or I quit! ... You don't work for me
  • You couldn't remember your phone number. But you gave me your phone
  • You're trying to lure this young lady into your van? ... Yeah?! But she's being really difficult about it
  • Greg, your service is crap.
  • You forgot to paint a painting son
  • You can wait at that table and someone will be here sometime. ... But aren't you here now? ... No
@IgnusG
IgnusG / books.md
Last active Jul 12, 2019
Books to Read
View books.md
  • The Art of War
  • How to talk TED
  • Debt: years
  • Start with Why?
  • Leaders eat last
  • Aufm Weg zur finanzieller Freiheit
  • Adversaries into allies (Bob Burg)
@IgnusG
IgnusG / git-superfixup.pl
Created Apr 8, 2018 — forked from oktal3700/git-superfixup.pl
Perl script for automating the process of creating fixup! commits for use with git rebase -i --autosquash
View git-superfixup.pl
#!/usr/bin/perl
# Scan unstaged changes in git tracked files, identify which commits they could
# be applied to as fixups, and automatically produce the appropriate "fixup!"
# commits for use with "git rebase -i --autosquash".
#
# Copyright (C) 2016, 2017 by Mat Sutcliffe
# This program is free software; you can redistribute it and/or modify it under
# the GNU General Public License as published by the Free Software Foundation;
# either version 2 of the License, or (at your option) any later version.
@IgnusG
IgnusG / order_by_array.rb
Last active Feb 23, 2018
Orders one array according to another array
View order_by_array.rb
objects = []
order = %w(first second)
objects
.group_by(&:order_by_this) # Create grouping according to field
.each { |_, h| h.sort_by!(&:sort_each_by_this).reverse! } # Each hash sorted individually
.values_at(*order) # Sorting according to order
.compact # Reject empty hash keys (no elements for order item)
.flatten(1) # Remove hash table
.concat(objects.reject { |o| order.include? o.order_by_this }) # Append all unidentified at the end
View detectSeparator.js
function detectSeparator(input) {
const availableSeparators = [ ';', ',', '|' ];
const separatorCount = availableSeparators.map((separator) => occurrences(input, separator));
return R.transpose([ availableSeparators, separatorCount ])
.reduce((maxSeparator, separator) => {
return separator[1] > maxSeparator[1] ? separator : maxSeparator;
}, [ availableSeparators[0], -1 ])[0];
}
View fizzbuzz.js
function isMultipleOfThenSay(x, say) {
return (i) => i % x == 0 ? say : '';
}
// The order matters. Any function with the signature (any)->(int)->str is valid
const whatShouldISay = [
isMultipleOfThenSay(3, 'Fizz'),
isMultipleOfThenSay(5, 'Buzz')
];
View maintainable-css.md
View webstorm-keyboard.md

Closing & Opening

Action Keyboard Shortcut
Close Ctrl + F4
Close Others Alt + Shift + F4
Close All Ctrl + Alt + Shift + F4
Close Unmodified Alt + F4
Reopen Ctrl + Shift + T
@IgnusG
IgnusG / context-loader.js
Last active Sep 6, 2016
Modifies context of imports. Should be called before whatever compiles the imports
View context-loader.js
const fs = require('fs');
const requirePatterns = [
/(import.*from\W*)(?:(')(.*)(?!\/)'|(")(.*)(?!\/)")(.*)/g,
/(require\W*\()(?:(')(.*)(?!\/)'|(")(.*)(?!\/)")(.*)/g
];
const extension = '.ts';
function decodeOption(key, value) {
switch (key) {
You can’t perform that action at this time.