Skip to content

Instantly share code, notes, and snippets.

View h1k3r's full-sized avatar

Andrii Havryliuk h1k3r

View GitHub Profile
@h1k3r
h1k3r / hostname.lua
Created June 25, 2014 19:52
Lua - get hostname
local _M = {}
function _M.getHostname()
local f = io.popen ("/bin/hostname")
local hostname = f:read("*a") or ""
f:close()
hostname =string.gsub(hostname, "\n$", "")
return hostname
end
return _M
@h1k3r
h1k3r / getElementsByClassName.js
Created July 16, 2014 15:37
Cross-browser js function to retrieve elements by classname from dom. Based on prototype js code
var getElementsByXPath = function(xpath, parentElement) {
var xpathResult = document.evaluate(xpath, parentElement, null, XPathResult.ANY_TYPE, null);
var results = [];
var element = xpathResult.iterateNext();
while(element) {
results.push(element);
element = xpathResult.iterateNext();
}
return results;
}
@h1k3r
h1k3r / detectUrls.js
Created September 19, 2014 15:56
Js function to extract urls from text (with silly regexp)
var detectUrls = function(text) {
var pattern = /(?:^|[\s\n\r])((?:https?:\/\/|www\.)[^\s\n\r]+)/ig,
urls = [],
matches;
while ((matches = pattern.exec(text)) !== null) {
urls.push(matches[1]);
}
return urls;
};
@h1k3r
h1k3r / anonymizeIp.php
Created August 2, 2016 11:49
Anonymize IP according like Google Analytics (according to German laws)
<?php
/**
* Last byte for IPv4 and last 80 bits for IPv6 are set to zero
* @see https://support.google.com/analytics/answer/2763052?hl=en
*/
function anonymizeIp($ip)
{
$binary = inet_pton($ip);
if ($binary === false) {
return false;
@h1k3r
h1k3r / elastic_search_delete_empty_indexes.sh
Created February 3, 2021 11:56
elastic_search_delete_empty_indexes.sh
#!/bin/bash
# Based on https://discuss.elastic.co/t/finding-and-deleting-empty-indexes/172764
# Usage:
# elastic_search_delete_empty_indexes.sh servername:9200 #for dry run
# elastic_search_delete_empty_indexes.sh servername:9200 delete #to really delete
srv=""
delete=false
# API Design Guidelines
# Introduction
The PayPal platform is a collection of reusable services that encapsulate well-defined business capabilities. Developers are encouraged to access these capabilities through Application Programming Interfaces (APIs) that enable consistent design patterns and principles. This facilitates a great developer experience and the ability to quickly compose complex business processes by combining multiple, complementary capabilities as building blocks.
PayPal APIs follow the [RESTful][0] architectural style as much as possible. To support our objectives, we have developed a set of rules, standards, and conventions that apply to the design of RESTful APIs. These have been used to help design and maintain hundreds of APIs and have evolved over several years to meet the needs of a wide variety of use cases.
We are sharing these guidelines to help propagate good API design practices in general. We have pulled extensively from the broader community and believe that it is importan