Skip to content

Instantly share code, notes, and snippets.

View willmanduffy's full-sized avatar
🦎
hi yes i'd like your finest wine "sir this is a mcdonalds"

Will Duffy willmanduffy

🦎
hi yes i'd like your finest wine "sir this is a mcdonalds"
View GitHub Profile
@willmanduffy
willmanduffy / auto.sh
Created December 19, 2023 21:39
List to camera changes
#!/bin/bash
log stream --predicate 'subsystem == "com.apple.UVCExtension" and composedMessage contains "Post PowerLog"' | while read line; do
if echo "$line" | grep -q "= On"; then
echo "Camera has been activated."
fi
# If we catch a camera stop event, turn the light off.
if echo "$line" | grep -q "= Off"; then
@willmanduffy
willmanduffy / calendar-utils.ts
Last active February 14, 2022 13:44
Calendar Generation
import {
endOfMonth,
getDay,
getDaysInMonth,
getWeeksInMonth,
startOfMonth,
} from 'date-fns';
import takeRight from 'lodash/takeRight';
import { mount } from 'enzyme';
import React from 'react';
import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils';
import WithInfiniteScrolling from './with-infinite-scrolling';
describe('WithInfiniteScrolling', () => {
afterEach(() => {
jest.clearAllMocks();
});
import React, { useEffect, useState } from 'react';
import { useInView } from 'react-intersection-observer';
const WithInfiniteScrolling = ({
children,
hasMultiplePages,
loading,
loadMoreFunction,
requireButtonClick = true
}) => {
import { withEvents } from 'react-compose-events';
import { compose, withHandlers, withState } from 'recompose';
import { debounce } from './utils';
const LOAD_DISTANCE_FROM_PAGE_BOTTOM = 500;
const LOAD_MORE_DEBOUNCE_TIME = 100;
const withInfiniteScrolling = (loadMoreFunctionName, startsInfiniteEnabled = false) => compose(
withState('infiniteEnabled', 'setInfiniteEnabled', startsInfiniteEnabled),
root = this
module = window.Sorta ||= {}
$ = jQuery
root.Sorta = do ( module, $ ) ->
self = module.lists = module.lists || {}
self.index = ->
Sorta.timeago.callTimeAgo()
@willmanduffy
willmanduffy / controller.js
Last active March 15, 2016 14:56
Ember Search
// app/controllers/resource/index.js
import Ember from 'ember';
// The resource in the file path here is just whatever you are searching. In this app, it's emoji
// but I wanted to standardize a bit. Here we are just defining the search query as a query param on
// line 9 and then, when the search action is triggered by the form we set the query param on the
// current route.
export default Ember.Controller.extend({
@willmanduffy
willmanduffy / test.rb
Created February 25, 2016 22:46
Cool test tho
class EmojiSearcherTest < ActiveSupport::TestCase
let(:collection) { create(:collection) }
let(:user) { create(:user) }
describe '#search' do
before { populate_emoji_list }
describe 'when a query argument is sent' do
let(:params) do
{
import Ember from 'ember';
function authorizationHeader() {
// I guess I need to inject service:session here and pull the data from it?
// how do?
}
export default Ember.Component.extend(Droplet, {
// options: {
// requestHeaders: {
@willmanduffy
willmanduffy / halp.sh
Last active November 28, 2015 17:50
HALP
curl 'http://127.0.0.1:3000/emojis/' -H 'Origin: http://localhost:4200' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36' -H 'X-File-Size: 101849' -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7ZQJvvFCg4Yp6dIO' -H 'Accept: */*' -H 'Referer: http://localhost:4200/emojis/new' -H 'Connection: keep-alive' --data-binary $'------WebKitFormBoundary7ZQJvvFCg4Yp6dIO\r\nContent-Disposition: form-data; name="file"; filename="Batman.jpg"\r\nContent-Type: image/jpeg\r\n\r\n\r\n------WebKitFormBoundary7ZQJvvFCg4Yp6dIO\r\nContent-Disposition: form-data; name="file"; filename="wonder_woman.jpg"\r\nContent-Type: image/gif\r\n\r\n\r\n------WebKitFormBoundary7ZQJvvFCg4Yp6dIO\r\nContent-Disposition: form-data; name="file"; filename="superman.jpg"\r\nContent-Type: image/jpeg\r\n\r\n\r\n------WebKitFormBoundary7ZQJvvFCg4Yp6dIO--\r\n' --compressed