Skip to content

Instantly share code, notes, and snippets.

View munir131's full-sized avatar
:octocat:

Munir Khakhi munir131

:octocat:
View GitHub Profile
@munir131
munir131 / Supplier_UID.js
Created October 6, 2022 10:47 — forked from karthikeyan5/Supplier_UID.js
Collection of some Frappe framework custom script
// Here, Supplier DocType Contains a custom field (readonly) Called "UID".
// This feild is auto populated with the next number based on the highest UID in the supplier table.
frappe.ui.form.on("Supplier", {
validate: function(frm) {
if(frm.doc.__islocal == '1'){
frappe.db.get_list("Supplier", {fields:'uid', order_by:"uid desc",limit:1}).then((data) => {
frm.set_value("uid",String(parseInt(data[0].uid)+1).padStart(5,'0'));
});
}
@munir131
munir131 / Go Context printer
Created August 4, 2020 05:58
This function will help to print context in Golang. Credit: https://stackoverflow.com/users/959140/robin-andersson
func printContextInternals(ctx interface{}, inner bool) {
contextValues := reflect.ValueOf(ctx).Elem()
contextKeys := reflect.TypeOf(ctx).Elem()
if !inner {
fmt.Printf("\nFields for %s.%s\n", contextKeys.PkgPath(), contextKeys.Name())
}
if contextKeys.Kind() == reflect.Struct {
for i := 0; i < contextValues.NumField(); i++ {
@munir131
munir131 / install_py
Created July 23, 2019 12:24
Install python 3.6.5
brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb --ignore-dependencies
@munir131
munir131 / masquerade
Created September 7, 2017 04:33
masquerade User
if [ $1 = 'Munir' ]
then
rm -f /home/munir/.ssh/id_rsa*
cp /home/munir/.ssh-Munir/id_rsa* /home/munir/.ssh/
git config --global user.name "Munir Khakhi"
git config --global user.email email@email.com
elif [ $1 = 'User' ]
then
rm -rf /home/munir/.ssh/id_rsa*
cp /home/munir/.ssh-User/id_rsa* /home/munir/.ssh/
@munir131
munir131 / url.js
Created May 13, 2016 12:04
Functions for read write remove value from URL
window.getValueFromURL = function (name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
};
window.setToURL = function (key, value) {
var queryString;
window.removeFromURL(key);