Skip to content

Instantly share code, notes, and snippets.

View kirilkirkov's full-sized avatar
🎯
Focusing

Kiril Kirkov kirilkirkov

🎯
Focusing
View GitHub Profile
@kirilkirkov
kirilkirkov / php-chatgpt-curl.php
Last active February 21, 2023 16:58
Access ChatGPT through PHP Using Curl Api. Easy Use of GPT3 API with Curl
<?php
define("CHATGPT_API_KEY", "your-key-goes-here");
$data = array(
"model" => "text-davinci-003",
"prompt" => "What is PHP and how it works?", // Your question or request
"temperature" => 0.5,
"max_tokens" => 500
);
@kirilkirkov
kirilkirkov / class-click-outside.js
Last active February 4, 2023 11:40
DOM Element Click OutSide handler with Vanilla JS. Easy integration in Vue or React. ES6 Import Module Type
/**
* Make new class instance for each element
*/
class ClickOutSide {
constructor() {
this.outsideHandler = null
this.element = null
this.documentEvent = (evt) => {
const flyoutEl = this.element
let targetEl = evt.target // clicked same el
@kirilkirkov
kirilkirkov / gist:b13baec4b5142a527399693f8829547d
Created June 21, 2016 07:20
Difference between png-Interlaced, jpg-progressive AND png-non-Interlaced, jpg-baseline
Interlaced image loads an early degraded version of the whole image as soon as possible and then progressively renders the image to clear state.
Non-interlaced image will load up in tiles showing clear image in each tile as it progresses to load in the image.
For .jpg the interlaced = progressive and not interlaced = baseline.
@kirilkirkov
kirilkirkov / unit-vs-feature-test.md
Created December 1, 2022 13:06
Laravel tests simple explain in two words..

What is unit test?

Unit Tests are written from a programmers perspective. They are made to ensure that a particular method (or a unit) of a class performs a set of specific tasks.

What is feature test?

Functional Tests are written from the user's perspective. They ensure that the system is functioning as users are expecting it to.

@kirilkirkov
kirilkirkov / JavaScript-Stranges.md
Created November 25, 2022 09:04
We All Love JavaScript with its stranges..

JavaScript Strange Behaviors

  • console.log(typeof NaN) // Number
  • console.log(Math.min() > Math.max()) // TRUE
  • console.log(9 - '1') // 8
  • console.log(9 + '1') // 91
  • console.log(Boolean(0.1 + 0.5 === 0.6)) // TRUE
  • console.log(Boolean(0.1 + 0.2 === 0.2)) // FALSE
  • console.log(! + []) // TRUE
@kirilkirkov
kirilkirkov / Streams-VS-Buffer.md
Last active November 19, 2022 15:53
When to use streams and when buffer - Usage in NodeJS

Whats the difference between Streams and Buffer?

  • Buffer is temporary placeholder in memory (ram/disk) on which data can be dumped and then processing can be done.
  • Stream is a sequence of data elements. like when you typing something in your computer then when you press the keys it will form a data stream and then it goes to the processor for processing.

Stream can be processed through Buffer.

What are buffers and streams in REST API?

A buffer is a temporary memory that a stream takes to hold some data until it is consumed.

@kirilkirkov
kirilkirkov / gist:60ff6d27b2a2da03d42cde85281f6330
Created September 7, 2022 15:46
Instagram in-app browser (WebView) errors with window.opener or window popups
Did you know that instagram webview (when click some link from private message or post) , the window.opener is null?
This is privacy reason.. so if you wants to close window popups, should use history.back(); instead of window.close();,
also the postMessage will not works with window.opener.postMessage ....
@kirilkirkov
kirilkirkov / Kali-Linux-MacBook-Air-2017-Wifi-Drivers
Last active July 17, 2022 06:05
How to use MacBook Air 2017 - WiFi broadcom default wifi adapter on Kali Linux 2022.2
sudo apt-get update
sudo apt install broadcom-sta-dkms
sudo modprobe -r b43 ssb wl
sudo modprobe wl
This will enable you wifi ;) Enjoy!
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const isDevelopment = true
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: {
app: './resources/js/entry-server.js',
},
mode: isDevelopment ? 'development' : 'production',
@kirilkirkov
kirilkirkov / gist:dcc281f642c179df608e04c24dedbeb6
Created February 27, 2022 07:48
When is admin_init Action ran?
admin_init is triggered when a user accesses the admin area. It is the first hook to be triggered. It can be used in cases like:
We want to block access to the admin panel for users that do not have the Administrator Role.
We want automatic redirection of users lacking the specified capability, to the homepage.
We want to register a new setting for use by a plugin.