Skip to content

Instantly share code, notes, and snippets.

Avatar

Lhassan Baazzi jbinfo

View GitHub Profile
@jbinfo
jbinfo / oracle_hierarchical_queries.md
Last active Mar 27, 2021
Oracle hierarchical queries: How to find parents of a list of child, tree
View oracle_hierarchical_queries.md

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
View instagram-auto-follow-activity.js
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);
@jbinfo
jbinfo / unique_lines_between_two_files
Last active Jan 30, 2020
Find unique lines between two files - Ubuntu
View unique_lines_between_two_files
fgrep -vf /path/to/file1 /path/to/file2
View instagram-scraper-sample-output.csv
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/,
@jbinfo
jbinfo / sqlite_full_text_search_example.sql
Last active Jul 29, 2017
SQlite full text search example, link to the article:
View sqlite_full_text_search_example.sql
-- 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
View twitter-auto-follow-activity
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;
View margin and padding for add space between blocks
.mar-left-5 {
margin-left: 5px;
}
.mar-left-10 {
margin-left: 10px;
}
.mar-left-15 {
margin-left: 15px;
@jbinfo
jbinfo / LoginSuccessHandler.php
Last active Feb 5, 2016
Symfony: Right way to get default target URL from session http://goo.gl/SNq3Tr
View LoginSuccessHandler.php
<?php
namespace AppBundle\Security\Authentication\Handler;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface
@jbinfo
jbinfo / closespider.py
Last active Jun 7, 2019
CloseSpider is a Scrapy extension that force spider to be closed after it reach a drop items limit
View closespider.py
# -*- 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):
@jbinfo
jbinfo / gist:ce5600eb7ea276dc194c
Created Dec 16, 2015 — forked from serapheem/gist:4153979
Symfony2 - Redirect one route to another from routing.yml
View gist:ce5600eb7ea276dc194c
SomeRoute:
pattern: /someroute
defaults:
_controller: SomeBundle:Controller:action
AnotherRoute:
pattern: /anotherroute
defaults:
_controller: FrameworkBundle:Redirect:redirect
route: SomeRoute