Skip to content

Instantly share code, notes, and snippets.

@jtreminio
jtreminio / all-tree-paths.py
Created April 20, 2025 15:12
structy | all tree paths iterative
class Node:
def __init__(self, val):
self.val = val
self.left: Node | None = None
self.right: Node | None = None
def all_tree_paths(root: "Node") -> list[str]:
result = []
stack = [(root, [root.val])]
def get_combinations(input: list) -> list:
"""
get_combinations() can be used to find all possible combinations of a
flat list of values.
"""
# start with a non-empty payload just to get the initial for loop going
combinations = [[]]
# iterate over every value once
@jtreminio
jtreminio / ApiAppApi.php
Created November 24, 2021 15:23
openapi-generator creates a PHP SDK where the OAuth typehints in the `OpenAPI\Client\Api\ApiAppApi::apiAppCreate()` method are not namespaced
<?php
/**
* ApiAppApi
* PHP version 7.3
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
const ServiceCategory = {
"Application Engine": 0,
"Web Server": 0,
"Database Engine": 0,
"Other": 0,
};
const ServiceCategories = Object.keys(ServiceCategory);
interface ServiceType {
I've deployed to two regions:
us-east-1
us-west-1
I've configured an instance in each region as my strongswan VPN, and they can connect to the other
region's instance just fine through their EIP.
Both regions have a single VPC with a private and a public subnet.
@jtreminio
jtreminio / gist:bcb78ccb97978a2cbd9e
Last active February 2, 2017 18:27
Sample PuPHPet Apache vhost conf file
# ************************************
# Vhost template in module puppetlabs-apache
# Managed by Puppet
# ************************************
<VirtualHost *:80>
ServerName awesome.dev
## Vhost docroot
DocumentRoot "/var/www/awesome/web"
[02:58 PM]-[vagrant@packer-virtualbox-iso]-[/usr/local/rvm/gems/ruby-1.9.3-p547/bin]
$ ./puppet --version
/usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'puppet' (>= 0) among 19 total gem(s) (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from ./puppet:22:in `<main>'
from /usr/local/rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
<?php
interface Baz
{
public function BazBaz();
}
=========
interface Bar extends Baz

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
$ sudo iptables -v -L
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination