This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testDates() throws ParseException { | |
// Desired Format in all scenarios | |
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | |
//Sample string we recieve | |
String runTime = "2020-10-26T00:07:35.965030-04:00[America/Toronto]"; | |
//converting to LocalDateTime for usage | |
LocalDateTime localDateTimeOut = ZonedDateTime.parse(runTime).toLocalDateTime(); | |
System.out.println("LocalDateTime to String without format: " + localDateTimeOut.toString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.armaandhir.slack_integration.util; | |
import com.mashape.unirest.http.HttpResponse; | |
import com.mashape.unirest.http.Unirest; | |
import com.mashape.unirest.http.exceptions.UnirestException; | |
import org.json.JSONArray; | |
import org.json.JSONObject; | |
/** | |
* Send slack messages using java. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The program takes 2 parameters for the main method: | |
* - first parameter is the number to be converted | |
* - second parameter is either 1 or 2. 1 represents question 1 and 2 represents question 2 | |
* | |
* @author armaan | |
* | |
*/ | |
public class NumberWords { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Simple implementation of & bitwise operator | |
*/ | |
#include <stdio.h> | |
#define TUNA_A 1 | |
#define TUNA_B 2 | |
#define TUNA_C 4 | |
#define TUNA_D 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def crc_encode(self, message, length): | |
new_message = message | |
crc = 0 | |
hex_crc = 0x91 | |
#lopp through each letter in string and store the xor value | |
for x in range(length): | |
crc ^= ord(message[x]) | |
#loop through each bit in char and check if it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# I hate the documentation of openpyxl and it took me a while to undertand their stuff. So I decided to write down this code. | |
# Has some wrapper functions that reads all rows from the excel sheet and also a function to read a particular row. | |
# Add some code to the functions if you wish to do something on fly like adding values to list and sorting them later. | |
# | |
# Date: 28/09/2015 | |
from openpyxl import load_workbook | |
# Reads all rows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* C function to replace a sub string with something in a string. Would suggest to use glib to avoid memory overwritting or use mallocs. | |
* You can use malloc() to assign memory to return string and get rid of the last argument but make sure to free it later. | |
* This function replaces multiple instances of the found substring. To replace single instance, see the comment in the function. | |
* If you want to dig more into it, check this out: http://creativeandcritical.net/str-replace-c | |
* | |
* Date: 23/09/2015 | |
*/ | |
#include <stdio.h> |