Skip to content

Instantly share code, notes, and snippets.

@andrzj
andrzj / docker-compose.yml
Last active March 1, 2020 01:47 — forked from pantsel/docker-compose.yml
example docker-compose.yml for kong, postgres and konga
version: "2.1"
networks:
kong-net:
driver: bridge
services:
#######################################
# Postgres: The database used by Kong
@andrzj
andrzj / API.md
Created November 27, 2018 15:34 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@andrzj
andrzj / gitlab-ci.yml
Last active September 7, 2018 17:11
Gitlab CI - Google Cloud
variables:
GCP_PROJECT_ID: ****
GCLOUD_SERVICE_KEY: ****
NPM_TOKEN: ****
image: andrzj/gcloud-ci
cache:
untracked: true
key: "$CI_BUILD_REF_NAME"
@andrzj
andrzj / proxy-config.md
Last active August 1, 2018 15:10
Proxy configuration by command line for some tools

Yarn configuration

$ yarn config set proxy http://username:password@host:port

$ yarn config set https-proxy http://username:password@host:port

NPM configuration

$ npm config set proxy http://username:password@host:port

@andrzj
andrzj / mongo.js
Last active June 8, 2018 10:59
Mongo querys
// Filter all URL's that have "/blogs/" in it AND don't have "em-foca". Result limited and pretty
db.assets.find({
$and:[
{ url: /\/blogs\// },
{ url: {$not: /em-foca/}},
]
}).limit(2).pretty()
// Filter and count all URL's that have "/blogs/" in it
db.assets.find({url: /^http:\/\/(.*)\/blogs\//}).count()
@andrzj
andrzj / index.js
Created December 28, 2017 20:16
Ways to check if something is changed on your page (client side)
$('#form').data('serialize',$('#form').serialize()); // On load save form current state
$(window).bind('beforeunload', function(e){
if($('#form').serialize()!=$('#form').data('serialize'))return true;
else e=null; // i.e; if form state change show box not.
});
// *******
var initial_form_state = $('#myform').serialize();
@andrzj
andrzj / php_curl_authorization.php
Created October 4, 2017 14:12
PHP cURL with authorization
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $urlAuthComentarios,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_USERAGENT=>'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)',
@andrzj
andrzj / post_json_curl.php
Created October 2, 2017 19:10
POSTing JSON Data With PHP cURL
$data = array("name" => "Hagrid", "age" => "36");
$data_string = json_encode($data);
$ch = curl_init('http://api.local/rest/users');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
@andrzj
andrzj / file_get_contents_post_json_cookie.php
Last active October 2, 2017 19:08
Posting JSON and Cookie via file_get_contents
$urlC = "http://test.com/api/v1/graph/ql";
$jsonData = '{"query": "query CoralAdmin_Dashboard($from: Date!, $to: Date!) {\n assetsByActivity: assetMetrics(from: $from, to: $to, sortBy: ACTIVITY) {\n ...CoralAdmin_Metrics\n }\n}\n\nfragment CoralAdmin_Metrics on Asset {\n id\n title\n url\n created_at\n commentCount\n }\n","variables": { "from": "2017-09-18T10:01:58.350Z", "to": "2017-09-21T18:06:58.350Z" }, "operationName": "CoralAdmin_Dashboard" }';
$options = array(
'http' => array(
'method' => 'POST',
'content' => $jsonData,
'header'=> "Content-Type: application/json\r\n" .
"Accept: application/json\r\n" .
@andrzj
andrzj / index.html
Created July 3, 2017 18:10
Detect a click in a cross domain iframe
<iframe id="iframe" src="//example.com"></iframe>
<div id="message"></div>