Skip to content

Instantly share code, notes, and snippets.

View nilesolutions's full-sized avatar

Ahmed Samy nilesolutions

  • Abu dhabi
View GitHub Profile
@nilesolutions
nilesolutions / index.js
Created October 25, 2019 08:28 — forked from kingkool68/index.js
AWS Lambda Function for Proxying Requests to S3
/**
* This is a simple AWS Lambda function that will look for a given file on S3 and return it
* passing along all of the headers of the S3 file. To make this available via a URL use
* API Gateway with an AWS Lambda Proxy Integration.
*
* Set the S3_REGION and S3_BUCKET global parameters in AWS Lambda
* Make sure the Lambda function is passed an object with `{ pathParameters : { proxy: 'path/to/file.jpg' } }` set
*/
var AWS = require('aws-sdk');
@nilesolutions
nilesolutions / example.js
Created September 19, 2019 13:43 — forked from na0AaooQ/example.js
AWS LambdaでAmazon RDS for MySQLへ接続する(Node.js 4.3 + KMSで暗号化したMySQL接続パスワードをkms.decryptで復号化してMySQLヘ接続 + バッチ実行をSNS通知する) ref: http://qiita.com/na0AaooQ/items/ff9ab6ce9831236b3ea6
var AWS = require('aws-sdk');
var mysql = require('mysql');
// KMSにより暗号化したMySQL接続用のパスワード文字列
var kmsEncyptedToken = "CiC*********(KMSで暗号化したMySQL接続用のパスワード文字列)***********UI=";
// 接続先のMySQLサーバ情報
var mysql_host = "example-rds-mysql-server.carvmoii2uds.ap-northeast-1.rds.amazonaws.com";
var mysql_user = "example_user";
var mysql_dbname = "exampledb";
@nilesolutions
nilesolutions / lazyload.html
Created September 5, 2019 20:27 — forked from addyosmani/lazyload.html
Native image lazy-loading with a cross-browser fallback
<img data-src="unicorn.jpg" loading="lazy" alt=".." class="lazyload"/>
<script>
// Select all images with the class "lazyload"
const images = document.querySelectorAll("img.lazyload");
// Check if the browser supports the "loading" attribute
if ('loading' in HTMLImageElement.prototype) {
// If so, we'll update all <img src> to point to the data-src instead
images.forEach(img => {
img.src = img.dataset.src;
@nilesolutions
nilesolutions / s3-dropzone-upload.php
Created May 28, 2019 21:39 — forked from mmoehrlein/s3-dropzone-upload.php
s3 upload with dropzone.js
<?php
// AWS data
$bucketName = "BUCKET-NAME";
$AWSAccessKeyId = "XXXXXXXXXXXXXXXXXXXX";
$AWSSecretAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$date = date("Y-m-d");
$dateISO = date("Ymd");
$validTill = date('Y-m-d\TH:i:s.000\Z', time() + (60 * 60 * 4)); // 4 hours

Website Contract [month] [year]

Description of this Contract

This contract is not meant to trick or deceive you; the intention is purely to protect both parties. I have tried to keep the wording as plain as possible, but if anything is unclear, please let me know and I will be more than happy to clarify it with you. Also, until you sign it, please feel free to request to change bits of it to suit your requirements.

In short, [client name] is contracting me, [my name], to [description of my role] between [start date and finish date].

By signing this, you are confirming that you have the power and ability to enter into this contract on behalf of [client's company].

@nilesolutions
nilesolutions / autofill.php
Created February 26, 2019 09:07 — forked from jubstuff/autofill.php
Wrap text in imagick
<?php
/**
* Auto Fit Text To Image
*
* Write text to image using a target width, height, and starting font size.
*
* @author Clif Griffin
* @url http://cgd.io/2014/auto-fit-text-to-an-image-with-php-and-wordpress
*
@nilesolutions
nilesolutions / readme.md
Created February 12, 2019 09:41 — forked from Niteshvgupta/readme.md
Install PHP7-compatible memcache on Mac OS X

1. Install PHP7 with brew

brew install php70

2. Install Memcache from source on PHP7 branch

git clone -b NON_BLOCKING_IO_php7 https://github.com/websupport-sk/pecl-memcache.git
cd pecl-memcache
phpize
./configure
make &amp;&amp; make install
@nilesolutions
nilesolutions / ImageResizer.php
Created January 27, 2019 06:20 — forked from localdisk/ImageResizer.php
Image Resize GD and Imagick
<?php
namespace localdisk;
use localdisk\Bench;
class ImageResizer
{
const SRC = './src.jpg';

AWS IAM Policy for flysystem-adapter-s3-v3

You can copy AWS IAM policy below to secure the access of your AWS S3 bucket when using S3 Adapter of Flysystem

{
    "Version": "2012-10-17",
    "Statement": [
 {
@nilesolutions
nilesolutions / optimize.php
Created December 24, 2018 09:51 — forked from fians/optimize.php
Optimize Image in PHP using Imagick according Google Pagespeed Recommendation
/**
* Optimize image image
*
* https://developers.google.com/speed/docs/insights/OptimizeImages
* -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace sRGB
*
* @access public
* @param string $filePath Path of the file
* @return string Raw image result from the process
*/