Skip to content

Instantly share code, notes, and snippets.

View radityopw's full-sized avatar

radityo radityopw

View GitHub Profile
@radityopw
radityopw / php_session_in_gcp.php
Created April 28, 2022 07:37
session handler using google cloud storage
<?php
require_once 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
class MySessionHandler implements SessionHandlerInterface{
private $savePath;
private $storage;
private $bucket;
public function __construct(){
@radityopw
radityopw / free_up_memory_php_excel.php
Last active January 4, 2022 05:11
free up memory on phpExcel
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);
@radityopw
radityopw / CommandResult.java
Created October 15, 2021 14:30
membuat db sederhana part 2
package com.radityopw.simpledb;
public class CommandResult{
public static final int OK = 1;
public static final int ERROR = 2;
public static final int EXIT = 3;
public int status = CommandResult.OK;
public String message = "";
@radityopw
radityopw / .gitignore
Created October 15, 2021 12:16
membuat DBMS sederhana day 1
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
CREATE TRIGGER <schema>.<table_name>_read_only_events ON <schema>.<table_name>
INSTEAD OF INSERT,
UPDATE,
DELETE
AS
BEGIN
RAISERROR( 'table is read only.', 16, 1 )
ROLLBACK TRANSACTION
END
@radityopw
radityopw / String or binary data would be truncated.sql
Last active February 19, 2021 01:59
sql script to investigate String or binary data would be truncated
;WITH CTE_Dev
AS (
SELECT C.column_id
,ColumnName = C.NAME
,C.max_length
,C.user_type_id
,C.precision
,C.scale
,DataTypeName = T.NAME
FROM sys.columns C
@radityopw
radityopw / catatan_excel_dengan_win32.py
Created December 25, 2020 08:06
membaca, menulis excel dari python menggunaan win32 py
# install library
pip install pywin32
# import komponen
import win32com.client
# untuk membuka excel
xl = win32com.client.Dispatch('Excel.Application')
@radityopw
radityopw / levenshtein
Last active December 12, 2020 02:01
levenshtein distance in sqlserver
CREATE FUNCTION [dbo].[LEVENSHTEIN]( @s NVARCHAR(MAX), @t NVARCHAR(MAX) )
/*
Levenshtein Distance Algorithm: TSQL Implementation
by Joseph Gama
http://www.merriampark.com/ldtsql.htm
Returns the Levenshtein Distance between strings s1 and s2.
Original developer: Michael Gilleland http://www.merriampark.com/ld.htm
Translated to TSQL by Joseph Gama
import pyodbc
import time
from shutil import copy
import smtplib
import os
import datetime
def backup_db(cnxn,mode,backup_dir,secondary_backup_dirs,dbname):
backup_name = dbname+"-"+mode+" database backup"
/*
drop table #source ;
drop table #source_diff;
drop table #source_deleted;
*/
declare @last_synchronization_version bigint;