Skip to content

Instantly share code, notes, and snippets.

@OrganicPanda
OrganicPanda / hacky-scrollbar-resize-listener.js
Last active April 7, 2024 10:53
A sham that will throw a window resize event even when scrollbars are added/removed (this is not something the standard window resize event does). Tested in IE9+, Chrome & Firefox latest.
// Demo: http://jsfiddle.net/pFaSx/
// Create an invisible iframe
var iframe = document.createElement('iframe');
iframe.id = "hacky-scrollbar-resize-listener";
iframe.style.cssText = 'height: 0; background-color: transparent; margin: 0; padding: 0; overflow: hidden; border-width: 0; position: absolute; width: 100%;';
// Register our event when the iframe loads
iframe.onload = function() {
// The trick here is that because this iframe has 100% width
@OrganicPanda
OrganicPanda / mouse-plugin.js
Created July 28, 2016 16:06
Track the mouse position in Protractor
// Hook in to `addEventListener` to track the mouse and display it as a circle
exports.onPageLoad = function() {
return browser.executeScript(function() {
(function() {
var EventSniffer = function() {
this.history = [];
this.callbacks = {};
this.minCacheSize = 100;
this.maxCacheSize = 500;
};
@OrganicPanda
OrganicPanda / test.py
Created February 3, 2012 11:51
A basic CherryPy/SQLAlchemy example site to demonstrate a multi-user issue
import cherrypy
import sqlalchemy
from sqlalchemy import Table, Column, ForeignKey, MetaData, Integer, String
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relationship
from sqlalchemy.orm.properties import ColumnProperty
from sqlalchemy.orm.util import object_mapper
# The base class from which all entities will extend
class BaseEntity(object):
def __repr__(self):

Pure360 Angular Tech Test

Create a SPA that:

  • Displays list of emails
  • Allows the user to see a preview of each email. The user should be able to toggle the HTML and plain versions
    • HTML version is rendered correctly with styles
    • Plain version is rendered raw with line breaks preserved
  • Has unit tests

Pure360 React Tech Test

Create a SPA that:

  • Displays list of emails
  • Allows the user to see a preview of each email. The user should be able to toggle the HTML and plain versions
    • HTML version is rendered correctly with styles
    • Plain version is rendered raw with line breaks preserved
  • Has unit tests
#!/bin/bash
brew uninstall node
brew prune
sudo rm -rf $HOME/{local,lib,include,node*,npm,.npm*}
sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/include/node*
sudo rm -rf /usr/local/bin/{node,npm}
sudo rm -rf /usr/local/share/man/man1/node.1
const screenshot = (text = '') => {
const upload = filename => {
const util = require('util');
const exec = require('child_process').exec;
const command = 'curl -sbv ' +
'-H \'Content-Type: multipart/form-data\' ' +
'-H \'Accept: application/json\' ' +
'-F "file=@./' + filename + '" ' +
'-F "upload_preset=kzrkwuhx" ' +
/**
* Juan's leaving card: http://is.gd/juan_leaving
*/
(function() {
'use strict';
var message = [
' gg ',
' dP8, ',
' dP Yb ',
@OrganicPanda
OrganicPanda / windows.md
Last active December 27, 2015 14:39
Windows instructions for Alfonzo's blog post