Skip to content

Instantly share code, notes, and snippets.

View deividaspetraitis's full-sized avatar

Deividas Petraitis deividaspetraitis

View GitHub Profile
@deividaspetraitis
deividaspetraitis / madox2vim-ai.diff
Created July 19, 2023 08:28
Path for madox2/vim-ai to work with Azure AI.
diff --git a/py/chat.py b/py/chat.py
index 93d31bf..1980681 100644
--- a/py/chat.py
+++ b/py/chat.py
@@ -69,7 +69,7 @@ try:
**openai_options
}
printDebug("[chat] request: {}", request)
- response = openai_request('https://api.openai.com/v1/chat/completions', request, http_options)
+ response = openai_request('https://engineering-ai.openai.azure.com/openai/deployments/engineering/chat/completions?api-version=2023-03-15-preview', request, http_options)
@deividaspetraitis
deividaspetraitis / flash.sh
Created July 10, 2022 09:44 — forked from nicinabox/flash.sh
Find the Pro Micro serial port automatically and flash it
#!/bin/bash
# Usage
# ./flash.sh path/to/your.hex
TARGET=$1
ls /dev/tty* > /tmp/1
echo "Reset your Pro Micro now"
package main
import (
"fmt"
"time"
"runtime"
"context"
)
func main() {
package main
import (
"fmt"
"time"
"runtime"
)
func main() {
package main
import (
"fmt"
"encoding/json"
"reflect"
)
type circle struct {
Radius float64 `json:"radius"`
@deividaspetraitis
deividaspetraitis / laravel-mass-assignment.php
Last active September 10, 2020 08:24
How to bypass mass assignment protection in laravel?
<?php
class Article extends \Illuminate\Database\Eloquent\Model
{
/**
* All available model properties ( DB fields )
*
* @var array $schema
*/
protected $schema = [
@deividaspetraitis
deividaspetraitis / MailFake.php
Created November 16, 2017 18:26
Laravel Fake Mailable Fails After Few Emails Inside Application Are Sent.
<?php
class Test
{
/**
* Api Helper
*
* @var \Helper\Api
*/
protected $api;
@deividaspetraitis
deividaspetraitis / User.php
Created November 9, 2017 11:49
Default laravel generated User model
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
@deividaspetraitis
deividaspetraitis / lumen-filesystem.md
Created October 19, 2017 09:36
Lumen flysystem ( filesystem ) integration

Lumen flysystem integration

By default lumen doesn't support laravel file system. In order to integrate to lumen we need follow these instructions:

  1. composer require league/flysystem
  2. Copy filesystems config file from Laravel ( https://github.com/laravel/laravel/blob/master/config/filesystems.php ) to your local Lumen installation document_root/config
  3. Bind filesystem to IoC for example in document_root/bootstrap/app.php by adding this code lines:

`` $app->singleton('filesystem', function ($app) {

@deividaspetraitis
deividaspetraitis / Region.php
Last active October 13, 2017 10:58
Geo regions with example data
<?php namespace Modules\Geo\Entities\MariaDB;
use App\Entities\MariaDB\Model;
use Grimzy\LaravelMysqlSpatial\Types\Geometry;
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
use Illuminate\Database\Eloquent\SoftDeletes;
class Region extends Model
{
use SoftDeletes, SpatialTrait;