Skip to content

Instantly share code, notes, and snippets.

View AhmadMansour's full-sized avatar
☝️
الحمد لله

Ahmad Mansour AhmadMansour

☝️
الحمد لله
View GitHub Profile
@mie00
mie00 / cnc.bash
Last active April 14, 2019 04:23
Check internet connection script
#!/bin/bash
export COLOR_NC='\e[0m'
export COLOR_GREEN='\e[0;32m'
export COLOR_RED='\e[0;31m'
export INTERFACE='wlp3s0'
if [ "`nmcli networking`" == "enabled" ]; then
printf "${COLOR_GREEN}networking enabled${COLOR_NC}\n"
else
@qti3e
qti3e / README.md
Last active January 12, 2026 15:29
List of file signatures and mime types based on file extensions
@Alexlambertz
Alexlambertz / app.js
Created November 20, 2016 13:07
ngTreant - Simple Angular JS wrapper for Treant.js
var app = angular.module("app", ["ngTreant"]);
angular.module('ngTreant', [])
.directive('treantGraph', function () {
return {
restrict: 'E',
scope: {
data: '=data'
},
template: '<div class="chart" id="example-graph"></div>',
@smeijer
smeijer / parse-es6-template.js
Last active October 26, 2024 03:15
ES6 template string parser
function get(path, obj, fb = `$\{${path}}`) {
return path.split('.').reduce((res, key) => res[key] || fb, obj);
}
function parseTpl(template, map, fallback) {
return template.replace(/\$\{.+?}/g, (match) => {
const path = match.substr(2, match.length - 3).trim();
return get(path, map, fallback);
});
}
@Marsup
Marsup / CustomError.js
Last active January 16, 2019 22:12
Custom error with cross browser support
const CustomError = function CustomError() {
if (Error.captureStackTrace) { // Chrome
Error.captureStackTrace(this, CustomError);
} else {
const err = new Error();
let processedStack, fileName, lineNumber;
Object.defineProperties(this, {
stack: {
get: function() {
@stefanwalther
stefanwalther / Enum.es6.js
Created October 16, 2015 15:08 — forked from xmlking/Enum.es6.js
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@Yimiprod
Yimiprod / difference.js
Last active August 7, 2025 14:25
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
/**
* Produces a function which uses template strings to do simple interpolation from objects.
*
* Usage:
* var makeMeKing = generateTemplateString('${name} is now the king of ${country}!');
*
* console.log(makeMeKing({ name: 'Bryan', country: 'Scotland'}));
* // Logs 'Bryan is now the king of Scotland!'
*/
var generateTemplateString = (function(){
@WebReflection
WebReflection / String.prototype.template.js
Last active August 17, 2022 04:04
ES6 Template like strings in ES3 compatible syntax.
// this is now a module:
// https://github.com/WebReflection/backtick-template#es2015-backticks-for-es3-engines--
var template = require('backtick-template');
// just string
const info = 'template';
`some ${info}` === template('some ${info}', {info});
@ismaels
ismaels / polyline_decoder.js
Created September 20, 2013 12:50
Javascript function to decode google maps api polyline
// source: http://doublespringlabs.blogspot.com.br/2012/11/decoding-polylines-from-google-maps.html
function decode(encoded){
// array that holds the points
var points=[ ]
var index = 0, len = encoded.length;
var lat = 0, lng = 0;
while (index < len) {
var b, shift = 0, result = 0;