Skip to content

Instantly share code, notes, and snippets.

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

musaid musaid

🏠
Working from home
View GitHub Profile
@musaid
musaid / login.php
Last active October 21, 2023 16:23
Slim Login :: A crude example
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim();
$app->add(new \Slim\Middleware\SessionCookie(array('secret' => 'myappsecret')));
$authenticate = function ($app) {
return function () use ($app) {
if (!isset($_SESSION['user'])) {
@musaid
musaid / postgres_queries_and_commands.sql
Created August 13, 2023 02:42 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@musaid
musaid / ExampleNotification.php
Created April 24, 2020 04:07 — forked from alejandrogih/ExampleNotification.php
Send email with Sendgrid (including template id and substitutions) with Laravel's notifications
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
//This example use the official's sendgrid php helper (https://github.com/sendgrid/sendgrid-php)
// Comments
++ -- /= && || ||=
-> => :: __
== === != =/=
<= >= <==>
/* */ // ///
\n \\
<< <<< <<= >> >>> >>= |= ^=
0xFF 1920x1080
@musaid
musaid / docker-compose.yml
Created March 17, 2019 12:45
Sample Docker Compose File
version: '3'
services:
proxy:
container_name: proxy
image: jwilder/nginx-proxy
ports:
- 80:80
volumes:
@musaid
musaid / config.js
Last active October 31, 2018 10:34 — forked from 1Marc/config.js
My VS Code Config
// For: @musaid
// https://twitter.com/musaid/status/1039688749205020672
// Ligatures built into Operator Mono as "Operator Mono Lig" with https://github.com/kiliman/operator-mono-lig
// VS Code Extensions:
// Material Icon Theme (Philip Kief),
// indent-rainbow (oderwat),
// Rainbow Brackets (2gua),
// Subtle Match Brackets (Rafa Mel),
// Git Lense
// Prettier (Esben Petersen) (require config file with requireConfig)
@musaid
musaid / laravel-subdirectory.conf
Created February 8, 2017 03:29 — forked from tsolar/laravel-subdirectory.conf
Laravel in subdirectory nginx example
server {
client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 300M;
sendfile on;
send_timeout 300s;
# Port that the web server will listen on.
#listen 80;
$(function() {
$('#sortable').sortable({
start: function(event, ui) {
var start_pos = ui.item.index();
ui.item.data('start_pos', start_pos);
},
change: function(event, ui) {
var start_pos = ui.item.data('start_pos');
var index = ui.placeholder.index();
if (start_pos < index) {
@musaid
musaid / Vagrantfile
Last active October 9, 2018 06:56
Vagrants
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.box = "trusty64"
@musaid
musaid / remove-processed.sql
Created October 7, 2018 04:25
Stored procedure to remove rows in chunks until a certain value is reached.
CREATE DEFINER=`admin`@`10.0.0.1` PROCEDURE `removeProcessed`(table_name VARCHAR(255), keyField VARCHAR(255), maxId INT, num_rows INT)
BEGIN
SET @table_name = table_name;
SET @keyField = keyField;
SET @maxId = maxId;
SET @num_rows = num_rows;
SET @sql_text1 = concat('SELECT MIN(',@keyField,') INTO @a FROM ',@table_name);
PREPARE stmt1 FROM @sql_text1;
EXECUTE stmt1;