Skip to content

Instantly share code, notes, and snippets.

View azhararmar's full-sized avatar

Ibrahim Azhar Armar azhararmar

View GitHub Profile
@azhararmar
azhararmar / WordpressFunctions.php
Last active October 6, 2016 05:23
Wordpress Functions
<?php
// SQL Logger
function sql_logger() {
global $wpdb;
$log_file = fopen(ABSPATH.'/sql_log.txt', 'a');
fwrite($log_file, "//////////////////////////////////////////\n\n" . date("F j, Y, g:i:s a")."\n");
foreach($wpdb->queries as $q) {
fwrite($log_file, $q[0] . " - ($q[1] s)" . "\n\n");
}
fclose($log_file);
@azhararmar
azhararmar / Symfony - Manual User Authentication
Last active June 21, 2024 08:44
Manually Authenticate User In Symfony
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
// Manually authenticate user in controller
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));
@azhararmar
azhararmar / iOS Helpers
Last active August 14, 2018 06:15
IOS Helper Methods
// 1. UIView Border
extension UIView {
func addBorder(edges: UIRectEdge, color: UIColor = .black, thickness: CGFloat = 1.0) {
func borderView() -> UIView {
let view = UIView(frame: .zero)
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = color
return view
}
if edges.contains(.top) || edges.contains(.all) {
# Generate Lets Encrypt Cert For Subdomain
sudo certbot -i apache -a manual --preferred-challenges dns -d b.example.org