Skip to content

Instantly share code, notes, and snippets.

View arungpisyadi's full-sized avatar

Arung Isyadi arungpisyadi

View GitHub Profile
@arungpisyadi
arungpisyadi / main.py
Last active June 8, 2024 02:25
How to use Perplexity AI API as the LLM Model for CrewAI in FastAPI framework.
import os
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.requests import Request
from fastapi.encoders import jsonable_encoder
from typing import List
from pydantic import BaseModel
from crewai import Agent, Task, Crew, Process
from langchain_community.chat_models import ChatPerplexity
@arungpisyadi
arungpisyadi / wp-wildcard-subdomains.php
Created August 11, 2021 05:24
A script to allow dynamic site_url and home_url.
<?php
if (!defined('ABSPATH')){
define('ABSPATH', dirname(__FILE__) . '/');
}
$main_domain = get_site_url();
$port = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
$main_domain = str_replace($port, '', $main_domain);
// var_dump($main_domain);
$viewed_domain = $_SERVER['HTTP_HOST'];
@arungpisyadi
arungpisyadi / updateCurrencies.php
Created June 13, 2017 02:49
openexchange.org using laravel
public function updateCurrencies()
{
$listed = DB::table('currencies')->get();
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://openexchangerates.org/api/latest.json?app_id=9dfc90f4fd60462d9088aa0039ccb30d&base=USD');
$result = curl_exec($ch);
curl_close($ch);
@arungpisyadi
arungpisyadi / Functions-658.php
Created December 16, 2016 07:01
Code archive for MyLibrary/Functions.php
/*
public static function leafNode() {
$allCats = Categories::all()->toArray();
for ( $i = 0; $i < count($allCats); $i++) {
$children = DB::table('categoryOrganisations')->where('categoryId', $allCats[$i]['id'])->count();
if($children === 0) {
DB::table('categories')->where('id', $allCats[$i]['id'])->update(['leaf' => 1]);
} else {
DB::table('categories')->where('id', $allCats[$i]['id'])->update(['leaf' => 0]);
}
@arungpisyadi
arungpisyadi / Panel-1473.php
Last active December 16, 2016 04:35
Archive the unused codes from Panel.php
/* if(isset($_POST['slug']) && !empty($_POST['slug'])){
$oldslug = User::where('id',$_POST['user_id'])->value('slug');
$newslug = str_slug($_POST['slug'], '-');
//if data not change
if($oldslug == $newslug){
$counts = User::where('slug',$newslug)->count();
//if data more than the object original
if($counts>1){
@arungpisyadi
arungpisyadi / Front-175.php
Last active December 13, 2016 07:04
Cleaned backend code unused dealerListings
//$sql = "SELECT a.ID, a.post_date, a.post_title,a.post_content, a.post_name, b.meta_value,t.name as category_name , t.term_id,tax.taxonomy FROM wp_posts a inner JOIN wp_postmeta b inner JOIN wp_term_relationships rel ON rel.object_id = a.ID inner JOIN wp_term_taxonomy tax ON tax.term_taxonomy_id = rel.term_taxonomy_id inner JOIN wp_terms t ON t.term_id = tax.term_id WHERE a.post_status = 'publish' AND a.ID = b.post_id AND b.meta_key = '_thumbnail_id' AND tax.taxonomy = 'category' group by a.ID ORDER BY a.post_date DESC LIMIT 2;";