Skip to content

Instantly share code, notes, and snippets.

View sanjeevshrestha's full-sized avatar
💭
I may be slow to respond.

Sanjeev Shrestha sanjeevshrestha

💭
I may be slow to respond.
View GitHub Profile
@sanjeevshrestha
sanjeevshrestha / telegraf-dockercompose.yml
Last active July 24, 2022 01:12
Telegraf Docker Compose file
telegraf:
image: telegraf
restart: always
environment:
HOST_PROC: /rootfs/proc
HOST_SYS: /rootfs/sys
HOST_ETC: /rootfs/etc
hostname: localhost
volumes:
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
@sanjeevshrestha
sanjeevshrestha / introrx.md
Created May 26, 2017 05:19 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@sanjeevshrestha
sanjeevshrestha / jackson-json.java
Created March 31, 2017 20:08
Creating JSON with Jackson
ObjectMapper mapper = new ObjectMapper();
ArrayNode arrayNode = mapper.createArrayNode();
ObjectNode objectNode1 = mapper.createObjectNode();
objectNode1.put("bookName", "Java");
objectNode1.put("price", "100");
ObjectNode objectNode2 = mapper.createObjectNode();
objectNode2.put("bookName", "Spring");
@sanjeevshrestha
sanjeevshrestha / Vagrantfile
Created October 3, 2016 15:17 — forked from aweijnitz/Vagrantfile
This is a Vagrant file and a provisioning script to create a Debian-based Jenkins server, including Java, Ant and Tomcat. Also see "provision.sh" below
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
# Named boxes, like this one, don't need a URL, since the are looked up
@sanjeevshrestha
sanjeevshrestha / Swapping two numbers without third variable
Created July 6, 2016 19:23
Swapping two numbers without third variable in java
public static void swap1(int a, int b) {
System.out.println("The intital value " + a + " " + b);
a = a + b;
b = a - b;
a = a - b;
System.out.println("The swapped value " + a + " " + b);
}
@sanjeevshrestha
sanjeevshrestha / Adding numbers without + Operator
Created July 6, 2016 19:16
Adding numbers without + Operator in Java
public static int addIter(int a, int b) {
while (b != 0) {
int carry = a & b;
a = a ^ b;
b = carry << 1;
}
return a;
}
@sanjeevshrestha
sanjeevshrestha / Joomla-two-column-admin-menu
Created March 14, 2015 05:36
Making Joomla 3.4.x administrator menu 2 column
<?php
/**
* @author Sanjeev Shrestha <[email protected]>
* 14/03/2015
* Add a class to Menu Node For the menu in the administrator/mod_menu/tmpl/default_enabled.php
* Here I am making the admin components menu 2 column
*/
/**
* Add a class to 'components' menu node creator in file administrator/mod_menu/tmpl/default_enabled.php
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
@sanjeevshrestha
sanjeevshrestha / menutype.php
Created April 9, 2012 10:26
Joomla 2.5.x! com_menu menutypes model changes
/**
* Changes to menutypes.php method 'getTypeOptionsFromXML'
* Why? Currently the menutype does not allow to insert other many variables from metadata.xml file. This makes is rigid if any developer wants to add a variable to the menu url. Yes there is request field type but it does not server the purpose. I don't want to confuse people and also i want to use the same name for multiple state vars.
* How? Allow devs to insert variables as an attribute in menu option item as shown below
* e.g.
* <metadata>
* <menu>
* <options var="view">
* <option value="lists" name="Lists" msg="Listing" />
* <option value="messages" name="Messages" role='message.pms.exec' msg="Messages" />