Skip to content

Instantly share code, notes, and snippets.

View iampato's full-sized avatar
🖐️
Hey

Patrick waweru iampato

🖐️
Hey
View GitHub Profile
@iampato
iampato / conf.d
Created December 27, 2022 12:31
nginx api gateway setup
server {
server_name localhost;
listen 80;
location ~ /users/[12][0-9]+ {
proxy_pass http://localhost:8802;
}
location ~ /products/[12][0-9]+ {
@iampato
iampato / default
Created December 22, 2022 17:48
redirect with ngin
server {
server_name www.example.com;
# return 301 https://google.com$request_uri;
location / {
proxy_pass http://localhost:PORT;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
@iampato
iampato / main.dart
Created December 9, 2022 12:49
Here is a possible solution for a Dart function that randomly generates unique names without using predefined lists of names:
import 'dart:math';
// A set to store the generated names.
final Set<String> generatedNames = Set();
String generateUniqueName() {
// Generate a random first and last name.
final firstName = generateRandomName();
final lastName = generateRandomName();
@iampato
iampato / main.dart
Created December 2, 2022 08:35
A flutter extension on Row to add spaces between each child
/// extension on Row
/// to add a space between each child
extension RowExtension on Row {
Row addSpaceBetweenChildren(double space) {
final children = <Widget>[];
for (var i = 0; i < this.children.length; i++) {
children.add(this.children[i]);
if (i != this.children.length - 1) {
children.add(SizedBox(width: space));
}
@iampato
iampato / dotted_border.dart
Last active July 6, 2022 14:07
Creating a dotted border container
import 'dart:math' as math;
import 'package:flutter/material.dart';
class DashRectPainter extends CustomPainter {
double strokeWidth;
Color color;
double gap;
DashRectPainter(
{this.strokeWidth = 5.0, this.color = Colors.red, this.gap = 5.0});
@iampato
iampato / RabbitManager.java
Created April 6, 2022 06:00
Rabbit mq logic manager
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.NonNull;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
class MapsUtils{
static double calculatePolygonArea(List coordinates) {
double area = 0;
if (coordinates.length > 2) {
for (var i = 0; i < coordinates.length - 1; i++) {
var p1 = coordinates[i];
var p2 = coordinates[i + 1];
area += convertToRadian(p2.longitude - p1.longitude) *
@iampato
iampato / increment.dart
Created October 6, 2021 12:20
Mula example
import 'package:flutter/material.dart';
class Increment extends StatefulWidget {
const Increment({Key? key}) : super(key: key);
@override
State<Increment> createState() => _IncrementState();
}
class _IncrementState extends State<Increment> {
@iampato
iampato / main.txt
Created September 15, 2021 15:25
KPLC token dataset
2221 8276 2247 0362 2220
1803 2971 2398 5334 5278
5035 3788 0077 3951 5883
3836 8566 4431 0052 8914
@iampato
iampato / main.go
Created August 30, 2021 07:40
Go serve react build dir
package main
import (
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "./build/index.html")