Skip to content

Instantly share code, notes, and snippets.

View azihassan's full-sized avatar
🦆

Azi Hassan azihassan

🦆
View GitHub Profile
@azihassan
azihassan / slitaz_packager.php
Created July 11, 2012 22:04
Package downloader for Slitaz in PHP. This is useful for people who can't get their internet connection to work on Slitaz and want an easy way to download their packages (and dependencies) on Windows.
<?php
define('USAGE', 'Usage : php '.$argv[0].' --package package_name [--path '.__DIR__.'] [--dependencies] [--overwrite] [--nocache] [--help]'.PHP_EOL);
if($argc == 1)
{
echo USAGE;
exit;
}
try
@azihassan
azihassan / srt_synch.php
Created July 12, 2012 17:31
Subtitle synchroniser. Goes through the .srt file and edits the hh:mm:ss --> hh:mm:ss as per the user's specificatoins.
<?php
$begin = microtime(TRUE);
$args = parse_argv($argv);
echo PHP_EOL.'Processing the file...'.PHP_EOL;
$contents = file($args['in'], FILE_IGNORE_NEW_LINES);
$difference = $args['diff'];
$out = isset($args['out']) ? $args['out'] : $args['in'];
@azihassan
azihassan / imgur_album.php
Created July 15, 2012 12:04
Imgur album scraper
<?php
try
{
list($id, $path) = parse_argv($argv);
$links = get_links($id);
if(($link_count = sizeof($links)) === 0)
{
echo 'No links were found.'.PHP_EOL;
@azihassan
azihassan / NeymarS.d
Created September 26, 2014 15:53
Recursively copies the given "file" to all the directories inside the "root" folder. http://www.hackforums.net/showthread.php?tid=4462689&pid=42561339
import std.stdio;
import std.file;
import std.path : buildPath;
import std.exception : enforce;
int main(string[] args)
{
string root;
string file;
@azihassan
azihassan / sqli.php
Created May 4, 2015 10:14
SQLi demonstration.
<?php
session_start();
$conn = mysqli_connect('localhost', 'root', '', 'test');
if(mysqli_connect_error())
{
echo '<p>Connexion à la base de données échouée : ' . mysqli_connect_error() . '</p>';
exit;
}
?>
loadDetailsButton.click ~= &loadDetailsButton;
//...
void loadDetailsCallback(Control sender, EventArgs ea)
{
if(!urlBox.text)
{
msgBox("No URL was provided.", "Error", MsgBoxButtons.OK, MsgBoxIcon.INFORMATION);
urlBox.focus();
@azihassan
azihassan / filecomp.php
Last active December 14, 2015 19:33
Memory-friendly function that compares two files and returns a boolean
<?php
if(compare_files('file1', 'file2'))
echo 'Files are similar', PHP_EOL;
else
echo 'Files are different', PHP_EOL;
function compare_files($a, $b, $buf_size = 1048576)
{
if($a === $b)
return true;
@azihassan
azihassan / xml.php
Created December 16, 2015 15:59
SimpleXML usage example
<form method = "post">
<p><label>Nom : <input type = "text" name = "nom" /></label></p>
<p><label>Prenom : <input type = "text" name = "prenom" /></label></p>
<p><label>CIN : <input type = "text" name = "cin" /></label></p>
<p><label>Adresse : <input type = "text" name = "adresse" /></label></p>
<p><label>Email : <input type = "text" name = "email" /></label></p>
<p><input type = "submit" value = "Convertir" /></p>
</form>
<?php
#include <iostream>
#include <algorithm>
#include <array>
#include <utility>
#include <map>
#include <vector>
#include <queue>
struct Point
{
#include <iostream>
#include <vector>
#include <SFML/Graphics.hpp>
class Scroller
{
sf::Texture texture;
sf::IntRect rect;
public:
Scroller(sf::Texture& texture)