This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Javascript makeslug() | |
* by J. Santos <jefrey[at]jefrey[dot]ml> | |
*/ | |
/* | |
Usage: | |
string makeslug( string val [, string replaceBy = "-" ] ) | |
Example: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
@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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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, ",") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
All Ini-related functions from AutoIt are available. | |
Just add the paamayim nekudotayim (::) between "Ini" and the functio. | |
E.g.: IniWrite becomes Ini::Write, IniReadSectionNames becomes Ini::ReadSectionNames | |
Docs: https://www.autoitscript.com/autoit3/docs/functions/IniWrite.htm | |
*/ | |
include 'phpini.class.php'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Array.au3> | |
#Region Math | |
; http://sabemosdetudo.com/ciencias/ask67749-O_que_sao_numeros_relativamente_primos.html | |
Func RelativelyPrime($x, $y) | |
Return gdc($x, $y) = 1 | |
EndFunc | |
; http://stackoverflow.com/a/21480873 | |
Func gdc($a, $b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Array.au3> ; need only to do _ArrayDisplay, not needed by the lib | |
_ArrayDisplay(ParseStr("foo=bar&test=lol%20123")) | |
#cs | |
Result is: | |
[0][0] = 2 | |
[0][1] = ununsed | |
[1][0] = foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('SENDGRID_KEY', 'SG.your api key here'); | |
function sendgrid($from, $to, $subject, $message) { | |
$postdata = json_encode( | |
array( | |
'personalizations' => [ | |
[ | |
'to' => [ |
OlderNewer