Skip to content

Instantly share code, notes, and snippets.

View MohammadYounes's full-sized avatar
💭
I may be slow to respond.

Mohammad Younes MohammadYounes

💭
I may be slow to respond.
View GitHub Profile
@MohammadYounes
MohammadYounes / mozGetMatchedCSSRules.js
Last active June 29, 2021 11:31 — forked from darrnshn/mozGetMatchedCSSRules.js
A Blink only polyfill for Webkit's window.getMatchedCSSRules
// polyfill window.getMatchedCSSRules() in Chrome
if ( typeof window.getMatchedCSSRules !== 'function' ) {
var ELEMENT_RE = /[\w-]+/g,
ID_RE = /#[\w-]+/g,
CLASS_RE = /\.[\w-]+/g,
ATTR_RE = /\[[^\]]+\]/g,
// :not() pseudo-class does not add to specificity, but its content does as if it was outside it
PSEUDO_CLASSES_RE = /\:(?!not)[\w-]+(\(.*\))?/g,
PSEUDO_ELEMENTS_RE = /\:\:?(after|before|first-letter|first-line|selection)/g;
// convert an array-like object to array
@MohammadYounes
MohammadYounes / Font-Awesome-RTL.md
Last active January 9, 2023 08:16
Adding RTL support to font-awesome

You can control icons direction using the following CSS:

[dir=ltr].fa-dir-flip .fa.fa-flip-horizontal,
[dir=rtl].fa-dir-flip .fa,
[dir=rtl] .fa.fa-dir-flip {
  filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);
  -webkit-transform: scale(-1, 1);
      -ms-transform: scale(-1, 1);
          transform: scale(-1, 1);
@MohammadYounes
MohammadYounes / readme.md
Created December 26, 2015 11:51 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@MohammadYounes
MohammadYounes / npm-cheat-sheet.md
Created December 26, 2015 09:57 — forked from AvnerCohen/npm-cheat-sheet.md
Node.js - npm Cheat Sheet

Node.js - npm Cheat Sheet

(Full description and list of commands at - https://npmjs.org/doc/index.html)

##List of less common (however useful) NPM commands

######Prepand ./bin to your $PATH Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:

@MohammadYounes
MohammadYounes / ID.js
Created December 21, 2015 12:30
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@MohammadYounes
MohammadYounes / squash-commits.sh
Created December 13, 2015 14:14 — forked from jbub/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
function dataURItoBlob(dataURI, callback) {
// convert base64 to raw binary data held in a string
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
var byteString = atob(dataURI.split(',')[1]);
// separate out the mime component
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
// write the bytes of the string to an ArrayBuffer
var ab = new ArrayBuffer(byteString.length);
//Your ValuesController.cs
//Version 1
string uri = Url.Route("Default", new { controller="Home", action="MyAction", id = 1 });
string absoluteUrl = new Uri(Request.RequestUri, uri).AbsoluteUri;
//http://localhost/Home/MyAction/1
//Version 2
string uri = Url.Route("DefaultApi", new { id = 1 });
string absoluteUrl = new Uri(Request.RequestUri, uri).AbsoluteUri;