Skip to content

Instantly share code, notes, and snippets.

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

Manuel Almaguer manunoly

🏠
Working from home
View GitHub Profile
import {Directive, Attribute} from '@angular/core';
import {NgModel} from '@angular/common';
@Directive({
selector: '[mask]',
host: {
'(keyup)': 'onInputChange()'
}
})
export class Mask {
maskPattern: string;
@manunoly
manunoly / request_no_curl.php
Created August 11, 2019 19:28 — forked from iNaD/request_no_curl.php
Sending a GET/POST Request via PHP without CURL (fopen needs to be enabled)
<?php
$url = 'http://server.com/path';
$data = array('key1' => 'value1', 'key2' => 'value2');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
@manunoly
manunoly / hosting-on-github.md
Created November 10, 2019 18:21 — forked from TylerFisher/hosting-on-github.md
Basic steps for hosting on Github

Hey there, apparently people are still using this Gist from 2013! It's out of date! Consult the Github docs.

Steps for Hosting a Website on GitHub

  1. Create a GitHub account on github.com.
  2. Download either [GitHub for Mac][1] or [GitHub for Windows][2], depending on your operating system. Open the app and log in using the account you just created.
  3. (On Mac): After you login, click advanced and make sure that your name and email are correct. Then, click "Install Command Line Tools", just in case you want to start using the command line later in life.
  4. Create a new repository in your GitHub application. Name it your-username.github.io. The name is very important. Note the folder that GitHub is saving the repository to. Make sure the "Push to GitHub?" box is checked.
  5. Move your website's files into the folder that GitHub just created when you made the repository. IMPORTANT: Your homepage HTML file must be called "index.html", and it must exist in the top-level
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor() { }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
import { AuthService } from './../servicios/auth.service';
import { environment } from './../../environments/environment.prod';
import { finalize } from 'rxjs/operators';
import { Chooser } from '@ionic-native/chooser/ngx';
import { File, FileEntry } from '@ionic-native/file/ngx';
import { UtilService } from './../servicios/util.service';
import { FilePath } from '@ionic-native/file-path/ngx';
import { WebView } from '@ionic-native/ionic-webview/ngx';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
@manunoly
manunoly / capture-upload-file-ionic-ios-android
Last active April 20, 2020 13:45
read file for android and ios using ionic Chooser plugin
import { AuthService } from './../servicios/auth.service';
import { environment } from './../../environments/environment.prod';
import { finalize } from 'rxjs/operators';
import { Chooser } from '@ionic-native/chooser/ngx';
import { File, FileEntry } from '@ionic-native/file/ngx';
import { UtilService } from './../servicios/util.service';
import { FilePath } from '@ionic-native/file-path/ngx';
import { WebView } from '@ionic-native/ionic-webview/ngx';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
@manunoly
manunoly / AuthController.php
Created May 14, 2021 14:32
rest Api login for Sanctum
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\BaseController;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AuthController extends BaseController
@manunoly
manunoly / download_ajax.js
Created March 4, 2022 13:23 — forked from AxelUser/download_ajax.js
How to download file in base64 format by ajax request to your api
$.ajax({
url: "http://api.yoursite.com",
data: data,
type: "POST"
}).done(function(result) {
var link = document.createElement("a");
document.body.appendChild(link);
link.setAttribute("type", "hidden");
link.href = "data:text/plain;base64," + result;
link.download = "data.zip";
import NextAuth from "next-auth"
import Providers from "next-auth/providers"
import { addSeconds } from "date-fns"
import type { User } from "hooks/useUser"
import log from "utils/server-logger"
import sessionsDB, { InactiveSessionReason } from "lib/session-db"
import jwtDecode from "jwt-decode"
/** @see https://docs.microsoft.com/en-us/azure/active-directory/develop/id-tokens#payload-claims */
export interface IDToken {