Skip to content

Instantly share code, notes, and snippets.

View jbinfo's full-sized avatar

Lhassan Baazzi jbinfo

View GitHub Profile
@jbinfo
jbinfo / prayers_scraper.py
Created September 26, 2025 23:40
Prayer Times Scraper for Morocco - Extracts Islamic prayer times from official Ministry of Habous website (habous.gov.ma) and outputs CSV format compatible with Mawaqit App for TV. Supports multiple cities, handles Arabic text, and provides clean formatted data (Fajr, Sunrise, Dhuhr, Asr, Maghrib, Isha).
import scrapy
import csv
import re
class PrayerTimesSpider(scrapy.Spider):
name = 'prayer_times'
start_urls = [
'https://habous.gov.ma/prieres/horaire_hijri_2.php?ville=58', # Casablanca city
'https://habous.gov.ma/prieres/horaire_hijri_2.php?ville=142' # Agdz city
]
@jbinfo
jbinfo / mouseJiggler.ps
Created September 18, 2025 16:06
Stay Active – PowerShell Script to Prevent Windows Idle Lock
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class NativeMethods {
[DllImport("user32.dll")]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
}
"@
@jbinfo
jbinfo / sqlite_full_text_search_example.sql
Last active August 31, 2024 19:45
SQlite full text search example, link to the article:
-- Table that store hotels reviews
CREATE TABLE hotels_reviews (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
review TEXT NOT NULL
);
-- As SQLite index content on a virtual table,
-- We need to create a virtual table for hotels_reviews
-- I use the last extension fts5 for full text searching https://www.sqlite.org/fts5.html
-- I use the "porter" tokenizer, check this link for definition: https://www.sqlite.org/fts3.html#tokenizer
@jbinfo
jbinfo / BaseAdminCrudController.php
Created August 3, 2024 10:25
Symfony EasyAdmin customize form with events
<?php
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
class BaseAdminCrudController extends AbstractCrudController
{
public function edit(AdminContext $context)
{
$event = new BeforeCrudActionEvent($context);
$this->container->get('event_dispatcher')->dispatch($event);
@jbinfo
jbinfo / auto_twitter_follow_script.js
Last active February 5, 2023 04:03
auto twitter follow script
;(function(global, $) {
/**** PARAMETERS BLOCK ************************/
var miniFollowersToIgnore = 0,
miniFollowingToKeep = 1000,
secondes = Math.floor((Math.random() * 10) + 10),
enableBioFilter = false,
userBioKeywords = [
'devel', 'code', 'analysis',
'cloud', 'unix', 'tech', 'computer',
'.net', 'freelance', 'guru', 'UX',
@jbinfo
jbinfo / scrapy_csv_exporter.md
Last active March 7, 2022 05:49
How to create a Scrapy CSV Exporter with a custom delimiter and order fields

Create a scrapy exporter on the root of your scrapy project, we suppose the name of your project is my_project, we can name this exporter: my_project_csv_item_exporter.py

from scrapy.conf import settings
from scrapy.contrib.exporter import CsvItemExporter

class MyProjectCsvItemExporter(CsvItemExporter):

    def __init__(self, *args, **kwargs):
 delimiter = settings.get('CSV_DELIMITER', ',')
@jbinfo
jbinfo / oracle_hierarchical_queries.md
Last active March 27, 2021 02:33
Oracle hierarchical queries: How to find parents of a list of child, tree

In this Gist will show you how to get parents of a list of child from an Oracle database.

Let's start with the table below:

Child Parent
1 NULL
2 1
3 2
4 3
@jbinfo
jbinfo / unique_lines_between_two_files
Last active January 30, 2020 19:34
Find unique lines between two files - Ubuntu
fgrep -vf /path/to/file1 /path/to/file2
@jbinfo
jbinfo / closespider.py
Last active June 7, 2019 06:40
CloseSpider is a Scrapy extension that force spider to be closed after it reach a drop items limit
# -*- coding: utf-8 -*-
# MIT License (c) Lhassan Baazzi <baazzilhassan@gmail.com>
from collections import defaultdict
from twisted.internet import reactor
from scrapy import signals
class CloseSpider(object):
def __init__(self, crawler):
var buttons = $('div[role=dialog]').find('button:contains(Follow)').filter(function() {
return $(this).text().toLowerCase() === 'follow';
});
$.each(buttons, function(idx, itm) {
var secondes = Math.floor((Math.random() * 10) + 3);
setTimeout(function() {
$(itm).trigger('click');
}, duration = secondes * 1000);