Skip to content

Instantly share code, notes, and snippets.

View ahmad-moussawi's full-sized avatar
🎹
Playing 🎶

Ahmad Moussawi ahmad-moussawi

🎹
Playing 🎶
View GitHub Profile
function checkIp() {
/**
* Deny if not from the following IPs
*
*/
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
<?php
class Permission
{
static $dictionaryPath = 'clients.php';
/**
* Check if the clientId exists in the dictionary
* @param $clientId
<?php
class News extends Eloquent{
public function scopeLang($query)
{
return $query->where('LocalString.lang', LANG);
}
Byblos API enhancements
=======================
## Version
The version of the API should be included in the base URL of the API precedeed with the letter v
e.g. `//myapi.com/v1/accounts`
## Naming
### Use names for resources and verbs for actions
Provide sensible **names** for the applications resources
@ahmad-moussawi
ahmad-moussawi / index.html
Created June 16, 2014 10:32
angular dropzone uploader
<div ng-show="!item.edit">
<div ng-if="item.row.logo" >
<img ng-src="uploads/mdpi/{{item.row.logo}}" style="max-width: 80px;"/>
</div>
<div ng-if="!item.row.logo"><i>No image selected</i></div>
</div>
<div class="dropzone">
@ahmad-moussawi
ahmad-moussawi / create_db_user.sql
Created April 4, 2015 06:47
SQL Server Create Login with User
-- create a user myUser with myPassword and assign it to myDb
USE [master]
GO
-- Delete existing login.
IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'myUser')
DROP LOGIN [myUser]
GO
<?php
$i = 0;
$col = 5; // number of items per row
$width = 100/ $count;
$count = count($items)
?>
<div class="white-box gallery">
<?php foreach($items as $item): ?>
<?php if($i % $col === 0): ?>
@ahmad-moussawi
ahmad-moussawi / HomeController.cs
Created May 18, 2016 10:17
A view Render for Razor (aspnetcore RC2)
public class HomeController : Controller {
private readonly ViewRender view;
public HomeController (ViewRender view) {
this.view = view
}
public string Test () {
// render ~/Views/Emails/ResetCode
@ahmad-moussawi
ahmad-moussawi / sign.sh
Created November 29, 2017 14:15 — forked from ezimuel/sign.sh
Sign and verify a file using OpenSSL command line tool. It exports the digital signature in Base64 format.
#!/bin/bash
# Sign a file with a private key using OpenSSL
# Encode the signature in Base64 format
#
# Usage: sign <file> <private_key>
#
# NOTE: to generate a public/private key use the following commands:
#
# openssl genrsa -aes128 -passout pass:<passphrase> -out private.pem 2048
# openssl rsa -in private.pem -passin pass:<passphrase> -pubout -out public.pem
@ahmad-moussawi
ahmad-moussawi / $namedRoute.js
Created May 13, 2018 08:12 — forked from stakach/$namedRoute.js
Augments AngularJS $route provider with route naming.
(function(angular) {
'use strict';
/*
Usage:
-----
FILE --app.js--