Skip to content

Instantly share code, notes, and snippets.

View sultanofcardio's full-sized avatar
💭
coding

Kenroy Gobourne sultanofcardio

💭
coding
View GitHub Profile
@sultanofcardio
sultanofcardio / git-https-to-ssh.sh
Last active February 12, 2022 18:28
git-https-to-ssh.sh
#!/usr/bin/env bash
set -e
if [ "$#" -ne 1 ]; then
echo "Search root was not supplied. Searching from current directory"
SEARCH_ROOT="$(pwd)"
else
SEARCH_ROOT="$(readlink -f $1)"
echo "Searching from ${SEARCH_ROOT}"
@sultanofcardio
sultanofcardio / README.md
Last active October 19, 2019 19:35
Nginx Secure Proxy

Setup an nginx configuration to proxy a hostname to a localhost server.

This script will do the following:

  • Install nginx and configure it to listen on your hostname
  • Install certbot and use it to obtain an SSL certificate for your hostname
  • Configure nginx to listen for your hostname on port 443 over TLS, and redirect port 80 connections to port 443
  • Proxy all incoming connections on your hostname to a localhost server of your choosing
@sultanofcardio
sultanofcardio / README.md
Last active May 7, 2019 21:42
Command line cheat sheet - updated periodically

Markdown to PDF

# npm install -g --save mdpdf
mdpdf file.md

Markdown to Word

# sudo apt install pandoc
pandoc -o file.docx -f markdown -t docx file.md
@sultanofcardio
sultanofcardio / README.md
Created March 7, 2019 01:36
How to set up a mail server

Instructions

Install postfix

sudo apt install postfix

Configure postfix

Edit the file /etc/postfix/main.cf to the following contents, replacing example.com with your hostname

@sultanofcardio
sultanofcardio / OpenWithSublimeText2.bat
Created June 21, 2018 16:23 — forked from mrchief/LICENSE.md
Add "Open with Sublime Text 2" to Windows Explorer Context Menu (including folders)
@echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@sultanofcardio
sultanofcardio / compile_shell_script.sh
Last active January 4, 2018 20:23
Shell scripting
# Please install shc first!
shc -f <file_name>.sh -e 01/01/9999 -r
@sultanofcardio
sultanofcardio / python_java_time.py
Created March 16, 2017 03:03 — forked from huskercane/python_java_time.py
Convert from java timestamp to python datetime and vice versa
def _convert_java_millis(java_time_millis):
"""Provided a java timestamp convert it into python date time object"""
ds = datetime.datetime.fromtimestamp(
int(str(java_time_millis)[:10])) if java_time_millis else None
ds = ds.replace(hour=ds.hour,minute=ds.minute,second=ds.second,microsecond=int(str(java_time_millis)[10:]) * 1000)
return ds
def _convert_datetime_java_millis(st):
"""Provided a python datetime object convert it into java millis"""
@sultanofcardio
sultanofcardio / Activity.java
Last active January 21, 2017 15:57
File Templates
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Call various methods here. We use method instead of writing code directly here
//for better readability
}
private void initViews(){
@sultanofcardio
sultanofcardio / AsyncResponse.java
Created October 6, 2016 20:10
AsyncResponse Interface
package <full>.<package_name>.models;
/**
* @author <your_name>
*
* Implementing this class allows an Activity class to collect the result of an AsyncTask
* without needing to pass context or handling view modification restrictions
*/
public interface AsyncResponse {
void processFinish(int newItems);
@sultanofcardio
sultanofcardio / lift_on_touch.xml
Created September 22, 2016 16:02
State List Animator for Android CardView
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:state_pressed="true" >
<set>
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueTo="6dp"
android:valueType="floatType" />