Skip to content

Instantly share code, notes, and snippets.

View jesobreira's full-sized avatar
💭
Implementing new bugs to fix later.

Jefrey Sobreira Santos jesobreira

💭
Implementing new bugs to fix later.
View GitHub Profile
@jesobreira
jesobreira / monitor.php
Last active October 25, 2023 13:26
Server Monitor
<?php
/*
The aim is to create a functional server monitor based on the one
showed on Mark Zuckerberg's monitor on The Social Network movie.
Run so:
php monitor.php
Notes:
- The server LogFormat must be "Common Log Format" (%h %^[%d:%^] "%r" %s %b)
@jesobreira
jesobreira / rangeparser.au3
Last active January 12, 2016 19:33
Range
#cs
Range parser
This function parser printing-like intervals (like "1,2,3-5") and returns an array with every page number as item.
@author Jefrey S. Santos <jefrey[at]jefrey.ml>
#ce
Func rangeparser($interval)
$interval = StringReplace($interval, " ", "")
If Not StringRegExp($interval, "([0-9\-\,])") Then Return SetError(1, 0, False)
$interval = StringSplit($interval, ",")
@jesobreira
jesobreira / currency.js
Last active August 30, 2015 18:57
How to get currency using Javascript or PHP
/*
@author Jefrey S. Santos <github.com/jesobreira>
*/
function currency(icoin1, icoin2, value, callback) {
if(typeof value == 'undefined') value = 1;
icoin1 = icoin1.toUpperCase();
icoin2 = icoin2.toUpperCase();
value = parseFloat(value);
@jesobreira
jesobreira / example.php
Created August 1, 2015 06:40
Using bitwise operators to store privs
<?php
$user_rights = 3; // 1+2 (taken from database)
if(rights::can_read($user_rights)) echo "User can read\n";
if(rights::can_write($user_rights)) echo "User can write\n";
if(rights::can_modify($user_rights)) echo "User can modify\n";
class rights {
static $READ = 1;
@jesobreira
jesobreira / gist:4e8b5e4a1fa2b32676de
Created July 5, 2015 15:11
CmdLine arguments parser (get values/existence/flags)
<?php
/*
Based on CmdLine UDF for AutoIt (also mine): https://www.autoitscript.com/forum/topic/169610-cmdline-udf-get-valueexistenceflag/
*/
class cmdline {
function get($sKey, $mDefault = Null) {
global $argv,$argc;
for($i = 1; $i <= ($argc-1); $i++) {
@jesobreira
jesobreira / makeslug.js
Last active July 14, 2020 13:09
Create slugs with accented chars in PHP and Javascript
/*
* Javascript makeslug()
* by J. Santos <jefrey[at]jefrey[dot]ml>
*/
/*
Usage:
string makeslug( string val [, string replaceBy = "-" ] )
Example: