Skip to content

Instantly share code, notes, and snippets.

@gavinwilliams
gavinwilliams / amazon-fresh-delete.js
Created July 13, 2020 23:56
Delete all items from your Amazon Fresh Basket
// Paste into console where the Amazon Fresh basket is visible, hit enter
document.querySelectorAll("[data-action='fresh-item-delete'] a").forEach(e => e.click());
@gavinwilliams
gavinwilliams / keys-to-lastpass.sh
Last active May 1, 2019 20:21
Adds all SSH keys to your lastpass account. Make sure you install lpass CLI and login first.
read "?Lastpass Folder (i.e. AWS/ include the trailing slash) " folder; for filename in ~/.ssh/*.pem; do printf "Private Key: $(cat $filename)" | lpass add $folder/$(basename $filename) --note-type=ssh-key --non-interactive; done
@gavinwilliams
gavinwilliams / shortcuts.js
Last active August 29, 2015 13:56
Angular Keystroke Combo Service
'use strict';
angular.module('MyApp')
.service('Shortcuts', function Shortcuts() {
var _subscribers = {},
_keystrokes = [];
var processKeyStrokes = function processKeyStrokes(keystrokes) {
// Rebuild the hash, this is probably the quickest way to find our subscribers
@gavinwilliams
gavinwilliams / gist:3371769
Created August 16, 2012 17:14
Assisting code complete with custom objects
($object instanceof \Fishrod\CardBundle\Entity\Artwork);
@gavinwilliams
gavinwilliams / codecomplete.php
Created February 16, 2012 13:52
Getting code complete on assignments in Zend Studio
/**
* By checking to see whether an assignment is an instance of an object, Zend Studio will pick up on this hint
* and produce code complete for your newly assigned variable.
*/
if(($entity instanceof \My\Special\Object\Entity\EntityName) === false){
throw new Exception('WAAAAH! Something went wrong!');
} else {
$entity->getAwesomeness();
}
@gavinwilliams
gavinwilliams / routing.xml
Created February 16, 2012 11:44
DTD's for FOSRestBundle's xml routing
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://friendsofsymfony.github.com/schema/rest"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://friendsofsymfony.github.com/schema/rest http://friendsofsymfony.github.com/schema/rest/routing-1.0.xsd">
<import id="your_id" type="rest" resource="\Namespace\For\Your\Resource" />
</routes>
@gavinwilliams
gavinwilliams / build.xml
Created September 7, 2011 10:02
This ant task will automatically clear your Drupal cache with every build/save. Gone are the days of logging into the admin panel to clear the Drupal cache to preview your template or modifying Drupal to get around it!
<!--
1. Download and add drush to your template folder or put it somewhere on your computer and symlink it - http://drupal.org/project/drush
2. Add the following task to your Ant build file after your deployment tasks
3. 'dir' is the path to your local deployment i.e. /Users/yourname/Sites/yourwebsite/public_html
4. 'executable' is the path to your drush command. Simply use drush in this attribute if you have symlinked it
-->
<exec dir="${path.deploy}" executable="${directory.build.tools}/drush/drush" failonerror="true" output="/dev/null">
<arg line="cache-clear all" />
</exec>
@gavinwilliams
gavinwilliams / facebook-game-app-ignore
Created May 25, 2011 08:53
Ignore all facebook game and app requests
var e = document.getElementById('pagelet_requests'); var els = e.getElementsByTagName('input'); for(var i = 0; i < els.length; i++){ if(els[i].getAttribute('name') == 'actions[reject]'){ els[i].click(); } };
@gavinwilliams
gavinwilliams / facebook-group-ignore
Created May 25, 2011 08:42
Ignore all Facebook group requests, just copy and paste this into console
var e = document.getElementById('pagelet_groups_requests'); var els = e.getElementsByTagName('input'); for(var i = 0; i < els.length; i++){ if(els[i].getAttribute('value') == 'Ignore'){ els[i].click(); } };
protected function _initConfig(){
$config = $this->getApplication()->getOption('app');
Zend_Registry::set('config.app', $config['config']);
}