Skip to content

Instantly share code, notes, and snippets.

View prezire's full-sized avatar

Mark N. Amoin prezire

View GitHub Profile
@prezire
prezire / view_helper.php
Last active November 4, 2022 14:41
Helps view rendering for CodeIgniter 3.
<?php
function showView($view, $data = null)
{
$CI = get_instance();
$CI->load->view('commons/layouts/header', $data);
$CI->load->view($view, $data);
$CI->load->view('commons/layouts/footer', $data);
}
function showJsonView($data, $status = 200)
{
@prezire
prezire / haversinehelper.js
Last active November 4, 2022 14:42
For NodeJS
var HaversineHelper = {
getQueryString: function
(
latitiude,
longitude,
keywords
){
return "SELECT id, post_id, full_name, description, (6371 * acos(cos(radians($latitude)) * cos(radians(latitude)) * cos(radians(longitude) - radians(longitude)) + sin(radians(latitude)) * sin(radians(latitude)))) distance FROM wp_locations WHERE full_name LIKE '%$keywords%' OR description LIKE '%keywords%' GROUP BY full_name HAVING distance < $distance ORDER BY distance LIMIT 0, 20";
}
};
<?php if(!defined('BASEPATH')) exit('No direct script access allowed.');
function debug($data, $forceExit = TRUE)
{
echo '<pre>';
print_r($data);
echo '</pre>';
if(TRUE === $forceExit) exit;
}
function debugStackTrace()
{
@prezire
prezire / autobahn.js
Created February 13, 2018 06:00 — forked from cboden/autobahn.js
Autobahn v1
/** @license MIT License (c) 2011,2012 Copyright Tavendo GmbH. */
/**
* AutobahnJS - http://autobahn.ws
*
* A lightweight implementation of
*
* WAMP (The WebSocket Application Messaging Protocol) - http://wamp.ws
*
* Provides asynchronous RPC/PubSub over WebSocket.
@prezire
prezire / instructions.sh
Created February 24, 2018 06:16 — forked from james2doyle/instructions.sh
Setup beanstalkd on AWS EC2 with Ubuntu 16.04 to be public
sudo vim /etc/default/beanstalkd # change IP to 0.0.0.0
sudo systemctl daemon-reload # reload daemon
netstat -nat | grep LISTEN # see if `0.0.0.0:11300` is in the list
@prezire
prezire / php-event-listener-example.php
Created March 6, 2018 03:07 — forked from im4aLL/php-event-listener-example.php
PHP event listener simple example
<?php
class Event {
private static $events = [];
public static function listen($name, $callback) {
self::$events[$name][] = $callback;
}
public static function trigger($name, $argument = null) {
foreach (self::$events[$name] as $event => $callback) {
@prezire
prezire / git-log-live
Last active January 22, 2019 03:21 — forked from tlberglund/git-loglive
Log Live Git Command
#!/bin/bash
#sudo ln -s /full-path/git-log-live /usr/local/bin/git-log-live
#sudo chmod +x git-log-live
#git-log-live /absolute-proj-root-path
#git-log-live .
while :
do
clear
@prezire
prezire / laravel_log_helper.php
Last active November 4, 2022 14:30
Proper use of logger.
<?php namespace App\Services\Enums;
final class LogType
{
const
//Total failures. Major systems are unavailable.
EMERGENCY_UNUSABLE_SYSTEMS = 'emergency',
//Usable hardwares with unusal outputs such as website down, unavailable DBs.
ALERT_CORRUPTED_SYSTEMS = 'alert',
@prezire
prezire / git_submodule.txt
Created October 23, 2019 07:28
Basic Git Submodule Commands
#Main proj.
#Add a submodule.
git submodule add https://proj.git
#Go to submodule's dir and change to specific branch.
cd submodule_dir
git checkout -b branch origin/branch
#Go back to proj root and push to repo along with the new submodule's new branch.
git add . -u
git commit ...
git push
@prezire
prezire / docker_cheat_sheet.sh
Last active November 4, 2022 14:32
Docker commands
Ref:
https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes
Remove all:
docker system prune -a
Images:
Remove all:
docker rmi $(docker images -a -q)