Skip to content

Instantly share code, notes, and snippets.

View jastisriradheshyam's full-sized avatar
🪀
((~~~))

Jasti Sri Radhe Shyam jastisriradheshyam

🪀
((~~~))
View GitHub Profile
@jastisriradheshyam
jastisriradheshyam / marbles_all_names.go
Created April 17, 2018 09:43
Get all the objects (marble) names in the ledger
//Shows all the marbles or objects in the ledger (blockchain)
//This is a marbles chaincode (hyperledger fabric samples) related code.
// Jasti Sri Radhe Shyam
func (t *SimpleChaincode) getMarblesByRangeAll(stub shim.ChaincodeStubInterface) pb.Response {
//Gets all the data with undefined range
resultsIterator, err := stub.GetStateByRange("", "")
if err != nil {
return shim.Error(err.Error())
}
@jastisriradheshyam
jastisriradheshyam / couchdb_index_format_example.json
Created April 17, 2018 12:22
Couch DB index creation example.
{
"index": {
"fields": ["name"]
},
"ddoc": "index@1.0.0",
"name": "name-index",
"type": "json"
}
//Referesh automatially
<script type="text/javascript">
setTimeout(function(){
location = ''
},60000)
</script>
//Hard Refersh
location.reload(true);
@jastisriradheshyam
jastisriradheshyam / caller_name.go
Last active June 11, 2018 04:57
outputs the function name.
// Copyright 2018 Jasti Sri Radhe Shyam
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
@jastisriradheshyam
jastisriradheshyam / go_interface_json_unmarsall.go
Last active June 25, 2018 07:50
This is to get the unknown data (from json) and parse in go program for further opertions
package main
// Importing libraries
import (
"encoding/json"
"fmt"
)
func main() {
// Sample JSON string
@jastisriradheshyam
jastisriradheshyam / Caps_conversion.js
Last active July 3, 2018 13:04
Java Script Tricks
function ucFirstAllWords( str )
{
var pieces = str.split(" ");
for ( var i = 0; i < pieces.length; i++ )
{
var j = pieces[i][0].toUpperCase();
pieces[i] = j + pieces[i].substr(1).toLowerCase();
}
return pieces.join(" ");
}
@jastisriradheshyam
jastisriradheshyam / uploadAJAX.js
Created October 16, 2018 13:23
Document in upload
var someFunctionToUse = function (obj) {
// Form data
var formData = new FormData();
// Appending the files data in form data
formData.append("doc_file", document.getElementById("upload_input_id").files[0]);
// (Example) attribute from an object
formData.append("data_filed_name", obj.getAttribute("object_attribute_name"));
// Creating the Request object
var oReq = new XMLHttpRequest();
// Creating event
// IPv4
var regexStringIPv4 = '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$';
var regexIPv4 = new RegExp(regexStringIPv4, flags);
console.log(regexIPv4.test("192.168.0.25.25.23")); // false
console.log(regexIPv4.test("192.168.0.25")); // true
@jastisriradheshyam
jastisriradheshyam / .port
Last active October 31, 2018 17:07
Port validation
{
"validPort" : ["256"],
"invalidPort" : [],
"minPort" : "1000",
"maxPort" : "1200"
}
@jastisriradheshyam
jastisriradheshyam / cmdline
Last active December 1, 2018 20:52
Linux (Solus) V sync issue (Screen Tearing) with NVIDIA card solution
modprobe.blacklist=nouveau i915.enable_rc6=0 i915.enable_psr=0 i915.preliminary_hw_support=1 i915.enable_hd_vgaarb=1 intel_idle.max_cstate=1 nvidia-drm.modeset=1