Skip to content

Instantly share code, notes, and snippets.

View meandmax's full-sized avatar
🤠
Be water my friend

Maximilian Heinz meandmax

🤠
Be water my friend
View GitHub Profile
@meandmax
meandmax / coffee_examples.coffee
Last active August 29, 2015 14:06
Coffee examples
# initializing the parent class with a value defined by the child class
class a
constructor: (valA = 1, valB = 2, valC = 3, valD = 'parent') ->
@func(valD)
func: (val) ->
console.log(val)
class b extends a
@meandmax
meandmax / increment.js
Created September 11, 2014 17:05
Try to find a generic way of incrementing a value without new assignments
// This doesn`t work, as val is a completly different value then count with own scope
var count = 0;
var increment = function(val){
val += 1;
}
increment(count);
console.log(count);
@meandmax
meandmax / getcookiebyname.js
Last active October 27, 2020 02:01
get the cookie value by name if a cookie name exists.
/**
* get cookie by name without using a regular expression
*/
var getCookie = function(name) {
var getCookieValues = function(cookie) {
var cookieArray = cookie.split('=');
return cookieArray[1].trim();
};
var getCookieNames = function(cookie) {
@meandmax
meandmax / gulpfile.js
Last active January 24, 2017 11:16
Gulpfile for collecting, minifying & linting frontend sources in special case.
/*!
* gulp
* $ npm install gulp gulp-rename gulp-replace gulp-browserify gulp-less gulp-csso gulp-uglify gulp-jshint gulp-coffeelint gulp-notify gulp-livereload gulp-sourcemaps gulp-concat coffeeify del jshint-stylish --save-dev
*/
var gulp = require('gulp');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var browserify = require('gulp-browserify');
var less = require('gulp-less');
@meandmax
meandmax / single-and-fat-arrow-functions.md
Last active February 2, 2021 08:09
Don’t use fat arrows in CoffeeScript just because of »this«

New Coffeescript programmers usually struggle with understanding the differences between -> and => function definitions. In order to clarify this common case of confusion, it helps to look at how such functions are compiled down to JavaScript.

class A

    constructor: () ->
        @funcA()
        @funcB()

 funcA: () ->
@meandmax
meandmax / add.js
Last active April 19, 2018 09:33
Add Rekursion
const add = (y) => {
return (x) => {
if (!x) {
return y;
}
return add(y + x);
}
}
@meandmax
meandmax / react-lifecycle-cheatsheet.md
Created October 2, 2018 06:36 — forked from bvaughn/react-lifecycle-cheatsheet.md
React lifecycle cheatsheet

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
@meandmax
meandmax / .gitconfig
Last active February 14, 2019 00:54 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Max Heinz
email = heinzmaximilian@gmail.com
username = meandmax
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[web]
browser = google-chrome