Skip to content

Instantly share code, notes, and snippets.

View kishorek's full-sized avatar

Kishore Kumar Uthirapathy kishorek

View GitHub Profile
@kishorek
kishorek / exportImportJavaCert.md
Last active September 15, 2021 06:33 — forked from jeffsheets/exportImportJavaCert.md
Bash Commands to Export Cert and Import into Java Truststore

Command to export a cert from a website to a .cer file (example uses google.com) Tested with git-bash shell on Windows. Assume similar on Mac?

openssl s_client -servername google.com -connect google.com:443 </dev/null 2>/dev/null | openssl x509 -inform PEM -outform DER -out google.com.cer

Command to import into local java truststore (use your own location of JAVA_HOME)

"$JAVA_HOME"/bin/keytool -keystore "$JAVA_HOME"/jre/lib/security/cacerts -importcert -alias google.com -file google.com.cer

@kishorek
kishorek / jsoneditor.html
Created May 20, 2021 14:24
Quick Simple JSON Editor HTML
<!DOCTYPE html>
<html lang="en">
<head>
<!-- when using the mode "code", it's important to specify charset utf-8 -->
<meta charset="utf-8" />
<link
href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.4.1/jsoneditor.min.css"
rel="stylesheet"
type="text/css"
@kishorek
kishorek / tk_save_open_files.py
Created October 23, 2020 12:43
Open or Save files using system dialog in Python
from tkinter.filedialog import askopenfilename, asksaveasfile
file_path = askopenfilename(title = "Select the image", filetypes = (("jpg", "*.jpg"), ("png", "*.png")))
files = [('Image File', '*.jpg')]
savefile = asksaveasfile(filetypes = files, defaultextension = files)
@kishorek
kishorek / PDFFormReader.java
Created March 12, 2019 10:09
Read PDF Acro Forms
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
import org.apache.pdfbox.pdmodel.interactive.form.PDField;
import org.apache.pdfbox.pdmodel.interactive.form.PDNonTerminalField;
import java.io.IOException;
import java.util.List;
public class PDFFormReader {
@kishorek
kishorek / UIView+Subviews.swift
Created November 9, 2017 06:15
Remove all subviews from UIView
extension UIView {
// Recursive remove subviews and constraints
func removeSubviews() {
self.subviews.forEach({
if !($0 is UILayoutSupport) {
$0.removeSubviews()
$0.removeFromSuperview()
}
})
@kishorek
kishorek / UIImage+View.swift
Created November 9, 2017 06:15
Save UIView as UIImage
extension UIImage {
convenience init(view: UIView) {
UIGraphicsBeginImageContext(view.frame.size)
view.layer.render(in:UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
self.init(cgImage: image!.cgImage!)
}
}
@kishorek
kishorek / UIFont+CustomFont.swift
Created November 9, 2017 06:13 — forked from jimmyhillis/UIFont+CustomFont.swift
UIFont+CustomFont.swift
import UIKit
extension UIFont {
class func systemFontOfSize(size: CGFloat) -> UIFont {
return UIFont(name: "CustomFont-Regular", size: size)!
}
func lightSystemFontOfSize(size: CGFloat) -> UIFont {
return UIFont(name: "CustomFont-Light", size: size)!
}
@kishorek
kishorek / README.md
Created December 6, 2016 05:42 — forked from oodavid/README.md
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

<?php
$deviceToken = '6e1326c0e4758b54332fab3b3cb2f9ed92e2cd332e9ba8182f49027054b64d29'; // iPad 5s Gold prod
$passphrase = '';
$message = 'Hello Push Notification';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'pushcert.pem'); // Pem file to generated // openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts // .p12 private key generated from Apple Developer Account
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); // production
// $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); // developement
@kishorek
kishorek / xcode plugins
Created January 22, 2014 03:41
Some Useful XCode plugins
https://github.com/questbeat/Lin-Xcode5
https://github.com/chendo/FuzzyAutocompletePlugin
https://github.com/omz/ColorSense-for-Xcode
https://github.com/qfish/XAlign
https://github.com/ksuther/KSImageNamed-Xcode
https://github.com/nanaimostudio/Xcode-Quick-Localization