Skip to content

Instantly share code, notes, and snippets.

View adityadees's full-sized avatar
🏠
Work From Home

Aditya Dharmawan Saputra adityadees

🏠
Work From Home
View GitHub Profile
@adityadees
adityadees / fnStripTags.sql
Last active May 9, 2021 19:55
MSYQL FUNCITON REMOVE HTML TAGS FROM RECORD AND SELECT WITH LIMIT
SET GLOBAL log_bin_trust_function_creators=1;
DROP FUNCTION IF EXISTS funcStripTags;
DELIMITER |
CREATE FUNCTION fnStripTags( Dirty varchar(4000) )
RETURNS varchar(4000)
DETERMINISTIC
BEGIN
DECLARE iStart, iEnd, iLength int;
WHILE Locate( '<', Dirty ) > 0 And Locate( '>', Dirty, Locate( '<', Dirty )) > 0 DO
BEGIN
@adityadees
adityadees / addDecimal.js
Last active June 4, 2021 03:06
JS Input format currecy
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
@adityadees
adityadees / exted.php
Created May 14, 2021 19:57
PHP SORT MULTIDIMENSIONAL ARRAY
// To extend this to multi-dimensional sorting, reference the second/third sorting elements if the first is zero - best explained below. You can also use this for sorting on sub-elements.
usort($myArray, function($a, $b) {
$retval = $a['order'] <=> $b['order'];
if ($retval == 0) {
$retval = $a['suborder'] <=> $b['suborder'];
if ($retval == 0) {
$retval = $a['details']['subsuborder'] <=> $b['details']['subsuborder'];
}
}
@adityadees
adityadees / fix.git
Created May 16, 2021 17:06
git pull fails “unable to resolve reference” “unable to update local ref”
rm .git/refs/remotes/origin/master
git fetch
@adityadees
adityadees / fix.dart
Created July 30, 2021 01:30
FLUTTER WEB CORS
1- Go to flutter\bin\cache and remove a file named: flutter_tools.stamp
2- Go to flutter\packages\flutter_tools\lib\src\web and open the file chrome.dart.
3- Find '--disable-extensions'
4- Add '--disable-web-security'
@adityadees
adityadees / version-1.php
Last active September 9, 2021 08:54
BUS SEAT PATTERN PHP
$divide = 4;
$inside = 2;
echo "<table border='1'>";
for($i = 1; $i <= 45; $i++){
if($i % $divide == 1 && $i != 45){
echo "<tr>";
}
echo "<td width='15%' align='center'>".$i."</td>";
if($i % $inside == 0 && $i % $divide != 0 && $i != 42){
@adityadees
adityadees / basemap.py
Last active January 1, 2022 06:58
GIS BASE MAP
"""
This script should be run from the Python consol inside QGIS.
It adds online sources to the QGIS Browser.
Each source should contain a list with the folowing items (string type):
[sourcetype, title, authconfig, password, referer, url, username, zmax, zmin]
You can add or remove sources from the sources section of the code.
Script by Klas Karlsson
@adityadees
adityadees / check-value-js.txt
Created March 11, 2023 05:29
JS Check Value
Null Test:
if (variable === null)
- variable = ""; (false) typeof variable = string
- variable = null; (true) typeof variable = object
- variable = undefined; (false) typeof variable = undefined
- variable = false; (false) typeof variable = boolean
- variable = 0; (false) typeof variable = number
- variable = NaN; (false) typeof variable = number
@adityadees
adityadees / laravel_horizon.md
Created May 9, 2024 14:05 — forked from ankurk91/laravel_horizon.md
Laravel Horizon, redis-server, supervisord on Ubuntu server

Laravel Horizon, redis-server, supervisord on Ubuntu 20/22 server

Laravel 8+, Horizon 5.x, Redis 6+

Parepare application

  • Install and configure Laravel Horizon as instructed in docs
  • Make sure you can access the Horizon dashboard like - http://yourapp.com/horizon
  • For now; it should show status as inactive on horizon dashbaord

Install redis-server

@adityadees
adityadees / echo-server.json
Last active May 17, 2024 05:45
apache reverse proxy laravel echo server
- npm install pm2 -g
- pm2 start echo-server.json --name="apps"
```echo-server.json
{
"name": "apps",
"script": "laravel-echo-server",
"args": "start"
}