Skip to content

Instantly share code, notes, and snippets.

Avatar
🤗
I wake up early and work hard :)

Saeed Hassani Borzadaran realsaeedhassani

🤗
I wake up early and work hard :)
View GitHub Profile
@realsaeedhassani
realsaeedhassani / icons.txt
Last active Sep 22, 2021
Git conventional commit icons.
View icons.txt
🗑️ revert:
🐞 fix:
✨ feat:
💎 style:
♻️ chore:
📦 refactor:
🎉 build:
docs
@realsaeedhassani
realsaeedhassani / refactorFieldName.sql
Created Sep 22, 2021
Postgresql: Change field name in all table.
View refactorFieldName.sql
do
$$
declare
l_rec record;
begin
for l_rec in (select table_schema, table_name, column_name
from information_schema.columns
where table_schema = 'public'
and column_name = 'mount') loop
execute format ('alter table %I.%I rename column mount to amount', l_rec.table_schema, l_rec.table_name);
View split_csv_by_row.py
def split_and_save_df(df, name, chunk_size, output_dir):
"""Split a dataframe and save each chunk in a different csv file.
Parameters:
df : data frame ( df = pd.read_csv('file.csv')
name : name of output file
chunk_size : chunk size
output_dir : directory where to write the divided dataframe
"""
import os
@realsaeedhassani
realsaeedhassani / restart_squence.sql
Created Jul 30, 2021
Postgresql: Start sequence after max(id) in all table.
View restart_squence.sql
CREATE OR REPLACE FUNCTION "reset_sequence" (tablename text, columnname text, sequence_name text)
RETURNS "pg_catalog"."void" AS
$body$
DECLARE
BEGIN
EXECUTE 'SELECT setval( ''' || sequence_name || ''', ' || '(SELECT MAX(' || columnname ||
') FROM ' || tablename || ')' || '+1)';
@realsaeedhassani
realsaeedhassani / GtoJ.js
Last active Jul 13, 2021
Convert Georgian to Shamsi(Jalali)
View GtoJ.js
// https://www.linkedin.com/posts/ppx1400_ppx-progprox-afyahyabrafyahyabraepahyagpaeb-activity-6820335516840546304-eHMZ
function GtoJ(a){
var e,d,c;
var n,m,l;
var b,h;
var k;
var f;
var gdays=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
@realsaeedhassani
realsaeedhassani / fa2EnDigits.js
Last active Jul 12, 2021
Convert Persian digits to English digits.
View fa2EnDigits.js
fa2EnDigits(str) {
str = String(str);
var e = '۰'.charCodeAt(0);
str = str.replace(/[۰-۹]/g, function (t) {
return t.charCodeAt(0) - e;
});
e = '٠'.charCodeAt(0);
str = str.replace(/[٠-٩]/g, function (t) {
return t.charCodeAt(0) - e;
});
@realsaeedhassani
realsaeedhassani / make_app.sh
Created Jun 29, 2021
Generate APK file without IDE
View make_app.sh
#!/bin/bash
#mkdir -p { src/com/example/hellovirgool, obj, bin, res/layout, res/values, res/drawable}
#Define the help function
function help() {
echo "Options:"
echo "-package Package Name"
echo "-sdk SDK Path"
echo "-name Application Name"