Skip to content

Instantly share code, notes, and snippets.

@r-aamir
r-aamir / icu-install.sh
Created September 19, 2018 14:15 — forked from aminin/icu-install.sh
Install ICU from source and build php-intl with the specific version of ICU
#!/usr/bin/env bash
if [[ -x $(which php) ]]; then
PHP_ICU_VERSION=$(php -r 'echo defined("INTL_ICU_VERSION") ? INTL_ICU_VERSION : "none";')
echo "PHP ICU version: $PHP_ICU_VERSION"
else
echo 'WARNING: PHP not installed'
PHP_ICU_VERSION=none
fi
@r-aamir
r-aamir / media-query.css
Created October 25, 2018 11:48 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@r-aamir
r-aamir / CustomAnnotationView.h
Last active February 2, 2019 10:45
MKMapKit annotation clustering in Objective-C
#import <MapKit/MapKit.h>
@interface CustomAnnotationView : MKMarkerAnnotationView
- (id) initWithAnnotationWithImage:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier annotationViewImage:(UIImage *)annotViewImage;
@end
@r-aamir
r-aamir / Playground.swift
Created June 1, 2019 11:24
NSAttributedString from HTML: Add different font sizes for title and description https://stackoverflow.com/questions/56404650
import UIKit
import PlaygroundSupport
extension UIFont {
func cssStyle(selector: String, otherStyles styles: String = "") -> String {
return "\(selector){font-family:\(fontName);font-size:\(Int(pointSize));\(styles)}"
}
}
let text = "<span class=heading>Stackoverflow</span> is launched in 2008, it currently has 231,083 Swift questions out of 52,499,188 total."
@r-aamir
r-aamir / terser.js
Created July 13, 2019 17:03 — forked from jrschumacher/terser.js
A terser script to minify all javascript files in a directory
const fs = require('fs')
const {sync: globSync} = require('glob')
const filesize = require('filesize')
const Terser = require('terser')
const options = require(process.env.TERSER_CONFIG || './terserrc.json')
const getSize = (file) => {
const {size} = fs.statSync(file)
return filesize(size)
}
@r-aamir
r-aamir / webpack.config.js
Created July 13, 2019 21:12 — forked from dkarandana/webpack.config.js
Webpack Config
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const EntryList = require('./weback.entrylist');
const IS_PROD = (process.env.NODE_ENV === 'prod') ? true : false;
/* output path */
const OUT_DIR_ABS = path.resolve('./dist');
@r-aamir
r-aamir / amazon-linux2-userdata
Created August 3, 2021 18:25 — forked from Ammly/amazon-linux2-userdata
Amazon Linux 2 Laravel, Nginx, PHP7.4, Mariadb Userdata
#!/bin/sh
sudo yum update -y
sudo amazon-linux-extras install nginx1 php7.4 -y
sudo yum clean metadata
sudo yum install git mariadb-server php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip} -y
# Back up existing config
sudo cp -R /etc/nginx /etc/nginx-backup
sudo chmod -R 777 /var/log
sudo chown -R ec2-user:ec2-user /usr/share/nginx/html
echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/index.php
@r-aamir
r-aamir / le2018.md
Created August 30, 2021 01:04 — forked from someburner/le2018.md
Let's Encrypt + wildcards for Nginx (Ubuntu 17.10, IPv6, HTTP/2, Proxy-Pass, SLL Rating=A)

Let's Encrypt for Nginx on Ubuntu 17.10, 18.04 with wildcards

Guide info:

  • we're setting up mydomain.com, *.mydomain.com
  • HTML is served from /var/www/mydomain
  • Challenges are served from /var/www/letsencrypt.
  • As of this writing, SSL Labs gives it an A+
  • Took info from here and here on wilcard certs.

Auto-renewal

@r-aamir
r-aamir / CSP.md
Created October 14, 2021 12:49 — forked from corburn/CSP.md
Nginx server notes

The following is from scotthelme.co.uk

Content Security Policy

with Content Security Policy (CSP) enabled(and a browser that supports it(http://caniuse.com/#feat=contentsecuritypolicy), you can tell the browser that it can only download content from the domains you explicitly allow http://www.html5rocks.com/en/tutorials/security/content-security-policy/ https://www.owasp.org/index.php/Content_Security_Policy I need to change our application code so we can increase security by disabling 'unsafe-inline' 'unsafe-eval'

@r-aamir
r-aamir / nginx-csp-security.conf
Created October 14, 2021 12:54 — forked from mikeg-de/nginx-csp-security.conf
CSP definition for Nginx which leverages $server_name
# CSP definition for Nginx which leverages $server_name
# Purpose: One CSP-Header for all vhosts
# Installation
# Include this into each server directive in the nginx.conf
# Note
# Check out the script to send a Google Analytics Event and Email upon CSP violation is triggered
# https://github.com/mikeg-de/CSP-Violation-Google-Analytics-Email