Skip to content

Instantly share code, notes, and snippets.

View sesn's full-sized avatar
🏠
Working from home

Sankar sesn

🏠
Working from home
View GitHub Profile
@sesn
sesn / ImageMagick-6.7.7-10.md
Created June 22, 2020 20:19 — forked from ahmadhasankhan/ImageMagick-6.7.7-10.md
Install ImageMagick 6.7.7-10 on Unix using binary

Remove imagemagick

sudo apt-get --purge remove imagemagick
sudo apt autoremove

Install Required package:

sudo apt-get install build-essential 
sudo apt-get install checkinstall
const config = require('config');
const AWS = require('aws-sdk');
const fs = require('fs');
const path = require('path');
AWS.config.region = config.get('textract').region;
AWS.config.credentials = new AWS.Credentials(config.get('s3'));
const awsTextract = new AWS.Textract();
@sesn
sesn / nginx device redirect
Created September 26, 2018 14:28 — forked from mariusom/nginx device redirect
Nginx detecting desktop, tablet or mobile by looking tat the http user agent.
# Source: http://detectmobilebrowsers.com/
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|t
@sesn
sesn / example-ajax-enqueue.php
Created August 6, 2018 15:47 — forked from devinsays/example-ajax-enqueue.php
Simple WordPress Ajax Example
<?php
function example_ajax_enqueue() {
// Enqueue javascript on the frontend.
wp_enqueue_script(
'example-ajax-script',
get_template_directory_uri() . '/js/simple-ajax-example.js',
array('jquery')
);
@sesn
sesn / Contact Form 7: validation.css
Created July 14, 2018 08:16 — forked from landru247/Contact Form 7: validation.css
Contact Form 7: validation - removes the error/success message and removes the default field validation and replaces with colored fields
div.wpcf7-response-output, div.wpcf7-validation-errors { display: none !important; }
span.wpcf7-not-valid-tip { display: none; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: red; background-color: rgba(153,0,0,0.3); }
#
# Verify captcha
$post_data = http_build_query(
array(
'secret' => CAPTCHA_SECRET,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
)
);
$opts = array('http' =>
@sesn
sesn / gist:476e443c9ba5ced76378f7e74e4f7329
Created June 22, 2018 10:16
Configuring PHPCS in Visual Code
1. Insert the following into composer.json:
```json
"require-dev": {
"squizlabs/php_codesniffer": "*",
"wp-coding-standards/wpcs": "^0.13.1"
},
"scripts": {
"post-install-cmd": [
"\"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs"
@sesn
sesn / gist:e307a0938f8a252918d27c4826648ba8
Created June 3, 2018 14:36
Changing mac screenshoots storage folder
defaults write com.apple.screencapture location ~/Desktop/screenshots
@sesn
sesn / README.md
Created March 26, 2018 15:46 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@sesn
sesn / async-foreach.js
Created March 13, 2018 06:36 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)