Skip to content

Instantly share code, notes, and snippets.

View kmiyashiro's full-sized avatar
🐻

Kelly Miyashiro kmiyashiro

🐻
  • San Francisco, CA
View GitHub Profile
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
CustomError.prototype = Object.create(Error.prototype);
/*
* media.matchMedium()- test whether a CSS media type or media query applies
* primary author: Scott Jehl
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* adapted by Paul Irish to use the matchMedium API
* http://www.w3.org/TR/cssom-view/#media
* Doesn't implement media.type as there's no way for crossbrowser property
* getters. instead of media.type == 'tv' just use media.matchMedium('tv')
@duncanbeevers
duncanbeevers / throttle.js
Created May 11, 2011 21:56
throttle a given function
function throttle(millis, fn) {
var sched;
return function() {
if (!sched)
sched = setTimeout(function executeAndClear() { fn(); sched = false; }, millis);
};
}
@rickharris
rickharris / _shared.scss
Created December 18, 2011 17:02
Media queries with IE support using Sass 3.2 features
// Using this structure, this file should be your canonical stylesheet where
// everything would be imported into, so that you can just `@import "shared";`
// in both your normal and IE stylesheets, only having to add libraries and
// such in one place.
// These styles are just a contrived example.
body {
font-size: 18px;
@include respond-to(desktops) {
color: blue;
app.get('/robots.txt', function(req, res){
var rules = [
'User-agent: *',
'Disallow: /'
].join('\n');
res.send(rules, { 'Content-Type': 'text/plain' }, 200);
});
@joshje
joshje / supportsFFS.html
Created June 21, 2012 11:02
CSS font-feature-settings support detection
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Opentype Test</title>
<style>
span.opentype-test {
font-family: Corbel;
font-size: 100px;
position: absolute;
@emk
emk / ember-test.html
Created April 7, 2013 01:44
Testing Ember.js with Mocha, Sinon and Chai, including unit and integration tests. Runnable version available at: http://jsfiddle.net/ekidd/hCsws/13/
<!-- Mocha test output goes here. -->
<div id="mocha"></div>
<!-- Handlebars templates for our application. -->
<script type="text/x-handlebars">
<h1>Testing Ember.js with Mocha</h1>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
Ember.Model.reopenClass
adapter: MyApp.RESTAdapter.create()
camelizeKeys: true
rootKey: (->
@toString().split('.').get('lastObject').underscore()
).property()
collectionKey: (->
Em.get(@, 'rootKey') + 's'
@elithrar
elithrar / history.js
Last active January 10, 2016 14:03
smartScroll for Ember.js - reset the scroll position on forward transitions you haven't previously visited - via @rwjblue on embercommunity.slack.com
// app/locations/history.js
export default Ember.HistoryLocation.extend({
pushState() {
this._super(...arguments);
window.scrollTo(0, 0);
}
});
```​
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out default.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key default.key -out default.csr
echo "Removing passphrase from key (for nginx)..."
cp default.key default.key.org
openssl rsa -in default.key.org -out default.key