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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
#Warn ; Enable warnings to assist with detecting common errors. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory | |
; Make Ctrl + S work with cmd (windows) key | |
#s:: | |
Send,^s | |
Return |
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
func delay(_ delay: Double, closure: @escaping () -> ()) { | |
let when = DispatchTime.now() + delay | |
DispatchQueue.main.asyncAfter(deadline: when, execute: closure) | |
} |
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
extension Array { | |
func chunked(into size: Int) -> [[Element]] { | |
return stride(from: 0, to: count, by: size).map { Array(self[$0..<Swift.min($0 + size, count)]) } | |
} | |
} |
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
''' | |
usage: | |
path_name = "some_image_file.jpg" | |
meta_data = ImageMetaData(path_name) | |
latlng =meta_data.get_lat_lng() // result is converted from DMS to DD | |
source: https://www.codingforentrepreneurs.com/blog/extract-gps-exif-images-python/ | |
''' | |
from PIL import Image |
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
@IBOutlet weak var scrollView: UIScrollView! | |
func registerForKeyboardNotifications() { | |
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWasShown(_:)), name: .UIKeyboardDidShow, object: nil) | |
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillBeHidden(_:)), name: .UIKeyboardWillHide, object: nil) | |
} | |
@IBAction func keyboardWasShown(_ notification: NSNotification) { | |
guard let userInfo = notification.userInfo, |
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
// item 11: mark function as delete | |
class Widget { | |
public: | |
Widget(const Widget&) = delete; // delete copy ctor | |
Widget& operator=(const Widget& rhs)= delete; // delete copy= | |
template<typename T> | |
void process_pointer(T* ptr) {} |
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
// item 10 - enum class | |
#include <iostream> | |
#include <string> | |
#include <thread> | |
#include <array> | |
template<typename E> | |
constexpr auto toUType(E enumerator) noexcept { | |
return static_cast<std::underlying_type_t<E>>(enumerator); | |
}; |
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
#include <random> | |
decltype(auto) generate_id(){ | |
std::string id("ID"); // Holds the ID, starting with the characters "ID" followed | |
std::uniform_int_distribution<int> dist(0, 10000); // by a random integer in the range [0-10000]. | |
std::random_device rd; | |
std::mt19937 engine(rd()); | |
id += std::to_string(dist(engine)); |
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
#include <iostream> | |
#include <boost/type_index.hpp> | |
#define PRINT_TYPE(param) std::cout << boost::typeindex::type_id_with_cvr<decltype(param)>().pretty_name() << std::endl; | |
#define PRINT_TYPE_T(T) std::cout << "param type is: " << boost::typeindex::type_id_with_cvr<T>().pretty_name() << std::endl; |
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
import shlex | |
import subprocess | |
def bash_cmd(command): | |
return subprocess.check_output(shlex.split(command)) |
NewerOlder