Skip to content

Instantly share code, notes, and snippets.

View grim-reapper's full-sized avatar

Imran Ali grim-reapper

View GitHub Profile
@grim-reapper
grim-reapper / background.js
Created August 11, 2021 04:59 — forked from olegp/background.js
Active tab change detection in Chrome Extension
let activeTabId, lastUrl, lastTitle;
function getTabInfo(tabId) {
chrome.tabs.get(tabId, function(tab) {
if(lastUrl != tab.url || lastTitle != tab.title)
console.log(lastUrl = tab.url, lastTitle = tab.title);
});
}
chrome.tabs.onActivated.addListener(function(activeInfo) {
@grim-reapper
grim-reapper / manifest.json
Created March 15, 2021 07:58 — forked from IzumiSy/manifest.json
Chrome.storage.sync example
{
"name": "SyncExtension",
"version": "0.1",
"manifest_version": 2,
"description": "Storage Sync Extension",
"permissions": [ "storage" ],
"browser_action": {
@grim-reapper
grim-reapper / Pakistan Cities List.html
Created February 24, 2021 05:27 — forked from malikbilal1997/Pakistan Cities List.html
List of All Pakistan Cities Html Code.
<select name="Location" id="Location" required>
<option value="" disabled selected>Select The City</option>
<option value="Islamabad">Islamabad</option>
<option value="" disabled>Punjab Cities</option>
<option value="Ahmed Nager Chatha">Ahmed Nager Chatha</option>
<option value="Ahmadpur East">Ahmadpur East</option>
<option value="Ali Khan Abad">Ali Khan Abad</option>
<option value="Alipur">Alipur</option>
<option value="Arifwala">Arifwala</option>
<option value="Attock">Attock</option>
/*
* jQuery Double Tap
* Developer: Sergey Margaritov (github.com/attenzione)
* License: MIT
* Date: 22.10.2013
* Based on jquery documentation http://learn.jquery.com/events/event-extensions/
*/
(function($){
@grim-reapper
grim-reapper / gist:5c8a0534336b56f72701bef05f1b170e
Created October 23, 2020 16:19 — forked from reinink/gist:1392767
PHP wrapper for Google Weather API
<?php
class Google_Weather
{
public $condition;
public $temperature;
public $humidity;
public $icon;
public $wind_direction;
public $wind_speed;
@grim-reapper
grim-reapper / gist:ada216f46f11b20db5a27ce02902bb90
Created October 23, 2020 16:17 — forked from reinink/gist:1645193
PHP function to calculate age
<?php
function calculate_age($birthday)
{
$today = new DateTime();
$diff = $today->diff(new DateTime($birthday));
if ($diff->y)
{
return ($diff->y == 1) ? $diff->y . ' year' : $diff->y . ' years';
@grim-reapper
grim-reapper / gist:958e75c49cc0aa4aeea34e1967efce3d
Created October 23, 2020 15:54 — forked from reinink/gist:5039431
Custom sort multidimensional array
<?php
// Array with data
$teams = array
(
array('name' => 'Maple Leafs', 'city' => 'Toronto'),
array('name' => 'Canucks', 'city' => 'Vancouver'),
array('name' => 'Senators', 'city' => 'Ottawa'),
array('name' => 'Canadiens', 'city' => 'Montreal'),
array('name' => 'Flames', 'city' => 'Calgary'),
@grim-reapper
grim-reapper / .htaccess
Created October 23, 2020 15:46 — forked from reinink/.htaccess
Add filename-based cache busting to Laravel
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.(\d+)\.(css|gif|jpeg|jpg|js|png|svg)$ $1.$3 [L]
</IfModule>
@grim-reapper
grim-reapper / example.php
Created October 23, 2020 15:45 — forked from reinink/example.php
Given multiple periods of time in a day, that may overlap, calculate the sum of all the periods, in hours.
<?php
$periods = [
[new DateTime('8AM'), new DateTime('5PM')], // 9 hours
[new DateTime('8AM'), new DateTime('5PM')], // 9 hours
[new DateTime('10AM'), new DateTime('12PM')], // 2 hours
[new DateTime('12PM'), new DateTime('5PM')], // 5 hours
[new DateTime('7PM'), new DateTime('8PM')], // 1 hour
[new DateTime('9AM'), new DateTime('4PM')], // 7 hours
];