Skip to content

Instantly share code, notes, and snippets.

Anis uddin Ahmad ajaxray

Block or report user

Report or block ajaxray

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ajaxray
ajaxray / wait_for_signal.go
Last active Jan 27, 2019
Simple go function to prevent exiting program until SIGINT (Ctrl+C) or SIGTERM is received.
View wait_for_signal.go
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
@ajaxray
ajaxray / sql_to_csv.go
Last active Dec 20, 2018
Parse a MySQL dump and prints table/field definitions as CSV (including Table/field comments)
View sql_to_csv.go
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
)
@ajaxray
ajaxray / ListProvider.php
Created Aug 26, 2018
PHP Trait for key key-value array of various entities (e,g, Doctrine 2 ORM)
View ListProvider.php
<?php
/**
* Provide key-value list of various entities
*
* Created by: Anis Ahmad <anis.programmer@gmail.com>
* Created at: 8/26/18 4:42 PM
*/
namespace AppBundle\Traits;
trait ListProvider
@ajaxray
ajaxray / result_sequance_no.sql
Last active May 15, 2018
Adding row sequence number to MySQl result
View result_sequance_no.sql
SELECT
@a:=@a+1 AS sl,
t.field_name,
ot.other_field_name,
-- more fields...
FROM
(SELECT @a:= 0) AS a,
primary_table_name t
JOIN other_table ot ON t.other_id = ot.id
WHERE
@ajaxray
ajaxray / go-http-nginx.conf
Created Feb 16, 2018
Serve go / Golang HTTP/HTTPS app with Nginx as a subdomain
View go-http-nginx.conf
upstream go-http-backend {
server 127.0.0.1:3000;
keepalive 20;
}
server {
listen 80;
server_name sub.domain.com;
# adjust as per app's requirement
@ajaxray
ajaxray / my-app.tld.conf
Created Oct 29, 2017
Use NGINX as proxy server for Node ExpressJS application.
View my-app.tld.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name my-app.tld www.my-app.tld;
# Serve assets directly from nginx
location ~ ^/(scripts/|images/|img/|js/|css/|stylesheets/|media/|robots.txt|humans.txt|favicon.ico) {
root /path/to/my-app/public/;
access_log off;
@ajaxray
ajaxray / mysqldump_to_mega.sh
Last active Apr 2, 2018
Backup MySQL database to MEGA.nz cloud storage
View mysqldump_to_mega.sh
#!/bin/bash
# ----------------------------------------------------
# A Shell script to take MySql database backup
# and upload to MEGA cloud storage using megatools
# ----------------------------------------------------
# REQUIREMENTS : You should have -
# 1. Registered and verified MEGA account - https://mega.nz/
# 2. Installed megatools - https://github.com/megous/megatools
# ----------------------------------------------------
@ajaxray
ajaxray / wkhtmltopdf.sh
Last active Jun 12, 2019 — forked from Rajeshr34/wkhtmltopdf.sh
Install wkhtmltopdf with Patched QT for CentOS 7 or RHEL 7.x
View wkhtmltopdf.sh
cd ~
yum install -y xorg-x11-fonts-75dpi xorg-x11-fonts-Type1 openssl git-core fontconfig
wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
mv wkhtmltox/bin/wkhtmlto* /usr/bin
# Thanks to
# https://jaimegris.wordpress.com/2015/03/04/how-to-install-wkhtmltopdf-in-centos-7-0/
# https://gist.github.com/Rajeshr34/2e9b2438ff142e51c729b4b9b772680a
@ajaxray
ajaxray / mongo.ts
Created May 1, 2017
Simplest (just connect, create, find, count) MongoDB wrapper.
View mongo.ts
import {Query} from './query'
let MongoClient = require('mongodb').MongoClient;
let defaultFailure = function (err) { throw err; };
class Mongo {
connected: boolean;
db: any;
@ajaxray
ajaxray / SomeClassTest.php
Last active Mar 9, 2017
PHP mocking built-in functions (e,g exec, file_exists etc.) for testing
View SomeClassTest.php
<?php
/**
* Example of mocking built-in functions for testing
*
* @Author : ajaxray <anis.programmer@gmail.com>
* @Date-Time : 03/05/2017
*
* How it works?
* ----------------
* Simply by redefining the function for target Namespace.
You can’t perform that action at this time.