Skip to content

Instantly share code, notes, and snippets.

View M-Abdullahi's full-sized avatar
:octocat:
Available

M. Abdullahi M-Abdullahi

:octocat:
Available
View GitHub Profile
@M-Abdullahi
M-Abdullahi / Camera.md
Last active September 15, 2021 15:17
This gist allows you to request access to camera/webcam for your vuejs apps
View Camera.md
  methods: {
    hasCameraCapability() {
      return !!(window.navigator.mediaDevices && window.navigator.getUserMedia)
    },
    requestCameraAccess(config = {video: true}) {
      return window.navigator.getUserMedia(config)
    },
 
@M-Abdullahi
M-Abdullahi / M-PesaAPIAccess.md
Last active March 23, 2021 14:45
This gist describes the processe of creating m-pesa test application allowing us to access the m-pesa api.
View M-PesaAPIAccess.md

Access Safaricom's M-Pesa API

This gist describes the processes of allowing us to access the Safaricom's M-Pesa API. At the end of the process we will obtain all variable needed to start using their API. We will be using the Customer to Business (C2B) API.

This gist has been created as an Appendix to this article (part 1).

Start the Engine

⚡ Start by accessing the M-Pesa Developer Portal and create a new account if you don't already have one. Click the build new app button to scaffold a new testing application.

@M-Abdullahi
M-Abdullahi / mp-1-g2.md
Created December 8, 2020 09:14 — forked from sander3/mp-1-g2.md
Medium post 1, Gist 2
View mp-1-g2.md
$teams = App\Team::with([
    'portfolios' => function ($query) use ($user) {
        // Only include portfolios where...
        $query->whereHas('wallets', function ($query) use ($user) {
            // ...there are wallets...
            $query->whereHas('transactions', function ($query) {
                // ...with pending transactions...
                $query->whereStatus('pending');
            });
@M-Abdullahi
M-Abdullahi / mp-1-g3.md
Created December 8, 2020 09:13 — forked from sander3/mp-1-g3.md
Medium post 1, Gist 3
View mp-1-g3.md
$teams = App\Team::whereHas('portfolios', function ($query) use ($user) {
    // Only include teams with portfolios where...
    $query->whereHas('wallets', function ($query) use ($user) {
        // ...there are wallets...
        $query->whereHas('transactions', function ($query) {
            // ...with pending transactions...
            $query->whereStatus('pending');
        });
View encrypted_unique
Validator::extend('encrypted_unique', function ($attribute, $value, $parameters, $validator) {
list ($table, $column, $ignore_id) = $parameters; // or hard-coded if fixed
$count = $validator->getPresenceVerifier()->getCount($table, $column, encrypt($value), $ignore_id);
return $count === 0;
});
'identifier' => "encrypted_unique:table,column,$this_id"
View mail
$transport = new Swift_SmtpTransport('SMTP-HOST-HERE', SMTP-PORT-HERE);
$transport->setUsername('SMTP-USERNAME-HERE');
$transport->setPassword('SMTP-PASSWORD-HERE');
// extra configurations here if needed
Then, we use the Swift_SmtpTransport to build our Swift_Mailer object.
$swift_mailer = new Swift_Mailer($transport);
@M-Abdullahi
M-Abdullahi / html2canvas.js
Created February 16, 2019 05:47
Export html div content as image and save it to a pdf file
View html2canvas.js
html2canvas($("#canvas"), {
onrendered: function(canvas) {
var imgData = canvas.toDataURL(
'image/png');
var doc = new jsPDF('p', 'mm');
doc.addImage(imgData, 'PNG', 10, 10);
doc.save('sample-file.pdf');
}
});
@M-Abdullahi
M-Abdullahi / starts_with helper.php
Created February 15, 2019 05:59
Helper function to check if an items starts with a pattern
View starts_with helper.php
if (starts_with($uploadedFile->getClientMimeType(), 'image')) {
}
@M-Abdullahi
M-Abdullahi / gist:3e17b84959088c835539d3f6a4ef893f
Last active February 15, 2019 05:02 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions
View gist:3e17b84959088c835539d3f6a4ef893f

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch