Skip to content

Instantly share code, notes, and snippets.

View HamedFathi's full-sized avatar
🌎

Hamed Fathi HamedFathi

🌎
View GitHub Profile
/* Attribution: http://techslides.com/how-to-parse-and-search-json-in-javascript */
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
@HamedFathi
HamedFathi / index.html
Created December 2, 2021 22:57 — forked from LucGranato/index.html
Monaco Editor Liquid Language
<div id="container" style="height:100%;"></div>
public class Result
{
public bool Success { get; private set; }
public string Error { get; private set; }
public bool Failure
{
get { return !Success; }
}
@HamedFathi
HamedFathi / ExpressionCombiner
Created November 13, 2021 21:44 — forked from janvanderhaegen/ExpressionCombiner
C# code to combine two lambda expressions
//Shoutout to MBoros on stackoverflow
public static class ExpressionCombiner {
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> exp, Expression<Func<T, bool>> newExp)
{
// get the visitor
var visitor = new ParameterUpdateVisitor(newExp.Parameters.First(), exp.Parameters.First());
// replace the parameter in the expression just created
newExp = visitor.Visit(newExp) as Expression<Func<T, bool>>;
// now you can and together the two expressions
using System;
namespace Dummy
{
class Program
{
private static void Header(string title)
{
Console.WriteLine(new string('=', 79));
Console.WriteLine(title);
@HamedFathi
HamedFathi / DynamicPermissionManagementEntities.cs
Created April 1, 2021 22:09 — forked from rabbal/DynamicPermissionManagementEntities.cs
Domain Entities for Dynamic Permissions Management
public abstract class Entity
{
public long Id { get; set; }
[SuppressMessage("ReSharper", "BaseObjectGetHashCodeCallInGetHashCode")]
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
public override int GetHashCode()
{
if (IsTransient())
return base.GetHashCode();
import { injectStyle } from 'styl-injector';
const rippleStyleObj = {
"[data-animation]": { position: "relative", overflow: "hidden" },
".ripple": {
width: "2px",
height: "2px",
position: "absolute",
borderRadius: "50%",
backgroundColor: "rgba(255, 255, 255, 0.5)",
function scrollUp(start?: Function, end?: Function) {
const el = (document.documentElement || document.body);
if (start) start();
el.scroll({
top: 0,
left: 0,
behavior: 'smooth'
});
if (end) end();
}
@HamedFathi
HamedFathi / index.html
Last active August 15, 2020 04:37
au2-config
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
</head>
<!--
Dumber Gist uses dumber bundler, the default bundle file
const postcss = require('postcss')
module.exports = {
theme: {
extend: {}
},
variants: {
float: ['responsive', 'rtl'],
margin: ['responsive', 'rtl'],
padding: ['responsive', 'rtl'],