Skip to content

Instantly share code, notes, and snippets.

View n-eq's full-sized avatar

Nabil Elqatib n-eq

View GitHub Profile
@n-eq
n-eq / quote-tweet-graph.py
Last active March 21, 2020 14:55
Draw a graph of all the quote tweets (including children quote tweets) of a particular tweet (Depth First Search)
"""
@author: marrakchino
## Notes
* I used both tweepy and twitter because none of the two libraries is extensive enough to suit my needs:
1. Search for a specific tweet using its `id`, tweepy does this perfectly
2. Use a raw query (as in the web app), in particular to find quote tweets of a tweet, twitter does this perfecetly
* To my great disapointment, I learned that `The Search API is not complete index of all Tweets, but instead an index of recent Tweets.
The index includes between 6-9 days of Tweets.` This means this script would only work when applied on a 'recent' tweet.
@n-eq
n-eq / deloldtweets.py
Last active March 21, 2021 13:06 — forked from intentionally-left-nil/deloldtweets.py
Delete old tweets based on twitter archive
#!/bin/python3
# Fork of https://gist.github.com/davej/113241
# Requirements:
# - twitter API credentials (replace the correponding variables)
# - tweet.js file you get by extracting your twitter archive zip file (located in data/)
# License : Unlicense http://unlicense.org/
import tweepy
import
@n-eq
n-eq / nwkskey.c
Last active October 4, 2017 20:23
A C program to calculate LoRaWAN's Network Session Key (NwSKey) using mbed TLS
/*
* This C program calculates LoRaWAN's network session key (NwkSKey) using
* mbed TLS.
* To use it, you should provide the following parameters in this order when
* executing the program:
* AppKey: An AES-128 key
* AppNonce: A random 3 byte value
* NetID: A network identifier
* DevNonce: A 2 byte nonce
* Example:
@n-eq
n-eq / main.cpp
Last active August 26, 2017 14:09
mbed-os_threads
#include "mbed.h"
static void get_thread_id(){
osThreadId thread_id = osThreadGetId();
printf("main thread Id: %p\r\n", thread_id);
}
int main(){
get_thread_id();
@n-eq
n-eq / elbotolo_match_follow.py
Last active May 10, 2017 16:51
CLI match follow from elbotola.com website
#!/usr/bin/env python
# author: marrakchino (nabilelqatib@gmail.com)
"""
MIT License
Copyright (c) 2017 marrakchino
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@n-eq
n-eq / delete_rotten_downloads.py
Last active May 13, 2017 10:23
Delete rotten downloads on a Window host
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 25 09:11:46 2017
@author: marrakchino
based on the original idea (and implementation) of Cory Engdahl (https://www.quora.com/As-a-programmer-what-tasks-have-you-automated-to-make-your-everyday-life-easier/answer/Cory-Engdahl?srid=utoTd)
"""
import os
import time
@n-eq
n-eq / cache_blocking.py
Last active April 23, 2017 13:16
Illustration of "cache blocking" optimization technique on a 10000x10000 matrix fill.
import numpy as np
import matplotlib.pyplot as plt
import timeit
plt.ion()
n=10000
block=[i+1 for i in range(1000)]
time=[]
tab=[[0 for i in range(n)] for j in range(n)]
@n-eq
n-eq / MatrixTranspose.java
Created April 19, 2017 10:40
Illustration of matrix transposition time performance effects due to cache configuration
class MatrixTranspose {
public static void matrixTranspose(){
long startTime, elapsedTime;
int n = 10000;
int a[][] = new int[n][n];
int b[][] = new int[n][n];
// #######################################
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
@n-eq
n-eq / cachecache.c
Created April 16, 2017 12:40
Cache illustration
#include <stdio.h>
#include <stdlib.h>
#define N 2000
#define M 1000
int t[M][M] = {{0}};
int main(){
for (int i = 0; i < N; i++)