Skip to content

Instantly share code, notes, and snippets.

View brookslyrette's full-sized avatar
🏠
Working from home from now until forever.

Brooks Lyrette brookslyrette

🏠
Working from home from now until forever.
View GitHub Profile
@thevangelist
thevangelist / my-component.spec.js
Created August 4, 2016 13:06
The only React.js component test you'll ever need (Enzyme + Chai)
import React from 'react';
import { shallow } from 'enzyme';
import MyComponent from '../src/my-component';
const wrapper = shallow(<MyComponent/>);
describe('(Component) MyComponent', () => {
it('renders without exploding', () => {
expect(wrapper).to.have.length(1);
});
@francolaiuppa
francolaiuppa / express-controller.js
Last active April 21, 2023 17:31
Express JS + Amazon S3 + DropzoneJS Code Snippet
// Requires https://www.npmjs.org/package/s3-policy and https://www.npmjs.org/package/node-uuid
var config = require('env/' + process.env.NODE_ENV),
policy = require('s3-policy'),
uuid = require('node-uuid');
// SETUP S3
const AWS_ACCESS_KEY = config.s3.accessKey;
const AWS_SECRET_KEY = config.s3.secret;
const S3_BUCKET = config.s3.bucket;
@kyledrake
kyledrake / ferengi-plan.txt
Last active April 6, 2024 00:30
How to throttle the FCC to dial up modem speeds on your website using Nginx
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
@remmelt
remmelt / bamboo-to-slack.py
Last active August 31, 2023 00:35
Post an Atlassian Bamboo build result to Slack
#!/usr/bin/python
"""
Create a stage in your project, make it the last stage.
Make a task in the stage with this inline script:
#! /bin/bash
/some/path/bamboo-to-slack.py "${bamboo.planKey}" "${bamboo.buildPlanName}" "${bamboo.buildResultsUrl}"
@tstachl
tstachl / SSO.java
Created April 6, 2013 22:30
Desk.com Multipass SSO example.
import org.json.JSONObject;
import org.apache.commons.codec.binary.Base64;
import java.util.Arrays;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.net.URLEncoder;
import java.security.MessageDigest;
@jamiew
jamiew / mp4box_hacks.sh
Created March 7, 2013 18:56
Adding subtitles and audio tracks to an MP4 video with MP4Box
# Add subtitle track
MP4Box -add minecraft_uncut.srt:lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" Minecraft2_mobile.mp4
# Add audio track
# 1. doesnt work in quicktime/itunes
MP4Box -add commentary_audio.aac Minecraft2_mobile.mp4
# 2. supposed to work in quicktime/itunes but doesn't seem to; :name at least is definitely not supported
MP4Box -add commentary_audio.aac:disable:group1:lang=en:name="Director's Commentary" Minecraft2_mobile.mp4
@pcreux
pcreux / complete.sh
Created February 18, 2013 10:20
Github Commit Status API with Bamboo from Atlassian. Add those to your plan as Script.
# specs and cukes results are stored in JUnit format under test-reports
if (grep 'failures="[^0]"' test-reports/* || grep 'errors="[^0]"' test-reports/*); then
curl -H "Authorization: token MY_TOKEN" --request POST --data '{"state": "failure", "description": "Failed!", "target_url": "${bamboo.buildResultsUrl}"}' https://api.github.com/repos/USER/REPO/statuses/${bamboo.repository.revision.number} > /dev/null
else
curl -H "Authorization: token MY_TOKEN" --request POST --data '{"state": "success", "description": "Success!", "target_url": "${bamboo.buildResultsUrl}"}' https://api.github.com/repos/USER/REPO/statuses/${bamboo.repository.revision.number} > /dev/null
fi