Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ThisIsMissEm's full-sized avatar

Emelia Smith ThisIsMissEm

View GitHub Profile
@ThisIsMissEm
ThisIsMissEm / modified-resources.json
Last active August 29, 2015 13:56
Are these two Resource definitions for Cloudformation the same?
"WordPressAppAndDbServerRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
@ThisIsMissEm
ThisIsMissEm / gist:a6ae0069c7dc7ffa9f6d
Created May 12, 2014 10:00
Documentation for Sprintf() sourced from wayback machine for http://diveintojavascript.com/projects/javascript-sprintf

JavaScript sprintf()

sprintf() for JavaScript is a complete open source JavaScript sprintf implementation.

Its prototype is simple:

string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]]); The placeholders in the format string are marked by "%" and are followed by one or more of these elements, in this order:

An optional "+" sign that forces to preceed the result with a plus or minus sign on numeric values. By default, only the "-" sign is used on negative numbers.

traceroute to 4.2.2.2 (4.2.2.2), 64 hops max, 52 byte packets
1 172.20.10.1 (172.20.10.1) 4.881 ms 1.426 ms 1.291 ms
2 172.23.99.129 (172.23.99.129) 3397.333 ms 1880.334 ms 1690.922 ms
3 172.23.98.6 (172.23.98.6) 2210.959 ms 2706.279 ms 4038.367 ms
4 188.31.255.146.threembb.co.uk (188.31.255.146) 1349.220 ms 79.738 ms 1890.084 ms
5 188.31.255.101.threembb.co.uk (188.31.255.101) 1470.390 ms 274.612 ms 2804.336 ms
6 * te2-2.ccr01.lon11.atlas.cogentco.com (149.11.78.17) 2719.444 ms 59.814 ms
7 te0-0-0-34.ccr22.lon01.atlas.cogentco.com (154.54.61.53) 2089.817 ms 270.781 ms 2292.843 ms
8 level3.lon01.atlas.cogentco.com (130.117.15.246) 2786.211 ms 102.586 ms 1867.560 ms
9 vl-3604-ve-228.csw2.london1.level3.net (4.69.166.157) 1749.578 ms
@ThisIsMissEm
ThisIsMissEm / digitalocean.js
Last active August 29, 2015 14:05
I wanted to use DigitalOcean with Ansible. The python scripts don't work, so, I wrote this 70 liner node.js script.
#!/usr/bin/env node
var token = process.env.DIGITALOCEAN_TOKEN;
if(!token) {
console.error("Please specify a DIGITALOCEAN_TOKEN environment variable");
process.exit(1);
}
var request = require('request');
server 0.uk.pool.ntp.org iburst
server 1.uk.pool.ntp.org iburst
server 2.uk.pool.ntp.org iburst
server 3.uk.pool.ntp.org iburst
server 0.europe.pool.ntp.org iburst
server 1.europe.pool.ntp.org iburst
npm install --save-dev code master
npm WARN package.json mixcloud@1.0.1 No repository field.
npm http request GET https://registry.npmjs.org/code
npm http 304 https://registry.npmjs.org/code
npm http fetch GET https://registry.npmjs.org/code/-/code-1.1.0.tgz
npm http fetch 200 https://registry.npmjs.org/code/-/code-1.1.0.tgz
npm ERR! Darwin 13.2.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--save-dev" "code"
npm ERR! node v0.10.32
npm ERR! npm v2.1.4
{% macro select_for(model, name, options, selected) %}
<select class="form-control" id="{{ name }}" name="{{ model }}[{{ name }}]">
{% for option in options %}
{{ option_tag(option.value, option.title, option.value == selected) }}
{% endfor %}
</select>
{% endmacro %}
{% macro option_tag(value, title, selected=false) %}
{% if not title %}
@ThisIsMissEm
ThisIsMissEm / Samples
Last active August 29, 2015 14:08
Can you simplify this Regular Expression? Must be JavaScript compatible.
MONDAY / 9AM-10PM / WEEKLY
MONDAY-THURSDAY / 9AM-10PM / WEEKLY
TUESDAY AND THURSDAY / 9AM-10PM / WEEKLY
MONDAY / 9AM-MIDDAY / BI-WEEKLY
MONDAY-THURSDAY / 11PM-MIDNIGHT / MONTHLY
TUESDAY AND THURSDAY / MIDDAY-3PM / BI-MONTHLY
THURSDAY / MIDNIGHT-2AM / MONTHLY
@ThisIsMissEm
ThisIsMissEm / gist:0e4db76f7758afcab0e5
Created November 9, 2014 16:01
This is sometimes how I reply to recruiters or “opportunity” emails when the person spams me or really doesn't give a shit.

Dear Roberto,

Whilst I appreciate you taking great time out of your day to send me this highly personalised and tailored email offering me such a highly exclusive opportunity at your company, I have to decline.

See, it's not you, it's me. I just can't work for companies who show such laziness in recruiting. It's simply offensive. It shows that you really don't care who joins your company, unfortunately for you, I'm someone who thinkings that hiring should be about finding the right people. People who not only have technical skill and ability, but also people who live and breed the culture that your company represents.

Culturally, I think it's important to hire people that care about every aspect of the business, from the way the code is formatted, to the way the banking and recruiting is handled. Attention to details is everything, making relationships is important. You've shown in your email that all you care about is expanding your operations, and your revenue. You've not shown me anything about your cu

@ThisIsMissEm
ThisIsMissEm / pagination.rb
Last active August 29, 2015 14:10
So, I hacked together something for Grape to give me opaque cursors for pagination with Kaminari. It works, but could be a lot nicer. For instance, it doesn't handle query parameters at the moment.
require 'msgpack'
require "kaminari/grape"
module API
module V1
module Pagination
def self.included(base)
base.class_eval do
helpers do
def paginate(collection)