Skip to content

Instantly share code, notes, and snippets.

View mkhatib's full-sized avatar

Mohammad Khatib mkhatib

View GitHub Profile
@Leotomas
Leotomas / chrome_install_headless.sh
Created August 2, 2016 11:03
Install Chrome headless on Ubuntu
export CHROME_BIN=/usr/bin/google-chrome
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
@dcollien
dcollien / ImageTools.es6
Last active April 28, 2023 09:00
Resize Images in the Browser
let hasBlobConstructor = typeof(Blob) !== 'undefined' && (function () {
try {
return Boolean(new Blob());
} catch (e) {
return false;
}
}());
let hasArrayBufferViewSupport = hasBlobConstructor && typeof(Uint8Array) !== 'undefined' && (function () {
try {
@imevro
imevro / gist:edfe9dea12196056467f
Last active January 6, 2021 05:19
Clean up all cached pages in prerender.io from console
var cleanUp = function() {
$.ajax({method: "GET", url: "https://prerender.io/api/cached-pages?page=0&pageSize=1000000"}).success(function(response) {
var total = response,
lastChecked = 1;
console.log("total: " + response.length);
for(var i = 0; i < total.length; i++) {
$.ajax({
method: "DELETE",
@pwalsh
pwalsh / appengine-service-accounts-on-devserver.md
Last active May 17, 2022 18:07
Google App Engine Service Accounts that work in local development: A guide for the lost and weary

It is easy to get service accounts working with App Engine's app_devserver.py - once you know how.

On the way there, you might have pulled out all your hair following one documentation dead end after another, trying to piece together the right information.

Here are the steps you need to take, in exact order, to get this working. Once you follow these steps, you'll be able to use service accounts in local development, so that you can interact with Google APIs (e.g.: Spreadsheet, Calendar) in a way that is consistent with the deployment environment on App Engine.

In order to follow the instructions, you'll be better off using the latest UI for Google Cloud projects. Older interfaces (such as the dedicated App Engine dashboard) have things in different places, under different names, etc. It is a world of pain there.

Also note that I've tested this on several 1.9.x releases of App Engine; I can't confirm the behaviour of earlier releases.

@zollinger
zollinger / getcolor.py
Last active March 11, 2023 15:57
Simple way to get dominant colors from an image in Python
from PIL import Image, ImageDraw
import argparse
import sys
def get_colors(image_file, numcolors=10, resize=150):
# Resize image to speed up processing
img = Image.open(image_file)
img = img.copy()
img.thumbnail((resize, resize))
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt