Skip to content

Instantly share code, notes, and snippets.

View sisodiakaran's full-sized avatar

Karan Singh Sisodia sisodiakaran

View GitHub Profile
@sisodiakaran
sisodiakaran / title_case.java
Created September 7, 2018 06:11
Android String to Title Case
public static String toTitleCase(String str) {
if (str == null) {
return null;
}
boolean space = true;
StringBuilder builder = new StringBuilder(str);
final int len = builder.length();
@sisodiakaran
sisodiakaran / Webhookinbox.php
Created January 9, 2017 20:09
Code to check webhooks
<?php
$postdata = http_build_query($_POST);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
@sisodiakaran
sisodiakaran / time_between.java
Created June 22, 2016 07:46
Java method to check whether current time is between start time and end time.
private boolean isTimeBetweenTwoTime(String from, String to) throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date date_from = formatter.parse(from);
Date date_to = formatter.parse(to);
Calendar cal = Calendar.getInstance();
String dateNow = formatter.format(cal.getTime());
Date current = formatter.parse(dateNow);
@sisodiakaran
sisodiakaran / functions.php
Created June 15, 2016 20:06
Function to add custom fields in Wordpress user profile editor
/**
* Function to display custom field in Admin Profile editor
* Only Admin can view these options
*/
function user_custom_fields($user) {
if (is_admin()) { // Check of admin
$is_verified = get_the_author_meta('is_verified', $user->ID);
$is_qualified = get_the_author_meta('is_qualified', $user->ID);
?> <table class="form-table">
@sisodiakaran
sisodiakaran / test.js
Created September 11, 2015 21:51
JS Recursive Function
var home = {
room_1: {
tube: 5,
fan: 6,
lamp: {
one: 7,
two: {
two_1: 8,
tow_two: 9
}
@sisodiakaran
sisodiakaran / timezone_select.php
Last active January 2, 2016 13:39
CakePHP-TimezoneSelectHelper
<?php
class TimezoneSelectHelper extends FormHelper
{
var $helpers = array('Form');
function select($fieldname, $label, $default="Asia/Calcutta", $attributes=false)
{
$list = '<div class="input">';
$list .= $this->Form->label($label);
@sisodiakaran
sisodiakaran / GravatarHelper.php
Created October 1, 2013 05:46
CakePHP-GravatarHelper
<?php
class GravatarHelper extends AppHelper {
/**
* Get either a Gravatar URL or complete image tag for a specified email address.
*
* @param string $email The email address
* @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
* @param boole $img True to return a complete IMG tag False for just the URL