Skip to content

Instantly share code, notes, and snippets.

View codeepic's full-sized avatar

codeepic

View GitHub Profile
@codeepic
codeepic / README.md
Last active August 29, 2015 14:07 — forked from addyosmani/README.md

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@codeepic
codeepic / arrayFlattener.js
Last active November 16, 2018 16:36
Array Flattener in JS
var a = [[1,2,[3]],4, [5, [6, 7, [8, [9]]]]];
function flattenNestedArrays(arr){
var flattenedArray = [];
(function flattenArray(arr){
arr.forEach(function(item){
if(Array.isArray(item)){
flattenArray(item);
}else{
@codeepic
codeepic / two_invocations.js
Created April 12, 2016 16:35 — forked from PatrickJS/two_invocations.js
Write a function that adds from two invocations in JavaScript
function addf(x) {
return function(y) {
return x + y;
}
}
addf(3)(4)
-------------------------
[user]
email = ksaweryglab@gmail.com
name = codeepic
[alias]
a = add --all
s = status
c = commit -m
ca = commit --amend
co = checkout
p = push
constructor(
private route: ActivatedRoute,
private router: Router,
private dashboardService: DashboardService
){
super();
}
ngOnInit(){
let sub = this.route.params.subscribe(params => {
@codeepic
codeepic / index
Created September 1, 2017 14:32
Change values in Angular reactive form
this.form.setValue({search: ''}); //you have to provide all form controls
//OR
this.form.patchValue({search: ''}); //you can only provide 1 form control that you want to update
@codeepic
codeepic / FunctionalUtil.ts
Last active November 17, 2017 12:11
The FunctionalUtil class holds functional JavaScript helper methods.
export class FunctionalUtil{
static removeItem<T>(arr: T[], index: number): T[]{
return [
...arr.slice(0, index),
...arr.slice(index + 1)
];
}
static replaceItem<T>(arr: T[], item: T, index: number): T[]{

FWIW: I didn't produce the content present here. I've just copy-pasted it from somewhere over the Internet, but I cannot remember exactly the original source. I was also not able to find the author's name, so I cannot give him/her the proper credit.


Effective Engineer - Notes

What's an Effective Engineer?

@codeepic
codeepic / scroll-top-smooth.ts
Last active December 10, 2018 17:00
Scroll to top (smooth)
// https://stackoverflow.com/questions/15935318/smooth-scroll-to-top
// based on Gor answer
const scrollToTop = () => {
const c = document.documentElement.scrollTop || document.body.scrollTop;
if (c > 0) {
window.requestAnimationFrame(scrollToTop);
window.scrollTo(0, c - c / 8);
}
};
scrollToTop();