Skip to content

Instantly share code, notes, and snippets.

View cleopatra27's full-sized avatar
🎯
Focusing

cleopatra douglas cleopatra27

🎯
Focusing
View GitHub Profile
public class ImplementHeader implements RequestHandler<Map<String, Object>, NameEnquiryResponse> {
public String handleRequest(Map<String, Object> eventMap, Context context) {
context.getLogger().log("Header: " + eventMap.get("headers"));
context.getLogger().log("Input: " + eventMap.get("body"));
Gson gson = new Gson();
String json = gson.toJson(eventMap.get("body"));
String jsonHeader = gson.toJson(eventMap.get("headers"));
@cleopatra27
cleopatra27 / gist:8f79dcc7c53f3eb1448066ce6d2a1ff4
Created August 19, 2019 13:53
Sample mapping template for APIGATEWAY
{
"method": "$context.httpMethod",
"body" : $input.json('$'),
"headers": {
#foreach($param in $input.params().header.keySet())
"$param": "$util.escapeJavaScript($input.params().header.get($param))"
#if($foreach.hasNext),#end
#end
}
}
@cleopatra27
cleopatra27 / cardsgenerate.java
Created April 12, 2019 15:58
Card PAN generating (random numbers)
public long givenUsingPlainJava_whenGeneratingRandomLongBounded_thenCorrect() {
long leftLimit = 10000000000L;
long rightLimit = 1000L;
long generatedLong = leftLimit + (long) (Math.random() * (rightLimit - leftLimit));
return generatedLong;
}
public long generateRandomCard() {
long card = this.givenUsingPlainJava_whenGeneratingRandomLongBounded_thenCorrect();
return card;
public static final String SANBOX_URL = System.getenv("SANBOX_URL");
public static final String SECRET_KEY = System.getenv("SECRET_KEY");
public static final String PUBLIC_KEY = System.getenv("PUBLIC_KEY");
public static final String ENCRYPTION_KEY = System.getenv("ENCRYPTION_KEY");
@cleopatra27
cleopatra27 / mobilemoneyservice.java
Created March 8, 2019 14:17
mobilemoneyservice
public String doflwmobilemoney(String params) {
StringBuilder result = new StringBuilder();
try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
HttpPost post = new HttpPost((raveConfig.SANDBOXMOBILEMONEY_CHARGE_URL));
LOG.info("doflwmobilemoney response ::: " + params);
System.out.println("params ===>" + params);
pay_load pay_load = new pay_load();
@cleopatra27
cleopatra27 / mobileMoney.java
Created March 8, 2019 14:08
java class for ravepay mobile money
public class mobileMoney implements RequestHandler<mobilemoneyPayload, String> {
@POST
@Consumes({MediaType.APPLICATION_JSON})
@Produces(MediaType.APPLICATION_JSON)
public String handleRequest(mobilemoneyPayload mobilemoneyPayload, Context context) {
PaymentServices paymentservices = new PaymentServices();
// ReferenceUtil referenceutil = new ReferenceUtil();
InetAddress localhost = null;
try {
@cleopatra27
cleopatra27 / AES.java
Created March 7, 2019 11:52
Sample Java class for AES encryption
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
public class Encryptor {
public static String encrypt(String key, String initVector, String value) {
try {
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
@cleopatra27
cleopatra27 / 3DES.java
Last active May 6, 2019 15:35
Sample java 3DES class
public class TDES {
public static void main(String[] args) throws Exception {
String text = "cleopatra douglas";
byte[] codedtext = new TripleDESTest().encrypt(text);
String decodedtext = new TripleDESTest().decrypt(codedtext);
@cleopatra27
cleopatra27 / settings.py
Last active May 23, 2017 10:52
custom ckeditor for django-cms(should be included in settings.py and is based on css)
CKEDITOR_SETTINGS = {
# 'language': '{{ language }}',
# 'toolbar': 'CMS',
# 'skin': 'moono',
# 'toolbar_CMS': [
# ['Undo', 'Redo'],
# ['cmsplugins', '-', 'ShowBlocks'],
# ['Format', 'Styles'],
# ['TextColor', 'BGColor', '-', 'PasteText', 'PasteFromWord'],
# ['Maximize', ''],
@cleopatra27
cleopatra27 / setting.py
Created May 23, 2017 10:41
custom ckeditor for django-cms(should be included in settings.py)
CKEDITOR_SETTINGS = {
# 'language': '{{ language }}',
# 'toolbar': 'CMS',
# 'skin': 'moono',
# 'toolbar_CMS': [
# ['Undo', 'Redo'],
# ['cmsplugins', '-', 'ShowBlocks'],
# ['Format', 'Styles'],
# ['TextColor', 'BGColor', '-', 'PasteText', 'PasteFromWord'],
# ['Maximize', ''],