Skip to content

Instantly share code, notes, and snippets.

View ajaxray's full-sized avatar
🪁
Exploring

Anis uddin Ahmad ajaxray

🪁
Exploring
View GitHub Profile
@ajaxray
ajaxray / SomeClassTest.php
Last active July 4, 2023 16:30
PHP mocking built-in functions (e,g exec, file_exists etc.) for testing
<?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.
@ajaxray
ajaxray / vim-cheat-sheet.md
Last active February 6, 2022 04:14
Vim Cheat Sheet

Vim Cheat Sheet

My collection of vim tips to make the best editor even better. This is by no means complete or a tutorial on how to use vim, but a set of commands I don't want to forget and need to write them down before they burn into memory.

See the resources section below for a more complete introduction and a set of in-depth tutorials.

Navigation

:nn " Jump to line nn

@ajaxray
ajaxray / dependency_check.sh
Last active February 23, 2017 06:02
Simple bash script for checking system readiness for launching an application. It checks if necessary softwares/tools installed, required modules enabled, recommended ini settings, depending servers are up and required ports are listening.
#!/usr/bin/env bash
# Author : Anis Uddin Ahmad <anis.prorgrammer@gmail.com>
# http://ajaxray.com
# How to use : https://cl.ly/1f1L0K413g1x
# List command line tools
dependencies=(httpd php mysql beanstalkd convert)
# If php application, list required modules
php_modules=(curl PDO pdo_mysql session Reflection hash json sockets oci8 imagick)
@ajaxray
ajaxray / reload.sh
Last active January 28, 2017 10:29
A Bash script for resetting environment of Symfony2 app during development.
#!/usr/bin/env bash
# Author : Anis Uddin Ahmad <anis.prorgrammer@gmail.com>
# http://ajaxray.com
# Usages (from application base dir)
# sh bin/reload.sh => quick reset (default env is prod)
# sh bin/reload.sh dev => quick reset dev
# sh bin/reload.sh prod full => full reset prod (including assets, supervirord etc.)
# Paths and Settings
@ajaxray
ajaxray / select2-cascade.js
Last active November 23, 2022 07:27
Making Select2 (4.x) list boxes cascading / dependent. Options of a select2 list box will be loaded/refreshed by ajax based on selection of another select2 list box.
/**
* A Javascript module to loadeding/refreshing options of a select2 list box using ajax based on selection of another select2 list box.
*
* @url : https://gist.github.com/ajaxray/187e7c9a00666a7ffff52a8a69b8bf31
* @auther : Anis Uddin Ahmad <anis.programmer@gmail.com>
*
* Live demo - https://codepen.io/ajaxray/full/oBPbQe/
* w: http://ajaxray.com | t: @ajaxray
*/
var Select2Cascade = ( function(window, $) {
@ajaxray
ajaxray / firebase-online-user-count-example.md
Last active July 18, 2022 09:57
Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally

Gathering.js - How to use

Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally.

Live Demo

Firebase Shared Checklist is a demo application that shows the number of users joined a checklist using gathering.js. Here is a 1 minute screencast of using this application.

@ajaxray
ajaxray / module_pattern.js
Last active March 23, 2016 14:48
Sample implementation of JavaScript module pattern to explain private and public members.
var Talkative = ( function( w, $ ) {
// this object is used to store private variables and methods across multiple instantiations
var privates = {
"secret" : 'Not to share'
};
// A shared private method
privates.talk = function (msg) {
w.alert('whisper : ' + msg);
@ajaxray
ajaxray / supervisord.conf
Created December 9, 2015 01:39
Sample supervisord config file.
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
; - Quotes around values are not supported, except in the case of
@ajaxray
ajaxray / mysql_backup.sh
Last active November 2, 2015 18:34
Createing MySQL Database Backup and removing older backups automatically
#!/bin/sh
# Collected from https://rimuhosting.com/howto/mysqlbackup.jsp
# List of databases to be backed up separated by space
dblist="db_name_1 db_name_2 db_name_3 etc."
# Directory for backups
backupdir=/full/path/to/backup/dir
# Number of versions to keep
@ajaxray
ajaxray / beanstalkd-commands.md
Created July 22, 2015 12:41
Getting beanstalkd status with a single/one-line command

Getting beanstalkd status with a single command

  • Full status: echo -e "stats\r\n" | nc localhost 11300
  • List of tubes: echo -e "stats-tube create-report\r\n" | nc localhost 11300
  • Tube status: echo -e "stats-tube the-tube-name\r\n" | nc localhost 11300
  • Select a tube: echo -e "use create-report\r\n" | nc localhost 11300
  • Next ready job in current tube: echo -e "peek-ready\r\n" | nc localhost 11300