Skip to content

Instantly share code, notes, and snippets.

Mohamed Cherif Bouchelaghem cherifGsoul

Block or report user

Report or block cherifGsoul

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
@cherifGsoul
cherifGsoul / htmlentity.js
Created Dec 5, 2018 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
View htmlentity.js
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
@cherifGsoul
cherifGsoul / emojis.json
Created Dec 3, 2018 — forked from oliveratgithub/emojis.json
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
View emojis.json
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family_mothers_two_girls", "shortname": "", "unicode": "", "html": "👩‍👩‍👧‍👧", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family_mothers_children", "shortname": "", "unicode": "", "html": "👩‍👩‍👧‍👦", "category": "p", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family_mothers_two_boys", "shortname": "", "unicode": "", "html": "👩‍👩‍👦‍👦", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family_two_girls", "shortname": "", "unicode": "", "html": "👨‍👩‍👧‍👧", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👧‍👦", "name": "family_children", "shortname": "", "unicode": "", "html": "👨‍👩‍👧‍👦", "category": "p", "order": ""},
{"emoji": "👨‍👩‍👦‍👦", "name": "family_two_boys", "shortname": "", "unicode": "", "html": "👨&zw
@cherifGsoul
cherifGsoul / installvagrant
Created Oct 15, 2018 — forked from rrgrs/installvagrant
installs brew, virtualbox, and vagrant in osx
View installvagrant
if ! type "brew" > /dev/null; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)";
fi
brew tap phinze/homebrew-cask && brew install brew-cask;
brew cask install vagrant;
brew cask install virtualbox;
View can-util-replacements.md

can-util for can namespace

replaced by can-namespace

can-util/js/each/each

  • when looping on objects replaced by can-reflect.eachKey
  • when looping on lists/arrays replaced by can-reflect.each
  • can-reflect.eachKey has better performance

can-util/js/is-promise/is-promise

replaced by can-reflect.isPromise

@cherifGsoul
cherifGsoul / fp-lingo.md
Created May 3, 2018 — forked from ericelliott/fp-lingo.md
A Guide to Functional Programming Lingo for JavaScripters
View fp-lingo.md

A Guide to Functional Programming Lingo for JavaScripters

Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.

The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!

All examples using ES6 syntax. wrap (foo) => bar means:

function wrap (foo) {
View js-observables-binding.md

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5
setN(10);
@cherifGsoul
cherifGsoul / EmailAddress.php
Last active Mar 1, 2018
Value Object implementation pattern
View EmailAddress.php
<?php
class EmailAddress
{
/**
* Undocumented variable
*
* @var [type]
*/
private $address;
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>object creation</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@cherifGsoul
cherifGsoul / README.md
Created Dec 9, 2017 — forked from rrag/README.md
Yet another tutorial and Cheat sheet to Functional programming
View README.md

There are many tutorials and articles available online which explain functional programming. Examples show small functions, which are composed into others which again get composed. It is hard to imagine how it would all work, then come the analogies and then the math. While the math is necessary to understand it can be difficult to grasp initially. The analogies on the other hand, (at least for me) are not relatable. Some articles assume the reader knows the different terminologies of FP. Over all I felt it is not inviting to learn.

This introduction is for those who have had a tough time understanding those analogies, taken the plunge to functional programming but still have not been able to swim. This is yet another tutorial on functional programming

Terminology

Functions as first class citizens

Functions are first class means they are just like anyone else, or rather they are not special, they behave the same as say primitives or strings or objects.

@cherifGsoul
cherifGsoul / email-address.js
Last active Nov 26, 2017
Simple example for email Address value object
View email-address.js
var address;
var setAddress = function(address) {
/**
* @todo add validation here
*/
address = address;
};
function EmailAddress(anAddress) {
You can’t perform that action at this time.