Skip to content

Instantly share code, notes, and snippets.

@allaniftrue
allaniftrue / laravel-query-too-many-placeholder.php
Created March 6, 2023 01:48 — forked from sentiasa/laravel-query-too-many-placeholder.php
Laravel - Query +100k placeholders in Laravel using `whereIn()`
<?php
$transactionIds = Transaction::pluck('id'); // +100k transaction ids
$maxAtOneTime = 5000;
$total = count($transactionIds);
$pages = ceil($total / $maxAtOneTime);
$transactions = collect();
root@sydney:/mnt/vol2# rclone sync spaces-sgp1:mybucket1 /mnt/vol2 --checkers 256 --transfers 256 --progress --fast-list --size-only
2023-02-27 07:18:50 ERROR : 52231/: Failed to copy: failed to open source object: NoSuchKey:
status code: 404, request id: tx00000000000001d4ec082-0063fc595a-285cf3d6-sgp1b, host id:
2023-02-27 07:18:54 ERROR : Local file system at /mnt/vol2: not deleting files as there were IO errors
2023-02-27 07:18:54 ERROR : Local file system at /mnt/vol2: not deleting directories as there were IO errors
2023-02-27 07:18:54 ERROR : Attempt 1/3 failed with 3 errors and: failed to open source object: NoSuchKey:
status code: 404, request id: tx00000000000001d4ec082-0063fc595a-285cf3d6-sgp1b, host id:
Transferred: 2.276M / 2.276 MBytes, 100%, 3.198 MBytes/s, ETA 0s
2023-02-27 07:20:04 ERROR : 52231/: Failed to copy: failed to open source object: NoSuchKey:
status code: 404, request id: tx00000000000001d4e5352-0063fc59a4-28667c7c-sgp1b, host id:
@allaniftrue
allaniftrue / ipfw.rules
Last active February 25, 2023 22:42
/etc/ipfw.rules
#!/bin/sh
# Flush out the list before we begin.
ipfw -q -f flush
# Set rules command prefix
cmd="ipfw -q add"
pif="vtnet0" # interface name of NIC attached to Internet
$cmd 00005 allow all from any to any via vtnet0
@allaniftrue
allaniftrue / s3_set_object_public.sh
Last active February 16, 2023 01:24 — forked from alexclifford/s3_set_object_public.sh
Make S3 object public and private via s3cmd command line
s3cmd setacl s3://bucket/path/to/file --acl-public
s3cmd info s3://bucket/path/to/file
s3cmd setacl s3://bucket/path/to/file --acl-private
# S3CMD SET ALL FILES IN FOLDER TO PRIVATE
s3cmd setacl s3://bucket/path/to/file --acl-private --recursive
@allaniftrue
allaniftrue / keypress.js
Created June 3, 2021 06:46
Reactjs prevent characters on keypress
use { useState } from 'react';
const Test = () => {
const [tipAmount, setTipAmount] = useState('');
const handleKeypress = (e) => {
if(!((e.keyCode > 95 && e.keyCode < 106)
|| (e.keyCode > 47 && e.keyCode < 58)
|| e.keyCode == 8)) {
e.preventDefault(); // Let's stop this event.
@allaniftrue
allaniftrue / countries.json
Created April 16, 2021 02:00
Alpha-2 ISO3166 countries
[
{
"label": "Afghanistan",
"value": "AF"
},
{
"label": "Åland Islands",
"value": "AX"
},
{
@allaniftrue
allaniftrue / sarg.conf
Created February 21, 2016 09:44
custom Sarg Configuration
# sarg.conf
#
# TAG: access_log file
# Where is the access.log
# sarg -l file
#
access_log /250Vault/squid/logs/access.log
# TAG: graphs yes|no
# Use graphics where possible.
@allaniftrue
allaniftrue / axios.unverify.ssl.js
Last active August 18, 2022 11:30
axios configuration to disable certificate verification
import axios from 'axios';
import https from 'https';
axios.create({
baseURL: 'https://localhost:3001',
httpsAgent: new https.Agent({
rejectUnauthorized: false,
}),
});
@allaniftrue
allaniftrue / 422Error.php
Created May 14, 2021 19:19
Laravel Throw custom 422 error message
<?php
use Illuminate\Validation\ValidationException;
throw ValidationException::withMessages(['field_name' => 'This value is incorrect']);
@allaniftrue
allaniftrue / SomeController.php
Created April 11, 2021 14:17
Dompdf API response
<?php
public function pdf($id)
{
//...
$pdf = PDF::loadView('pdf.payroll');
return response()->json([
'pdf' => base64_encode($pdf->output())
]);