Skip to content

Instantly share code, notes, and snippets.

View tomerof's full-sized avatar
🐢
slow but accurate

Tomer Ofer tomerof

🐢
slow but accurate
View GitHub Profile

Clarifying Cloudflare API Filter Operators

Cloudflare's API documentation mentions Optional Filter Operators such as starts_with, ends_with, and contains, but it lacks clear examples of how to use them. This guide explains the correct syntax for these operators and provides working examples to help you filter results effectively.

For the official Cloudflare API documentation, visit: Cloudflare API - List Zones


Correct Syntax for Filter Operators

@tomerof
tomerof / ffmpeg-commands.md
Created October 6, 2023 07:19
useful ffmpeg commands

use ffmpeg to convert .flac to .mp3 (powershell)

dir *.flac | foreach {ffmpeg -i $_.FullName -ab 320k -map_metadata 0 -id3v2_version 3 $_.FullName.Replace('flac', 'mp3')}
@tomerof
tomerof / Load script dynamically.md
Created May 24, 2023 06:28
javascript load another script dynamically

To conditionally load a JavaScript script from a URL in JavaScript, you can use the following approach:

function loadScript(url, condition, callback) {
  if (condition) {
    var script = document.createElement('script');
    script.src = url;
    script.onload = callback;
    document.head.appendChild(script);
@tomerof
tomerof / pdf.md
Created May 16, 2023 18:48
Generate PDF using Javascript and HTML

To create a PDF using JavaScript and HTML, you can utilize a JavaScript library called "jsPDF." jsPDF is a popular open-source library that allows you to generate PDF files programmatically. Here's an example of how you can use jsPDF to create a PDF document:

  1. Include the jsPDF library in your HTML file by adding the following script tag within the <head> section:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.3/jspdf.umd.min.js"></script>
  1. Create a button or trigger that will initiate the PDF creation process. For example:
@tomerof
tomerof / javascript.object.merge.md
Last active May 7, 2023 14:00
Javascript - combine multiple objects while preserving duplicate values as arrays.

To merge two objects in JavaScript while letting the second object overwrite the same keys in the first object, you can use the Object.assign() method.

Here's an example:

const obj1 = {a: 1, b: 2, c: 3};
const obj2 = {b: 4, c: 5, d: 6};

const mergedObj = Object.assign({}, obj1, obj2);
@tomerof
tomerof / flutter_errors_report.md
Created April 20, 2023 06:31
Basic usage of catcher in Flutter application to handle errors and send them by email or by http request - like ACRA in android

To use the Catcher library in your Flutter application to catch errors and send them to a server, you can follow these steps:

  1. Add the Catcher dependency to your pubspec.yaml file and run flutter pub get to install it:

    dependencies:
      catcher: ^0.6.4
  2. Import the Catcher library in your Dart code:

@tomerof
tomerof / vue3-pwa.md
Last active April 11, 2025 20:03
To turn a Vue 3 app into a PWA

To turn a Vue 3 app into a PWA, you can follow these steps:

  1. Create a manifest.json file in the public folder of your Vue 3 app. This file contains metadata about your PWA, such as the app name, icon, and theme color. Here's an example:
{
  "name": "My Vue 3 App",
  "short_name": "My App",
  "icons": [
    {
 "src": "img/icons/android-chrome-192x192.png",
@tomerof
tomerof / validate.js
Last active March 8, 2023 21:08
validate israeli ID number
function isIsraeliId(id) {
id = String(id).trim();
if (id.length > 9 || isNaN(id)) return false;
id = id.length < 9 ? ("00000000" + id).slice(-9) : id;
return Array.from(id, Number).reduce((counter, digit, i) => {
const step = digit * ((i % 2) + 1);
return counter + (step > 9 ? step - 9 : step);
}) % 10 === 0;
}
@tomerof
tomerof / ffmpeg-mp4-to-animated-webp.md
Created December 5, 2022 06:07 — forked from witmin/ffmpeg-mp4-to-animated-webp.md
Convert MP4 file to animated WebP in ffmpeg

Convert MP4 file to animated WEBP file in ffmpeg CLI

1. Install ffmpeg CLI through homebrew

In terminal.app, install ffmpeg through homebrew

brew install ffmpeg

Validate the installation:

@tomerof
tomerof / functions.php
Last active September 14, 2022 11:01
Example of Wordpress api endpoint
<?php
add_action('rest_api_init', function(){
register_rest_route('my-namespace', 'endpoint-name', [
"methods" => WP_REST_Server::CREATABLE, // POST
//"methods" => WP_REST_Server::READABLE, // GET
'callback' => function(WP_REST_Request $request) use ($finsPostByTitle){
// if posted a json use this
//$data = $request->get_json_params();