Skip to content

Instantly share code, notes, and snippets.

@AngeloR
AngeloR / getArgs.js
Created December 10, 2019 14:32
get all arg names passed to a function
function getArgs(func) {
// First match everything inside the function argument parens.
var args = func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
// Split the arguments string into an array comma delimited.
return args.split(',').map(function(arg) {
// Ensure no inline comments are parsed and trim the whitespace.
return arg.replace(/\/\*.*\*\//, '').trim();
}).filter(function(arg) {
// Ensure no undefined values are added.
+-------------------+
| users |
+-------------------+
| |
| id (int) |
| username (string) |
| password (string) |
| |
+-------------------+
class Rest_Client {
/**
*
* Perform any get type operation on a url
* @param string $url
* @return string The resulting data from the get operation
*/
public static function get($url) {
$ch = curl_init();
<?php
include("Yubikey.php")
$id = 00000;
$signature = 'yoursignature';
if(isset($_POST) && array_key_exists('otp', $_POST)) {
$token = new Yubikey($id, $signature);
if($token->verify($_POST['otp'])) {
echo 'Verified!';
}
@AngeloR
AngeloR / gist:6605487
Last active December 23, 2015 08:09
Simple Node.js HTT server
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '293.122.113.1');
console.log('Server running at http://293.122.113.1:1337/');
@AngeloR
AngeloR / fargo2json.php
Last active December 17, 2015 11:19
Grab an OPML file generated by Fargo.io and return an JSON array of the outline
<?php
$OPML = 'ENTER THE LINK TO YOUR OPML FILE';
$rawOPML = file_get_contents($OPML);
$doc = new DOMDocument();
$doc->loadXML($rawOPML);
$arrayOutline = OPMLToArray($doc->childNodes->item(0));
$jsonOutline = json_encode($arrayOutline);
@AngeloR
AngeloR / gist:1672212
Created January 24, 2012 19:58 — forked from anonymous/gist:1672186
Jbom - pastebin.com/uEEvZEpK
//JAVASCRIPT
$(document).ready(function(){
CLICKIT_core.init();
CLICKIT_contract_form.init();
});
var CLICKIT_config = {
URLs : {
checkName : 'index.php/users/getnames'
}
@AngeloR
AngeloR / gist:948647
Created April 29, 2011 17:17
Lemondoo - delete_todo
<?php
function delete_todo($id) {
if(is_numeric($id) && !empty($id)) {
$sql = 'delete from todo where todo_id = '.$id;
return json(db($sql));
}
}
?>
@AngeloR
AngeloR / gist:948645
Created April 29, 2011 17:14
Lemondoo - update_todo
<?php
function update_todo($id) {
if(is_numeric($id) && !empty($id)) {
$todo_title = mysql_real_escape_string($_POST['title']);
$todo_text = (empty($_POST['todo_text']))?$todo_title:mysql_real_escape_string($unescaped_string);
$completed = bool($_POST['completed']);
if(!empty($todo_title)) {
$sql = 'update todo set todo_title = "'.$todo_title.'", todo_text = "'.$todo_text.'", completed = '.$completed.' where todo_id = '.$id;
return json(db($sql));
@AngeloR
AngeloR / gist:948632
Created April 29, 2011 17:08
Lemondoo - get_todo
<?php
function get_todo($id) {
if(is_numeric($id) && !empty($id)) {
$sql = 'select * from todo where todo_id = '.$id;
return json(db($sql));
}
}
?>