Skip to content

Instantly share code, notes, and snippets.

@kstefan
kstefan / Invoke-RestMethod.txt
Last active June 5, 2019 08:06
Call rest api via Invoke-RestMethod (PowerShell)
Invoke-RestMethod -Uri 'http://example.com' `
-Method Post -ContentType 'application/json' -Body '{"hello": "world"}'

Keybase proof

I hereby claim:

  • I am kstefan on github.
  • I am karelstefan (https://keybase.io/karelstefan) on keybase.
  • I have a public key ASBGbKOgKnAbOAEwlYYPP5sJAToyUNuvCctsw52FtJnv-Ao

To claim this, I am signing this object:

@kstefan
kstefan / create-elastic-user.sh
Created February 22, 2018 18:04
Create Elasticsearch User
curl -XPOST -u elastic 'http://elastic:9200/_xpack/security/role/my_role' -H "Content-Type: application/json" -d '{
"indices" : [
{
"names" : [ "indexPrefix*" ],
"privileges" : [ "all" ]
}
]
}'
curl -XPOST -u elastic 'http://elastic:9200/_xpack/security/user/my_username' -H "Content-Type: application/json" -d '{
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
@kstefan
kstefan / doctrine.global.php
Created August 15, 2015 17:37
ZF2 Doctrine naming strategy
<?php
return [
'doctrine' => [
/* ... */
'configuration' => [
'orm_default' => [
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'generate_proxies' => true,
@kstefan
kstefan / gist:d106ac428c7dcabae6e6
Created February 23, 2015 15:30
PL/SQL recalculate tree
# SET @@session.max_sp_recursion_depth = 255;
# CALL recalculateTree(NULL, 0, 0, @index);
CREATE PROCEDURE recalculateTree(IN parent INT, IN i INT, IN depth INT, OUT ri INT)
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE n_id INT;
DECLARE n_parent_id INT;
@kstefan
kstefan / date.cs.yml
Created January 24, 2015 20:06
Czech translations for Twig_Extensions_Extension_Date
diff.ago.second: '{0}Právě teď|{1}Před %count% vteřinou|[1,Inf]Před %count% vteřinami'
diff.ago.minute: '{1} Před %count% minutou|[1,Inf] Před %count% minutami'
diff.ago.hour: '{1} Před %count% hodinou|[1,Inf] Před %count% hodinami'
diff.ago.day: '{1} Před %count% dnem|[1,Inf] Před %count% dny'
diff.ago.month: '{1} Před %count% měsícem|[1,Inf] Před %count% měsíci'
diff.ago.year: '{1} Před %count% rokem|[1,Inf] Před %count% roky'
@kstefan
kstefan / gist:5965728
Created July 10, 2013 12:03
Callback validator example
<?php
public function getInputFilterSpecification()
{
return [
'amount' => [
'required' => true,
'validators' => [
new Validator\GreaterThan([
'min' => 0,
@kstefan
kstefan / gist:5450864
Last active December 16, 2015 14:48
Expample of using Doctrine\Common\Collections\Criteria
<?php
class ExpenseStatement
{
/**
* @param ExpenseStatementState|string $state
* @return ExpenseStatementEvent
*/
public function getLastEvent($state)
{
@kstefan
kstefan / common.twig
Last active December 15, 2015 14:18
Example of using macros in Twig
{% macro valueOrDefault(value, default, attribute) %}
{% if value %}
{{ attribute ? attribute(value, attribute) : value }}
{% else %}
{{ default }}
{% endif %}
{% endmacro %}
{% macro optionalValue(value, attribute) %}
{% import _self as self %}