Skip to content

Instantly share code, notes, and snippets.

View jbinfo's full-sized avatar

Lhassan Baazzi jbinfo

View GitHub Profile
@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 / sqlite_full_text_search_example.sql
Last active July 30, 2022 05: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 / 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);

Multiple PHP version under Ubuntu 14.04

Update your machine

apt-get update
apt-get upgrade

Install some dependencies

apt-get install build-essential

We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 21 columns, instead of 7. in line 3.
id,username,fullname,emails,fbPage,externalUrl,biography,followedBy,follows,isPrivate,isVerified,isBusinessAccount,businessCategory,businessEmail,businessPhone,businessAddressStreet,businessAddressZipcode,businessAddressCity,businessAddressRegion,businessAddressCountryCode,hashtags
5734709815,tasteititalian,Taste IT,,,https://m.facebook.com/TasteItitaliantakeaway/,"‼️The first independent Italian Gelateria in Greater Manchester ‼️
Stonebaked pizza 🍕 artisan gelato 🍦 baked pasta 🍝 tasty arancini.",430,146,0,0,1,Restaurants,tasteitsalford@gmail.com,441616980410,69 BLACKFRIARS ROAD,M3 7DB,City of Salford,,GB,pizzauk
3667203339,mobipizzeria,🇮🇹Mobile Wood Fired Pizza🇬🇧,,,https://www.facebook.com/mobipizzeria/,"Mobile pop-up wood fired pizza UK-wide.
We cater for weddings, corporate events, private parties, birthdays, festivals, concerts, fetes, and many more",7486,3492,0,0,1,Restaurants,info@mobipizzeria.co.uk,443300100270,,SG191RB,St Neots,,GB,pizzauk
2986836082,zialuciapizza,Zia Lucia,,,http://www.zialucia.com/,
var secondes = Math.floor((Math.random() * 10) + 3);
var duration = secondes;
$('#activity-popup-dialog-body').find('.not-following').find('button.follow-button').each(function() {
var _this = this;
setTimeout(function() {
$(_this).trigger('click');
}, duration * 1000);
duration += secondes;