Skip to content

Instantly share code, notes, and snippets.

View geminorum's full-sized avatar
🏠
Working from home

Nasser Rafie geminorum

🏠
Working from home
View GitHub Profile
@geminorum
geminorum / languages.json
Created March 26, 2023 04:22 — forked from joshuabaker/languages.json
List of languages with ISO 639-1 Alpha-2 codes in JSON.
[
{
"code": "aa",
"name": "Afar",
"native": "Afar"
},
{
"code": "ab",
"name": "Abkhazian",
"native": "Аҧсуа"
@geminorum
geminorum / remove-message.js
Created January 2, 2020 18:15 — forked from simonw/remove-message.js
JavaScript one-liner for removing a ?message=... parameter from the visible URL in the browser
history.replaceState && history.replaceState(
null, '', location.pathname + location.search.replace(/[\?&]message=[^&]+/, '').replace(/^&/, '?')
);
@geminorum
geminorum / bootstrap-4-sass-mixins-cheat-sheet.scss
Created November 29, 2019 06:14 — forked from mattez/bootstrap-4-sass-mixins-cheat-sheet.scss
Bootstrap 4 Sass Mixins [Cheat sheet with examples] #BS4
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// @author http://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/v4-dev/scss/mixins
/* -------------------------------------------------------------------------- */
// Grid variables
$grid-columns: 12 !default;
$grid-gutter-width: 30px !default;
@geminorum
geminorum / Convert like-Persian characters to Persian characters
Created October 24, 2019 12:35 — forked from amirmojiry/Convert like-Persian characters to Persian characters
A PHP function for convert like-Persian characters to Persian characters
<?php
function convert_non_persian_chars_to_persian ($str) {
//main goal: arabic chars: from ؀ U+0600 (&#1536;) to ۿ U+06FF (&#1791;)
//source: https://unicode-table.com/en
$right_chars = array (
'ا',
'ب',
'پ',
'ت',
'ث',
@geminorum
geminorum / object_inheritance_function.js
Created October 18, 2019 06:54 — forked from kn9ts/object_inheritance_function.js
How jQuery's $.extend function works, a way for object to inherit other objects properties and functions
function extend(target_object) {
// Look for additional parameters in this function
// eg. extend(target_object, ....a,b,c,d)
if (!arguments[1]) {
return;
}
// If any extra arguments, which are objects
// loop through them
for (var index = 1; index < arguments.length; index++) {
@geminorum
geminorum / gist:a7789578f18754c2b8ddfb69e191abd6
Created January 10, 2019 00:22 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@geminorum
geminorum / numbred-sprintf.js
Last active October 10, 2017 23:30 — forked from rmariuzzo/sprintf.js
Javascript sprintf
// @SOURCE: https://stackoverflow.com/a/4673436/4864081
// First, checks if it isn't implemented yet.
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
@geminorum
geminorum / google_jsapi.php
Created November 27, 2016 22:10 — forked from franz-josef-kaiser/google_jsapi.php
WordPress plugin to add a Google Pie Charts / Visualization in a MetaBox.
<?php
namespace WPSE;
/** Plugin Name: Google JSAPI test plugin */
add_action( 'admin_enqueue_scripts', __NAMESPACE__.'\addScripts' );
function addScripts()
{
wp_enqueue_script(
@geminorum
geminorum / mail_with_attachments.php
Created May 23, 2016 09:24 — forked from m-manu/mail_with_attachments.php
PHP function to send e-mail with attachments
<?php
/*
Copyright (c) 2012, Manu Manjunath
All rights reserved.
Redistribution and use of this program in source/binary forms, with or without modification are permitted.
Link to this gist is preferred, but not a condition for redistribution/use.
*/
function mail_with_attachments($to, $subject, $message, Array $filepaths, $from = null, $replyto = null) {
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
return input.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){
if (index > 0 && index + match.length !== title.length &&
match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
title.charAt(index - 1).search(/[^\s-]/) < 0) {
return match.toLowerCase();
}