Skip to content

Instantly share code, notes, and snippets.

View whitershade's full-sized avatar

Oleksandr Prokopenko whitershade

View GitHub Profile
@liberium
liberium / js-react-coding-rules.md
Created October 22, 2019 08:54
JS/React Coding rules

Module structure

ES module is a .js file with at least one export or folder containing index.js with at least one export.
The guiding module structure design principle is: you should imagine that any module might be extracted to its own package some day.

index.js of a module contains import-export statements only

In index.js we define a module interface, its exported object. This file should not contain business logic.
Placing business logic in index.js leads to following inconveniences, making code reading harder:

  • If components/Compo/index.js is opened in a tab in IDE, in many of them name of the tab would be "index.js", which is non-descriptive. There are addons in most IDEs that allow to show "Compo/index.js" instead of just "index.js" in tab name, but "Compo.js" is still more succinct yet descriptive.
@frgomes
frgomes / scala_base64_encode_decode.scala
Created July 28, 2017 12:39
Scala - Base64 encode/decode
// Base64 encode
val text = "This is plaintext."
val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes())
// Base64 decode
val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded))
println(textDecoded)
@workgena
workgena / cooke.js
Created October 2, 2015 10:27
cooke.js
/**
*
* Usage:
* Create/Update: Cookie.set("username", "John", 90);
* Read: Cookie.get("username");
* Destroy: Cookie.delete("username");
*
*/
var Cookie = {
set: function (name,value,days) {
@webdesign-masteru
webdesign-masteru / animate-css.js
Last active October 10, 2019 07:37
Animate CSS jQuery once animate
//Animate CSS + WayPoints javaScript Plugin
//Example: $(".element").animated("zoomInUp");
//Author URL: http://webdesign-master.ru
(function($) {
$.fn.animated = function(inEffect) {
$(this).css("opacity", "0").addClass("animated").waypoint(function(dir) {
if (dir === "down") {
$(this).addClass(inEffect).css("opacity", "1");
};
}, {