Skip to content

Instantly share code, notes, and snippets.

View itsdamslife's full-sized avatar
🎯
Learning new things...

Dams itsdamslife

🎯
Learning new things...
View GitHub Profile
@itsdamslife
itsdamslife / openssl.md
Created March 4, 2020 10:45 — forked from NoMan2000/openssl.md
Common OpenSSL Commands with Keys and Certificates

Common OpenSSL Commands with Keys and Certificates

SSL Info

Generate RSA private key with certificate in a single command

openssl req -x509 -newkey rsa:4096 -sha256 -keyout example.key -out example.crt -subj "/CN=example.com" -days 3650 -passout pass:foobar

Generate Certificate Signing Request (CSR) from private key with passphrase

openssl x509 -x509toreq -in example.crt -out example.csr -signkey example.key -passin pass:foobar

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@itsdamslife
itsdamslife / gitconfig
Created July 30, 2018 15:38
Git command shortcuts
[alias]
co = checkout
cob = checkout -b
ci = commit -m
st = status
br = branch
lg = log
rb = rebase
rbi = rebase -i
@itsdamslife
itsdamslife / open_terminal.sh
Created April 13, 2018 15:46
Open terminal from xcode script
#!/bin/bash
open -a Terminal "`pwd`"
@itsdamslife
itsdamslife / MemUtil.swift
Created March 20, 2017 08:58
A memory utility function in Swift to return the address of a reference variable.
public struct MemUtil {
public static func address(_ o: UnsafeRawPointer) -> String {
let address = unsafeBitCast(o, to: Int.self)
return String(format: "%p", address)
}
}
@itsdamslife
itsdamslife / MyExperimentsWithClosure.swift
Last active February 15, 2017 16:09
How do I check if myVC (the parent who created closure) is still alive before calling?
class Example {
var callbackRef: Closure?
var timer: Timer?
var incrementer: Int = 1
func test(repeating: Bool, callback: @escaping Closure) {
callbackRef = callback
_ = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true, block: { [unowned self]
timer in
self.newTest(callback: callback)
})
-(void)convertToPDF:(UIView*)aView withFileName:(NSString*)aFilename
{
// Creates a mutable data object for updating with binary data, like a byte array
UIWebView *webView = (UIWebView*)aView;
NSString *heightStr = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
int height = [heightStr intValue];
CGFloat screenHeight = webView.bounds.size.height;
int pages = ceil(height / screenHeight);
@itsdamslife
itsdamslife / Remote Image fetch and refresh
Created January 7, 2015 10:23
Simple HTML-JS code. Takes server address as input constructs a path and auto-refreshes the image every second. Just for personal reference.
<html>
<script>
var index = 0;
function connect()
{
var addr = document.getElementById("address")
var imgPath = "http://" + addr.value + ":8080/Test.png";
document.getElementById("path").innerHTML = imgPath;
setInterval(function() {
index = index + 1;
@itsdamslife
itsdamslife / svnprune
Created February 6, 2014 09:27
Terminal command to remove all .svn folders recursively from your working copy
// Make your working copy directory as current working directory
cd /path/to/your/working/copy/directory
// Copy and paste this command in your terminal and hit enter/return
sudo find . -type d -name .svn -exec rm -rf {} \;
@itsdamslife
itsdamslife / iTwunesScript.scpt
Created August 16, 2012 10:58
Add selected track into a playlist and start playing the playlist
tell application "iTunes"
duplicate selection to playlist "iTunes DJ"
if player state is playing then
if current playlist is not "iTunes DJ" then
play playlist "iTunes DJ"
else if current playlist is "iTunes DJ" then
if player state is playing then
print playing