Skip to content

Instantly share code, notes, and snippets.

View taher435's full-sized avatar
👨‍💻

Taher Dhilawala taher435

👨‍💻
View GitHub Profile
@taher435
taher435 / sign-in-with-klarna-style.css
Created November 25, 2024 11:38
Sign in with Klarna - Button styling
:root{--current-gap: 0px}
.klarna-sdk-button-container{
width:335px;
height:48px;
display:inline-block
}
#klarna-sdk-button {
container-type:inline-size;
container-name:sdk-button-content;
position:relative;
@taher435
taher435 / isInsideSFSafariViewController.ts
Last active September 11, 2024 11:19 — forked from aeharding/isInsideSFSafariViewController.ts
Check if page is running in SFSafariViewController vs the Safari app
function isInsideSFSafariViewController(): boolean {
// Only iOS
if (!isIOS()) return false;
const iosVersion = getIosVersion();
// Can't use this hack in iOS < 15
if (!iosVersion || iosVersion[0] < 15) return false;
// In SFSafariViewController, this is a valid font.
@taher435
taher435 / table_fk_dependency.sql
Created April 7, 2020 16:47
Fetch all dependent foreign key tables for given table and column name.
SELECT rc.constraint_catalog,
rc.constraint_schema||'.'||tc.table_name AS table_name,
kcu.column_name,
match_option,
update_rule,
delete_rule
FROM information_schema.referential_constraints AS rc
JOIN information_schema.table_constraints AS tc USING(constraint_catalog,constraint_schema,constraint_name)
JOIN information_schema.key_column_usage AS kcu USING(constraint_catalog,constraint_schema,constraint_name)
JOIN information_schema.key_column_usage AS ccu ON(ccu.constraint_catalog=rc.unique_constraint_catalog AND ccu.constraint_schema=rc.unique_constraint_schema AND ccu.constraint_name=rc.unique_constraint_name)
@taher435
taher435 / delivery_drivers.json
Created October 20, 2017 08:24
Delivery drivers
[
{"name": "Jon Snow", "contact": "+6511110000", "latitude": "1.291432", "longitude": "103.821268", "available": true, "user_id": 1},
{"name": "Tyrion Lanister", "contact": "+6522220000", "latitude": "1.285758", "longitude": "103.783870", "available": true, "user_id": 2},
{"name": "Brandon Stark", "contact": "+6533330000", "latitude": "1.289907", "longitude": "103.829398", "available": false, "user_id": 3},
{"name": "Arya Stark","contact": "+6544440000","latitude": "1.312164","longitude": "103.767720", "available": true, "user_id": 4},
{"name": "Cersei Lannister", "contact": "+6555550000", "latitude": "1.310749", "longitude": "103.843629", "available": true, "user_id": 5},
{"name": "Khal Drogo", "contact": "+6566660000", "latitude": "1.286969", "longitude": "103.844563", "available": true, "user_id": 6},
{"name": "Sansa Stark", "contact": "+6577770000", "latitude": "1.273629", "longitude": "103.799448", "available": false, "user_id": 7},
{"name": "Ned Stark", "contact": "+6588880000", "latitude": "1.2
@taher435
taher435 / clean_code.rb
Last active August 16, 2016 10:53
Clean Code Examples - Ruby
# This is an example of bad code
class Employee
attr_accessor :first_name, :last_name
def initialize(first_name, last_name)
@first_name = first_name
@last_name = last_name
end
end
def calculate_pay(employee)
//Directive for file upload
app.directive('fileUpload', function () {
return {
scope: false,
link: function (scope, el, attrs) {
el.bind('change', function (event) {
var files = event.target.files;
scope.$emit("fileUploaded", { file: event.target.files[0] }); //since we need only single file upload right now
});
@taher435
taher435 / find_page_hz_scroll_culprit.js
Created February 14, 2016 13:39
Find the horizontal scroll culprit
var docWidth = document.documentElement.offsetWidth;
[].forEach.call(
document.querySelectorAll('*'),
function(el) {
if (el.offsetWidth > docWidth) {
console.log(el);
}
}
);
@taher435
taher435 / bit_mask.rb
Created December 17, 2015 11:34
User Roles with bit mask
ROLES = %i(student mentor guardian admin td)
@roles_mask = nil
def set(roles)
@roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.inject(0, :+)
end
def get
ROLES.reject do |r|
@taher435
taher435 / time_drop_down.rb
Created November 5, 2015 11:46
Create time drop down with customisable interval
def time_iterate(start_time, end_time, step, &block)
begin
yield(start_time)
end while (start_time += step) <= end_time
end
start_time = Time.parse("2010/1/1")
end_time = Time.parse("2010/1/2")
time_iterate(start_time, end_time, 1800) do |t|
hours.push({:text => t.strftime("%H:%M"), :hour => t.hour})