Skip to content

Instantly share code, notes, and snippets.

View bayareawebpro's full-sized avatar
✔️
Available for Consulting

Dan Alvidrez bayareawebpro

✔️
Available for Consulting
View GitHub Profile
@TheDeadCode
TheDeadCode / JsonModelStreamWriter.php
Created March 3, 2021 22:04
JsonModelStreamWriter
<?php
/**
* Stream-write arrays onto a file on disk as JSON format, to avoid memory leaks.
* Written expressly for /u/devourment77 of reddit.
*
* Copyright (C) 2021 by Vynatu Cyberlabs, Inc. and Felix Lebel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
<template>
<div>
<label id="listbox-label" class="block text-sm font-medium text-gray-700" v-text="label"/>
<input type="hidden" :value="selectedValues" :name="name">
<div class="mt-1 relative">
<button @click="selected = !selected" type="button" aria-haspopup="listbox" aria-expanded="true"
aria-labelledby="listbox-label"
class="bg-white relative w-full border border-gray-300 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
<span class="block truncate" v-text="selectedText"/>
<template>
<div>
<label id="listbox-label" class="block text-sm font-medium text-gray-700">
Assigned to
</label>
<input type="hidden" :value="selectedValues" name="name">
<div class="mt-1 relative">
<button @click="selected = !selected" type="button" aria-haspopup="listbox" aria-expanded="true"
aria-labelledby="listbox-label"
class="bg-white relative w-full border border-gray-300 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
@elawad
elawad / format-size.js
Last active March 29, 2021 10:03
Format file size like macOS
function formatSize(size) {
const base = 1000; // 1000 or 1024
const kb = base ** 1;
const mb = base ** 2;
const gb = base ** 3;
let num;
num = (size / 1).toFixed(0);
if (num < base) return Number(num) + ' B';
@paragonie-scott
paragonie-scott / js-php-encrypt.md
Last active September 14, 2022 22:04
String Encryption in JavaScript and PHP

Just for fun, let's encrypt some stuff in client-side JavaScript and have a PHP server decrypt it. Note that this will never replace TLS (HTTPS).

JavaScript Encryption with Sodium-Plus

You'll want the latest release of sodium-plus for this. (As of this writing, it's version 0.4.0.)

<script
  src="/static/js/sodium-plus.min.js"
 integrity="sha384-lv7SVE0eb0bXA3fgK6PwlhViiUwG6tBuMAhS8XX7RvBvyRcdEdJ8HKtFgs4vHTUh"
@curran
curran / LICENSE
Last active March 9, 2024 23:04
Simplemaps: World Cities Database
This license is a legal document designed to protect your rights and the rights of the Pareto Software, LLC, the owner of Simplemaps.com. Please read it carefully. Purchasing or downloading a data product constitutes acceptance of this license.
Description of Product and Parties: This license is a contract between you (hereafter, the Customer) and Pareto Software, LLC (hereafter, the Provider) regarding the use and/or sale of an collection of geographic data (hereafter, the Database).
Ownership of Database: All rights to the Database are owned by the Provider. The Database is a cleaned and curated collection of geographic facts and the Provider retains all rights to the Database afforded by the law. Ownership of any intellectual property generated by the Provider while performing custom modifications to the Database for a Customer (with or without payment) is retained by the Provider.
License: Customers who purchase a license are allowed to use the database for projects that benefit their organization or t
@krakjoe
krakjoe / crawler.php
Last active October 11, 2023 19:07
parallel Futures, Channels (buffered, unbuffered, synchros), Events using parallel producer/consumer pattern
<?php
use \parallel\{Runtime, Future, Channel, Events};
/* usage php crawler.php [http://example.com] [workers=8] [limit=500] */
$page = $argv[1] ?: "https://blog.krakjoe.ninja"; # start crawling this page
$workers = $argv[2] ?: 8; # start this number of threads
$limit = $argv[3] ?: 500; # stop at this number of unique pages
$timeout = $argv[4] ?: 3; # socket timeout for producers
@jhm-ciberman
jhm-ciberman / NovaResourcesTest.php
Last active February 15, 2024 02:37
Simple Automatic Test for Laravel Nova Resources (Updated for Nova 4)
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Nova;
class NovaResourcesTest extends TestCase
{
@tigusigalpa
tigusigalpa / database.php
Last active March 11, 2024 17:43
Laravel PostgreSQL SSL encryption connection config
<?php
/**
* 1. You have to store your client SSL certificates on your Laravel server, in my case this is /var/certs/mydomain.com/...
* 2. You have to right select SSL mode for PostgreSQL (see https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS), verify-full means your server CA is signed for real domain name for the PostgreSQL server (recommended)
* 3. Go to Laravel config/database.php to the section 'pgsql' and extend it to the following:
*/
return [
/*...*/
'connections' => [
/*'mysql' etc*/
@mysiar
mysiar / ideolog-monolog.md
Created February 22, 2019 18:15
Monolog template for Ideolog
Message pattern: `^\[(.*)\] (.+?)\.([A-Z]+): (.*)`
Message start pattern: `^\[`
Time format: `yyyy-MM-dd HH:mm:ss`
Time capture group: `1`
Severity capture group: `3`
Category capture group: `2`