Skip to content

Instantly share code, notes, and snippets.

View aymanfarhat's full-sized avatar
🏠
Working from home

Ayman Farhat aymanfarhat

🏠
Working from home
View GitHub Profile
@amahdy
amahdy / decipher.js
Last active January 17, 2022 09:12
/* Code to run in the browser console of `go/techcon-lightningtalks` */
let loadData = function() {
// Array holding the data
let data = Array();
// Keep track of `H2` elements
let index = 1;
// Keep track of pillars
function getLastResource(time, regex) {
let entries = performance.getEntriesByType('resource')
let last = null;
for(let i = 0; i < entries.length; i++) {
let e = entries[i];
if(regex && !e.name.match(regex)) continue;
if(e.responseEnd < time) last = e;
}
return last;
}
@charisTheo
charisTheo / workbox-placeholder-image-fallback.js
Last active July 18, 2021 09:56
When an image is not found either in the network (offline) or in the cache, respond with a precached placeholder image from the cache.
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.1.5/workbox-sw.js');
const placeholderImageURL = '/img/placeholder-image.png'; // precache this in __WB_MANIFEST file
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST || []);
workbox.routing.registerRoute(
/\.(?:webp|png|jpg|jpeg|svg)$/,
async ({url, event, params}) => {
const staleWhileRevalidate = new workbox.strategies.StaleWhileRevalidate();
try {
@rudimusmaximus
rudimusmaximus / a Google Apps Script Getting Started Guide.md
Last active February 11, 2020 16:51
Getting started in google apps script

How To Get Started In Google Apps Script

Initially intended to extend G Suite apps, I like to think of Google Apps Script as a gateway to more kinds of development. Think of it as workflow glue and the power of programming that can interract with Google Apps and external APIs too!

Purpose

Provide a living document for whenever someone asks, " so, how do i get started with Google Apps Script?".

Working Outline

Just the orgainizing principles and some key links.

1 Starting point: Good Things to Keep in Mind

Scripts are 'bound' to a container like sheets, docs, slides or forms. These can be accessed from the containing doc and opened say in sheets by going to the menu Tools > Script editor. Scripts can also be standalone for addons or web apps. Your script home page is a dashboard found here script.google.com. The help link there will get you to an explanation of the dashboard.

@Link-
Link- / Useful Unix
Last active November 24, 2017 15:56
Unix : Search & Rescue commands
-- Find
egrep -Rl <regular expression> <file or files>
-- Find and Replace
grep -l '' ./* | xargs sed -i "" 's/IP4445A/IP445A/'
-- Find and Replace (no RegEx)
-- Add IMO number
grep -l '' ./* | xargs sed -i "" 's|MSC:172:20+++:146::VITNAME|MSC:172:20+++9299551:146::VITNAME|g'
-- Change VVN
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@calebwoods
calebwoods / nginx.conf
Created May 10, 2014 20:18
Sample Nginx config for deployment of Angular.js app
server { listen 80;
server_name example.com;
access_log /var/log/example.com/nginx.access.log;
error_log /var/log/example.com/nginx.error.log;
root /var/www/apps/example.com/public;
charset utf-8;
location / {
rewrite ^ https://$host$request_uri? permanent;
}
@omaraboumrad
omaraboumrad / astlookup.py
Last active October 9, 2015 08:11
Run static checks through various ast paths
import sys
import ast
is_if = lambda s: isinstance(s, ast.If)
is_for = lambda s: isinstance(s, ast.For)
is_call = lambda s: isinstance(s, ast.Call)
call_name_is = lambda s, n: is_call(s) and hasattr(s.func, 'attr') and s.func.attr == n
has_else = lambda s: is_if(s) and len(s.orelse) > 0
is_return = lambda s: isinstance(s, ast.Return)
is_name = lambda s: isinstance(s, ast.Name)
import operator
import collections
class Rule(object):
def __init__(self, logic, left=None, right=None, op=None, inv=False):
self.logic = logic
self.left = left
self.right = right
self.op = op
self.inv = inv

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style